Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2012
    Posts
    25

    Question Unanswered: Define Variable type dynamically in stored procedures in DB2

    Is it possible to define the type of a variable in a stored procedure dynamically with the type of a column in a table..

    I want to set the type of myVar the type of mytable.mycolumn

    DECLARE at_end SMALLINT DEFAULT 0;
    DECLARE myVar VARCHAR(21); -- It should be the type of mytable.mycolumn

    In Oracle it would be possible with age_of_person mytable.mycolumn%TYPE;

    How does it work in DB2 9.7??

    DB2 9.7

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by kotuboy View Post

    In Oracle it would be possible with age_of_person mytable.mycolumn%TYPE;

    How does it work in DB2 9.7??
    Exactly the same, if you enable Oracle compatibility.

    %TYPE attribute in variable declarations (PL/SQL) - IBM DB2 9.7 for Linux, UNIX, and Windows

  3. #3
    Join Date
    Mar 2012
    Posts
    25

    How

    How can i enable oracle compatibility??

  4. #4
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Tags for this Thread

Posting Permissions

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