473,407 Members | 2,598 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,407 software developers and data experts.

Insert to table question

Hello,

I have a small dilemma I need some help with. I would like to insert into a DB2 table the system date (timestamp) along with data retrieved via a db2 select statement but I am unsure how to code it using one statement.

I would like to use the following format to insert to the table but I am unsure how to add the "VALUES (CURRENT TIMESTAMP)"

Format I would like to use.....
Expand|Select|Wrap|Line Numbers
  1. db2 "INSERT INTO table1 (id, type, records, country) select id, type, count(*), country  from tdb.table2 where id = 222 and group by id, type"
Also here is the table stucture,
Expand|Select|Wrap|Line Numbers
  1. Column                         Type      Type
  2. name                           schema    name               Length   Scale Nulls
  3. ------------------------------ --------- ------------------ -------- ----- ------
  4. SYSTEM_DATE                    SYSIBM    TIMESTAMP                10     0 No
  5. ID                               SYSIBM    DECIMAL                   6     0 Yes
  6. TYPE                             SYSIBM    VARCHAR                  25     0 Yes
  7. RECORDS                        SYSIBM    DECIMAL                   8     0 Yes
  8. COUNTRY                        SYSIBM    VARCHAR                   2     0 Yes
Thanks in advance
Mar 10 '08 #1
1 1775
sakumar9
127 Expert 100+
Hello,

I have a small dilemma I need some help with. I would like to insert into a DB2 table the system date (timestamp) along with data retrieved via a db2 select statement but I am unsure how to code it using one statement.

I would like to use the following format to insert to the table but I am unsure how to add the "VALUES (CURRENT TIMESTAMP)"

Format I would like to use.....
Expand|Select|Wrap|Line Numbers
  1. db2 "INSERT INTO table1 (id, type, records, country) select id, type, count(*), country  from tdb.table2 where id = 222 and group by id, type"
Also here is the table stucture,
Expand|Select|Wrap|Line Numbers
  1. Column                         Type      Type
  2. name                           schema    name               Length   Scale Nulls
  3. ------------------------------ --------- ------------------ -------- ----- ------
  4. SYSTEM_DATE                    SYSIBM    TIMESTAMP                10     0 No
  5. ID                               SYSIBM    DECIMAL                   6     0 Yes
  6. TYPE                             SYSIBM    VARCHAR                  25     0 Yes
  7. RECORDS                        SYSIBM    DECIMAL                   8     0 Yes
  8. COUNTRY                        SYSIBM    VARCHAR                   2     0 Yes
Thanks in advance

You can try this command:

Expand|Select|Wrap|Line Numbers
  1.  
  2. INSERT INTO table1 (SYSTEM_DATE, id, type, records, country) 
  3.            select CURRENT TIMESTAMP, id, type, count(*), country  from                                      
  4.                tdb.table2 where id = 222 
  5.                and group by id, type
  6.  
  7.  
Regards
-- Sanjay
Mar 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Joel Thornton | last post by:
Whenever something is inserted to a given table, I want to run some shell commands using xp_cmdshell. Would it be a bad idea to put this xp_cmdshell in the INSERT trigger of this table? I...
1
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
11
by: Jean-Christian Imbeault | last post by:
I have a table with a primary field and a few other fields. What is the fastest way to do an insert into that table assuming that sometimes I might try to insert a record with a duplicate primary...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
5
by: Andrew | last post by:
Hi, friends, In ASP, we use obj = CreateObject("com.dll") obj.GetHTMLText(inVal, outHTMLTxt1, outHTMLTxt2) to get different HTML strings based on input values. Then, we insert them into...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
9
by: David Eades | last post by:
Hi all Complete newbie here, so apologies if this is the wrong forum. I've been asked to use mysql and asp to make a simple bidding system (rather like a simple ebay), whereby users can use a...
1
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.