473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Insert into temp tables not working

Hi,
I want to run this query. The query runs fine but it always inserts
blanks into the temp database. Any suggestions would be appreciated.
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE;

INSERT INTO SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1);

SELECT * FROM SESSION.temp_date;

DROP TABLE SESSION.temp_date;
------------------------------------------------------------------------------------------------------------
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE
DB20000I The SQL command completed successfully.

insert into SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1)
DB20000I The SQL command completed successfully.

SELECT * FROM SESSION.temp_date

V_DATE
--------------------------

0 record(s) selected.
DROP TABLE SESSION.temp_date
DB20000I The SQL command completed successfully.

Nov 12 '05 #1
4 13629
Ian
Ross wrote:
Hi,
I want to run this query. The query runs fine but it always inserts
blanks into the temp database. Any suggestions would be appreciated.
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE;

INSERT INTO SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1);

SELECT * FROM SESSION.temp_date;

DROP TABLE SESSION.temp_date;
------------------------------------------------------------------------------------------------------------
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE
DB20000I The SQL command completed successfully.

insert into SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1)
DB20000I The SQL command completed successfully.

SELECT * FROM SESSION.temp_date

V_DATE
--------------------------


By default a global temporary table drops all rows as soon as the
transaction ends. If you are not turning off auto-commit (it is
on by default), then your statements above are 4 distinct transactions.

Try:

declare global temporary table temp_date (v_date timestamp) in vdate
on commit preserve rows;
Or, disable auto-commit and issue commit explicitly.

Nov 12 '05 #2
temp table has to be in a session.
begin transaction
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE;

INSERT INTO SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1);

SELECT * FROM SESSION.temp_date;

DROP TABLE SESSION.temp_date;
end transaction

Nov 12 '05 #3

Thanks
on commit preserve rows did the trick

sh*******@gmail.com wrote:
temp table has to be in a session.
begin transaction
DECLARE GLOBAL TEMPORARY TABLE temp_date (v_date timestamp) in VDATE;

INSERT INTO SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1);

SELECT * FROM SESSION.temp_date;

DROP TABLE SESSION.temp_date;
end transaction


Nov 12 '05 #4
Ross wrote:
INSERT INTO SESSION.temp_date values(SELECT current timestamp FROM
sysibm.sysdummy1);

Anything wrong with using values as the gods of SQL intended to?
INSERT INTO SESSION.temp_date values (current timestamp)

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: xMANIGHTx | last post by:
I'm new to DTS. I read some docs before adventuring into this matter. I still haven't found in all the docs I read if there is some "built-in" DTS task or function or wathever, to do a mixed...
0
by: adove | last post by:
I am having problems with the following code. I am trying to update my db table Categories in Northwind. I have borrowed this code from www.dotnetjohn.com/articles/articleid27.aspx Although it...
4
by: sjoshi | last post by:
Hello I have these tables: CREATE TABLE . ( NOT NULL , NOT NULL ) ON CREATE UNIQUE CLUSTERED INDEX ON .(, ) WITH FILLFACTOR = 90 ON
8
by: Kragen Sitaker | last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index We've been getting this error in our application every once in a while --- typically once an hour to once a day,...
3
by: rhaazy | last post by:
Using ms sql 2000 I have 2 tables. I have a table which has information regarding a computer scan. Each record in this table has a column called MAC which is the unique ID for each Scan. The...
9
by: rhaazy | last post by:
Using MS SQL 2000 I have a stored procedure that processes an XML file generated from an Audit program. The XML looks somewhat like this: <ComputerScan> <scanheader>...
8
by: nano2k | last post by:
Hi Shortly, I keep invoices in a table. Occasionally, someone will fire the execution of a stored procedure (SP) that performs several UPDATEs against (potentially) all invoices OLDER than a...
21
by: lesperancer | last post by:
I've got an access97 reporting mdb that pulls data (77,000 rows) from a sql server table into a local table to run reports if the local table is part of the reporting MDB, the insert statement...
6
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.