Search code examples
db2db2-zos

DB2 Temp Table - Retrieving inserted Data in DB2 Z OS


I have created a temp table and Inserted in DB2 ZOS as mentioned below

CREATE GLOBAL TEMPORARY TABLE tmp2 (col1 INT)   

INSERT INTO tmp2 (col1) VALUES (10687);    
INSERT INTO tmp2 (col1) VALUES (10689);    
INSERT INTO tmp2 (col1) VALUES (10691);    

Inserted data with out any issues, where I'm trying to retrieve the data using select query Im unable see any values which I had inserted with the above values and getting.

select * from tmp2

I have an earlier experience in SQL Server and ran the below queries which work without any issues.

Drop table #tmp2    
CREATE TABLE #tmp2 (col1 INT)    

INSERT INTO #tmp2 (col1) VALUES (10687);    
INSERT INTO #tmp2 (col1) VALUES (10689);   
INSERT INTO #tmp2 (col1) VALUES (10691);   
select * from #tmp2   

How to get to see the inserted data?


Solution

  • Thanks for all replies.

    Below is the set of queries, actually I was looking for

    DECLARE GLOBAL TEMPORARY TABLE SESSION.tmp2 (col1 INTEGER) 
    CCSID EBCDIC ON COMMIT PRESERVE ROWS;
    INSERT INTO SESSION.tmp2 (col1) VALUES (10687);    
    INSERT INTO SESSION.tmp2 (col1) VALUES (10689);    
    INSERT INTO SESSION.tmp2 (col1) VALUES (10691);
    
    select * from SESSION.tmp2;