Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2011
    Posts
    41

    Unanswered: 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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  4. #4
    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

  5. #5
    Join Date
    Jul 2011
    Posts
    41

    "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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •