Jump to content

Stored Procedure Question


zohab

Recommended Posts

Hi,

 

I want to write stored procedure with one select query and 3 update queries.

 

I want to fetch 2 columns from first select query and use them in next 3 update queries.

 

Following is the procedure body.

 

PROCEDURE CHANGEORDER_TABLENAME(
P_ID NUMBER,
P_OLD_PARENT NUMBER,
P_DEST_PARENT NUMBER,
P_DEST_POSITION NUMBER
, RC1 OUT RCT) AS
BEGIN
OPEN RC1 FOR
SELECT TABLENAME_POSITION,TABLENAME_PARENT FROM AC_TABLENAME;
/*
SELECT TABLENAME_PARENT, TABLENAME_POSITION FROM AC_TABLENAME WHERE TABLENAME_ID = P_ID
UPDATE AC_TABLENAME SET TABLENAME_POSITION = TABLENAME_POSITION - 1 WHERE TABLENAME_POSITION > TABLENAME_POSITION AND TABLENAME_PARENT = TABLENAME_PARENT
UPDATE AC_TABLENAME SET TABLENAME_POSITION = TABLENAME_POSITION + 1 WHERE TABLENAME_POSITION => P_DESTPOSITION AND TABLENAME_PARENT = P_DESTPARENT
UPDATE AC_TABLENAME SET TABLENAME_POSITION = P_DESTPOSITION WHERE TABLENAME_PARENT => P_DESTPARENT AND ID = P_ID
*/
END;

 

- Thanks

Zohaib.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.