If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how to assign bind variable to another variable in db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-11, 08:15
divya.s divya.s is offline
Registered User
 
Join Date: Jul 2011
Posts: 36
how to assign bind variable to another variable in db2

how to assign bind variable to another variable in db2?

BEGIN
DECLARE
lv_ret VARCHAR2(2000);
cur PLS_INTEGER;
fdbk PLS_INTEGER;
v_sql VARCHAR(100);
a varchar(2000);
CALL DBMS_SQL.OPEN_CURSOR(cur);
SET v_sql := 'BEGIN'
|| 'val := 'lv_stack ';' ||
'END;';
CALL DBMS_SQL.PARSE(cur, v_sql, DBMS_SQL.native);
CALL Dbms_Sql.Bind_Variable_VARCHAR(cur, 'lv_ret', 'val', 2000);
CALL Dbms_Sql.EXECUTE (cur, fdbk );
/* --CALL Dbms_Sql.Variable_Value_VARCHAR(cur, 'a', lv_ret);
CALL Dbms_Sql.Close_cursor(cur);
lv_stack := lv_ret ;
*/
END


error in the assigning part lv_stack := lv_ret
Reply With Quote
  #2 (permalink)  
Old 07-21-11, 09:19
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
None of this looks like DB2 syntax. I assume you are trying to migrate from some other DBMS to DB2. What DB2 version and OS are you using? What are you trying to do with this SP?

Andy
Reply With Quote
  #3 (permalink)  
Old 07-21-11, 10:15
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 07-21-11, 14:09
shubin_du shubin_du is offline
Registered User
 
Join Date: Feb 2009
Location: Germany
Posts: 23
the variable lv_stack is not declared.

The statement

Code:
v_sql := 'BEGIN' || 'val := 'lv_stack ';' || 'END;';
is not correct because there are no || around lv_stack
Reply With Quote
  #5 (permalink)  
Old 07-21-11, 23:47
divya.s divya.s is offline
Registered User
 
Join Date: Jul 2011
Posts: 36
"Major help needed"

yes we are migrating from oracle 10g to db2 9.7..before this has been migarted from some other database to oracle...This is a big procedure which does a lot of Calculation.... and this Block is a part of it..

DECLARE

lv_ret VARCHAR2(2000);
cur PLS_INTEGER;
fdbk PLS_INTEGER;
a varchar(2000);
lv_Stack VARCHAR2(500) := (1729.78*2)*5;

CALL DBMS_SQL.OPEN_CURSOR(cur);
CALL DBMS_SQL.PARSE
(cur,'BEGIN :val := '|| lv_stack || ';END;' ,DBMS_SQL.native);
CALL Dbms_Sql.Bind_Variable_VARCHAR(cur, 'a', 'val', 2000);
CALL Dbms_Sql.EXECUTE (cur, fdbk );
CALL Dbms_Sql.Variable_Value_VARCHAR(cur, 'a', lv_ret);
CALL Dbms_Sql.Close_cursor(cur);
lv_stack := lv_ret ;

END;


what i need to do is that just parse the expression which is in lv_stack and return its calculated value back to lv_stack
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On