Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
create or replace 
PROCEDURE LOGV_SP_INSERTUSER
              (
                i_firstname in LOGV_USERS.firstname%type,
                i_lastname in LOGV_USERS.lastname%type,
                i_username in LOGV_USERS.username%type,
                i_password in LOGV_USERS.password%type,
                i_roleid in LOGV_USERS.roleid%type,
                p_result out number
                )
          AS 
           BEGIN
               INSERT INTO LOGV_USERS
                    (
                     userid,
                     firstname,
                     lastname,
                     username,
                     password,
                     roleid
                     ) 
               VALUES
                    (
                    user_seq.nextval,
                    i_firstname,
                    i_lastname,
                    i_username,
                    i_password,
                    i_roleid
                    ); 
         p_result:=sql%rowcount;
    END  LOGV_SP_INSERTUSER;

i want return userid from this procedure how can i do that thanxs a lot
Posted
Updated 30-May-13 5:00am
v2

1 solution

Hello,

Perhaps you can modify your stored procedure as shown below.
SQL
CREATE OR REPLACE PROCEDURE LOGV_SP_INSERTUSER (
    i_firstname IN LOGV_USERS.firstname%type,
    i_lastname  IN LOGV_USERS.lastname%type,
    i_username  IN LOGV_USERS.username%type,
    i_password  IN LOGV_USERS.password%type,
    i_roleid    IN LOGV_USERS.roleid%type,
    p_result    OUT NUMBER,
    p_uid       OUT LOGV_USERS.userid%type
)
AS 
    BEGIN
        p_uid := user_seq.nextval;
        INSERT INTO LOGV_USERS (
            userid,
            firstname,
            lastname,
            username,
            password,
            roleid
        ) 
        VALUES (
            p_uid,
            i_firstname,
            i_lastname,
            i_username,
            i_password,
            i_roleid
        ); 
        p_result := sql%rowcount;

END  LOGV_SP_INSERTUSER;

Note: I am assuming that the data type for userid is NUMBER.

Regards,
 
Share this answer
 
Comments
Member 10057465 31-May-13 10:34am    
thanxs a lot it helped me.....thank u again

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900