Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    40

    Unanswered: Issue in Inserting data in GLOBAL TEMPORARY TABLE

    Following code snippet is used to create GLOBAL TEMPORARY TABLE, INSERT into the created temporary table, SELECT the same for the output.

    db2 "declare global temporary table temp1(col1 integer,col2 varchar(30)) with replace"
    db2 "insert into temp1 values(1,a)"
    db2 "select * from session.temp2"

    COL1 COL2
    ----------- ------------------------------

    0 record(s) selected.

    In the above SELECT statement output it shows "0 record(s) selected", after inserting a record previously.

    What is the problem? Can any one resolve the same?.

    Thanks,
    Kamesh.

  2. #2
    Join Date
    Aug 2004
    Posts
    15
    the corrected statements are:


    db2 "declare global temporary table temp1(col1 integer,col2 varchar(30)) with replace"

    db2 "insert into session.temp1 values(1,'a')"
    db2 "select * from session.temp1"

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Also on your DECLARE GLOBAL TEMPORARY TABLE statement, add the clause "ON COMMIT PRESERVE ROWS". Otherwise all the rows will be deleted when a commit/autocommit occurs.

    Andy

  4. #4
    Join Date
    Jul 2004
    Posts
    65

    Unhappy

    Hi BKamesh:

    I have the same problem...did you solve it?
    how?.

    Thanks in advance...

  5. #5
    Join Date
    Oct 2004
    Posts
    7

    selecting records from DGTTs

    Try auto commit off, when you running 'declare/insert/select sql'.

    One way to this would be to execute query using file input on command line and use "db2 -e- -svtf input_file_nm.sql" command

Posting Permissions

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