Insert values into a destination table with more columns and select values from source table.

Database
Enthusiast

Insert values into a destination table with more columns and select values from source table.

Hi Technos,

 

I need a bit of an assistance. May be a silly question but need an answer to it. 

 

I have a table T1 with columns (C1,C2,C3....................C8,C9,C10) and 

table T2 with columns (C1,C2,C3......C7)

Table T1 has 3 extra columns where I need to send default values.

 

C8 varchar (10), C9 TIMESTAMP WITH TIMEZONE, C10 TIMESTAMP WITH TIMEZONE

 

I would like to insert values into table 1 and select values from T2 but at the same time pass default values to columns C8,C9,C10 in T1. 

 

Not sure if the following syntax is correct.

 

INSERT INTO T1 (C1,C2,C3,C4,C5,C6,C7,C8,C9,C10)

SELECT (C1,C2,C3,C4,C5,C6,C7,'adhoc',current_timestamp, current_timestamp)

from T1

 

but it fails mentioning invalid expression.

 

Can I do something like this or please let me know the alternate way.

 

 

 

2 REPLIES
Enthusiast

Re: Insert values into a destination table with more columns and select values from source table.

Please ignore this topic as I have now fixed the problem i had. 


ivan wrote:

Hi Technos,

 

I need a bit of an assistance. May be a silly question but need an answer to it. 

 

I have a table T1 with columns (C1,C2,C3....................C8,C9,C10) and 

table T2 with columns (C1,C2,C3......C7)

Table T1 has 3 extra columns where I need to send default values.

 

C8 varchar (10), C9 TIMESTAMP WITH TIMEZONE, C10 TIMESTAMP WITH TIMEZONE

 

I would like to insert values into table 1 and select values from T2 but at the same time pass default values to columns C8,C9,C10 in T1. 

 

Not sure if the following syntax is correct.

 

INSERT INTO T1 (C1,C2,C3,C4,C5,C6,C7,C8,C9,C10)

SELECT (C1,C2,C3,C4,C5,C6,C7,'adhoc',current_timestamp, current_timestamp)

from T1

 

but it fails mentioning invalid expression.

 

Can I do something like this or please let me know the alternate way.

 

 

 


 

Scout

Re: Insert values into a destination table with more columns and select values from source table.

Please make c9 and c10 colums data type are as timstamp(6), then it should work.