All Forums Database
praveen_reddy 22 posts Joined 10/11
08 May 2014
Stored procedure

Hi All,
 
Need to create a user using stored procedure. I am using the below code and getting an error
CREATE PROCEDURE abc.MyFirstProc(
   IN user_name VARCHAR(12),
    IN owner1 VARCHAR(12),
    IN password1 VARCHAR(12))
    
    BEGIN

        CREATE USER user_name FROM owner1 AS PERMANENT = 0 PASSWORD = password1

END;
 
Any help pls
 
Thanks,
Praveen.

Raja_KT 1246 posts Joined 07/09
09 May 2014

Did you try with these within your proc begin and end(Please double check the syntax and space)?
CALL DBC.SysExecSQL('CREATE USER '||user_name|| ' FROM '|| owner1 || ' AS PERMANENT = 0 PASSWORD = '||password1);
 
or EXECUTE IMMEDIATE example
 
DECLARE sqlstr VARCHAR(300);
SET sqlstring  like .... 'CREATE USER '||user_name|| ' FROM '|| owner1 || ' AS PERMANENT = 0 PASSWORD = '||password1 ;
EXECUTE IMMEDIATE sqlstring;

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

You must sign in to leave a comment.