Home » RDBMS Server » Server Administration » Re: Stored Procedure
Re: Stored Procedure [message #369787] Wed, 11 October 2000 15:13 Go to next message
Sivakumar SG
Messages: 14
Registered: August 2000
Junior Member
I think you have to use dynamic SQL to do the above
Re: Stored Procedure [message #369788 is a reply to message #369787] Wed, 11 October 2000 16:26 Go to previous messageGo to next message
Anita
Messages: 21
Registered: March 2000
Junior Member
Thanks for quick response. Can you give me some sample code so that I can get an idea of how to work with it.
Re: Stored Procedure [message #369789 is a reply to message #369787] Wed, 11 October 2000 22:36 Go to previous messageGo to next message
Aditya Deshpande
Messages: 3
Registered: October 2000
Junior Member
Create or Replace procedure test
(new_code IN VARCHAR2,
TBL_NAME IN VARCHAR2,
MSG_DESC OUT VARCHAR2)
IS
BEGIN DECLARE
queryStr Varchar2(2000);
TYPE TempRefCursor IS REF CURSOR;
c1 TempRefCursor;

BEGIN
queryStr := 'SELECT MESSAGE INTO MSG_DESC '
|| 'FROM :Tbl '
|| 'WHERE CODE=NEW_CODE' ;
OPEN c1 FOR queryStr USING TABLE_NAME;
FETCH c1 INTO MSG_DESC;
END;
END;
Re: Stored Procedure- A little Mistake [message #369790 is a reply to message #369787] Wed, 11 October 2000 22:40 Go to previous message
Aditya Deshpande
Messages: 3
Registered: October 2000
Junior Member
Sorry made a little mistake. Comes when you are trying to give a quick answer and rely too much on copy and paste :o)

Create or Replace procedure test
(new_code IN VARCHAR2,
TBL_NAME IN VARCHAR2,
MSG_DESC OUT VARCHAR2)
IS
BEGIN DECLARE
queryStr Varchar2(2000);
TYPE TempRefCursor IS REF CURSOR;
c1 TempRefCursor;

BEGIN
queryStr := 'SELECT MESSAGE'
|| 'FROM :Tbl '
|| 'WHERE CODE= :code';
OPEN c1 FOR queryStr USING TABLE_NAME,new_code;
FETCH c1 INTO MSG_DESC;
END;
END;
Previous Topic: Record Groups using Bind Variable.
Next Topic: insertion.. How can we make multiple insertion in a table?? PLZ HELP
Goto Forum:
  


Current Time: Sun Dec 22 15:43:40 CST 2024