Results 1 to 5 of 5

Thread: Writing temporary table problem

  1. #1
    Join Date
    Jan 2010
    Posts
    261

    Writing temporary table problem

    I have a problem writing to a temporary table. Here are some additional indications

    - Z / OS
    - COBOL program.
    - DB2 V7

    Here is my code

    creating the temporary table
    Code:
    EXEC SQL                                                          
        CREATE GLOBAL TEMPORARY TABLE SESSION.TEMPCOCS                 
         ( DATA1                 CHAR(12) NOT NULL,               
           DATA2               CHAR(4) NOT NULL,                
           DATA3               CHAR(45) NOT NULL,               
            )                                                          
     END-EXEC.
    I integrate the data into the table:
    Code:
    EXEC SQL                          
       INSERT INTO SESSION.TEMPCOCS   
              (DATA1                  
              ,DATA2                  
              ,DATA3                  
              )                       
       VALUES (:WS-DATA1              
              ,:WS-DATA2              
              ,:WS-DATA3              
              )                       
     END-EXEC.
    the displays shows that we move 22 times in the INSERT table

    at the end I expect the data in this table:
    Code:
    EXEC SQL                                                     
     SELECT COUNT(*) INTO :WS-COMPT FROM SESSION.TEMPCOCS           
     END-EXEC.
    but the result is zero.

    I tried to add like but nothing changes. I'm always in the same session when I did the select count.

  2. #2
    Join Date
    Nov 2008
    Posts
    1,221

    Re: Writing temporary table problem

    Recall the principle of global temporary tables: Data inserted in a xxl are automatically deleted without user intervention (no delete) in the first commit. So, if after each insertion, you do a commit, this has the effect of removing the line you just inserted (same with a rollback)!

    Check between your insert and your select, there is no order to generate an automatic commit and normally you should be able to read your lines without worry.

    The global temporary tables may go many services but keep in mind that you can not load lines in a xxl x in a program for use in a program there, unless these programs are actually ss pros-known even by the calling program.

    The only exception I know to delete the rule in cases of automatic commit: if you declared a cursor with the option 'with hold' on the global temporary tables, whereas a commit does not delete rows from the xxl. This allows, inter alias, use a xxl in a program and you will be able to make intermediate commits to release locks and validate what is already made.

    Other rules on xxl: no update, no delete selectively, just the SQL insert, select and delete without where clause.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Writing temporary table problem

    The data should probably be written in blocks (or groups) of lines, ie the physical transfer between memory and BDD occurs only when a number of lines is placed in the output buffer. This number is usually determined by the compiler determining the blocking factor (number of rows per block), depending on factors such as length of each line (record), the volume of the database, the space available on discs, etc..

    It is therefore possible, although data are not yet physically written to the DB and still reside in the write buffer until the block is completed by additional lines or that the table is closed. So, the select count (*) would give zero.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Writing temporary table problem

    Quote Originally Posted by MindSpace View Post
    It is therefore possible, although data are not yet physically written to the DB and still reside in the write buffer until the block is completed by additional lines or that the table is closed. So, the select count (*) would give zero.
    I think not. Even if the rows are physically stored offline (and yet here we are dealing with a temporary table), the SELECT statement always reads the "buffer" of data (we talk about BUFFER POOL in DB2 z/OS terminology ).

  5. #5
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Writing temporary table problem

    Replace CREATE by DECLARE , for example:
    Code:
    In working 
    EXEC SQL                                              
      DECLARE SESSION.TEMP_NOTEBOOK TABLE                   
      (IDCORIG CHAR(3) ,                                  
       BANK CHAR(5) )                                  
    END-EXEC      
                                            
    In procedure 
    EXEC SQL                                                       
      DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_NOTEBOOK            
      (IDCORIG CHAR(3) ,                                           
       BANK CHAR(5) )                                           
    END-EXEC 
     
    EXEC SQL                                                       
      INSERT INTO SESSION.TEMP_NOTEBOOK            
      ( IDCORIG ,                                                  
        BANK )                                                  
      VALUES                                                       
      ( 'BET'   ,                                                  
        '12345' )                                                  
    END-EXEC

Similar Threads

  1. Replies: 3
    Last Post: 27-10-2010, 01:51 PM
  2. Problem in reading and writing files in VB6
    By Badrunath in forum Software Development
    Replies: 4
    Last Post: 23-01-2010, 08:14 PM
  3. Error writing to the temporary location
    By McGrawh in forum Windows Software
    Replies: 3
    Last Post: 03-07-2009, 01:04 PM
  4. how to create sql temporary table for xml format using vb.net
    By runet in forum Software Development
    Replies: 3
    Last Post: 31-03-2009, 08:28 AM
  5. Temporary table in VB.NET
    By ArunJ in forum Software Development
    Replies: 4
    Last Post: 18-02-2009, 07:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,454,410.67083 seconds with 16 queries