Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MySQL
i have created a stored procedure but it is not creating please find out what have i done wrong
 
DELIMITER //
 CREATE PROCEDURE SP_Lock_update(IN locked int(1),IN user_id int)
    BEGIN
        update user_register , comments,articles
set
user_register.locked=locked,
comments.locked=locked,
articles.locked=locked
where
user_register.user_id=user_id
and
comments.user_id=user_id
and
articles.user_id=user_id
 
update comments
set
locked=locked
where article_id in (select article_id from articles where user_id=user_id)
    END //
 DELIMITER ;
Posted 1-Dec-12 0:54am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is because the update statement is incorrect. You need to prefix the table name to the column when two or more tables have the same column name.
So
user_register.locked=locked,
should be
user_register.locked = [Your Table Name from where the data should be taken].locked,
  Permalink  
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

i forgot to add semi colon after the each query
DELIMITER //
 CREATE PROCEDURE SP_Lock_update(IN locked int(1),IN user_id int)
    BEGIN
        update user_register , comments,articles
set
user_register.locked=locked,
comments.locked=locked,
articles.locked=locked
where
user_register.user_id=user_id
and
comments.user_id=user_id
and
articles.user_id=user_id;
 
update comments
set
locked=locked
where article_id in (select article_id from articles where user_id=user_id);
    END //
 DELIMITER ;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100