Mike and Stephie MacDonald
asked on
Adminer stored procedure with IN paramters and internal vars
Have a problem getting a stored procedure to work in Adminer
This fails on the first line
Comments / tips very welcome
This fails on the first line
Comments / tips very welcome
DECLARE @new_project_id int;
DECLARE @current_snapshot_id int;
DECLARE @new_snapshot_id int;
insert into project select * from project where project_id=@in_project_id
SET @new_project_id = last_insert_id()
for each row in (select * from snapshot where project_id=@in_project_id)
insert into snapshot values(
@new_project_id,
last_update
snapshot_date
snapshot_title
snapshot_note
)
SET @new_snapshot_id = last_insert_id()
insert into layer select new_snapshot_id, * from layer where snapshot_id =row.snapshot_id
loop
ASKER
Hi KV!
Thanks very much for your comments. Sorry for the delay in getting back - alerts don't seem to be working
Should have given a bit more explanation in the question
Any comments on the adminer issue would be very much appreciated.
We'll take your comments around the SQL and work with that
Thanks very much for your comments. Sorry for the delay in getting back - alerts don't seem to be working
Should have given a bit more explanation in the question
- The focus of the question is getting any SP to run in Adminer
- The purpose of the SP is to copy a table entry along with all its subtable entries
- The schema is: project -<- snapshot -<- layer
- Input a project id
- Duplicate the project
- Duplicate all children of the project as children of the new project
Any comments on the adminer issue would be very much appreciated.
We'll take your comments around the SQL and work with that
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Considering in_project_id will be unique, the for-each makes no sense.
Also, please review the query inside for-each, which is not correct.
Do you think an after-insert trigger is what you want here?
Review mysql documentation for using procedure.
Look around for some sample procedures if you're starting with writing procedures.