MySQL Forums
Forum List  »  Stored Procedures

Procedure not working
Posted by: tyuyu yuty
Date: December 25, 2019 06:44PM

Hello:

I am trying to create a procedure that make inserts in table only if it has no records. It generates errors.
Anyone could help me please?
I attach the code:

Thank you.

Francesc


CREATE PROCEDURE usp_test_transaction()
BEGIN

IF ((sELECT COUNT(*) FROM 'wp_codis_postals')>0) THEN

INSERT INTO `wp_codis_postals` (`codi_postal`, `poblacio`) VALUES
(8001, 'Barcelona'),
(8002, 'Barcelona'),
(43894, 'Camarles'),
(43895, 'Ampolla, l\''),
(43896, 'Aldea, l\''),
(43897, 'Tortosa');

END IF;

END
CALL usp_test_transaction;

Options: ReplyQuote


Subject
Views
Written By
Posted
Procedure not working
1220
December 25, 2019 06:44PM
503
December 25, 2019 07:02PM
467
December 26, 2019 05:05PM
426
December 26, 2019 06:53PM
478
December 27, 2019 01:59AM
459
December 27, 2019 10:13AM
401
December 29, 2019 04:20AM
595
December 29, 2019 12:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.