Link to home
Start Free TrialLog in
Avatar of arashaga
arashaga

asked on

mysql Stored Procedure with Output parameter

I have the following stored procedure that puts a website url in a table with its description and so forth and returns the last inserted id . I was wondering if someone could give me an example with php PDO so that I can pass the parameters to it and also capture the output parameter.

Thanks
DELIMITER $$
 
create PROCEDURE add_website(IN website varchar(30),IN active Bool,
IN description varchar(150),OUT lastInsertedId INT)
begin
 
insert into website (website_url,date_created,active,description)
    values(website,NOW(),active,description);
 
select LAST_INSERT_ID() into lastInsertedId;
 
END $$

Open in new window

Avatar of pg-expert
pg-expert
Flag of India image

did you tried the example given in the links, is the example for your question.

ASKER CERTIFIED SOLUTION
Avatar of arashaga
arashaga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maheshjagadeesan
maheshjagadeesan

arashaga: I'm trying to do the very same thing. The sample code that you have pasted here doesn't seem to be complete: for example, where are you binding the output parameter? Would you be able to reply ASAP please?