|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Oracle 8.1.7.0.0 - INSERT using SELECT
I'm VERY new to Oracle. I've been a SQL Server programmer for quite some time but don't understand the intricasies of Oracle.
Here's my problem: I've created a temporary table TMP_MYTMPTABLE with the following field definitions: TAGNAME VARCHAR(32), TAGDATE DATE, TAGVAL NUMBER Now, I want to insert records into this table using a select clause building the fields by concatenating values from joined tables. Here's and example: insert /*+APPEND*/ into TMP_MYTMPTABLE (TAGNAME,TAGDATE,TAGVAL) VALUES ( SELECT SUBSTR(MYTABLE1.FIELD1,3,2) || 'L.' || Lpad(TABLE1.FIELD2,3,'0') || '.' || TRANSLATE(TABLE2.FIELD2,'-','_') || '.' || TRANSLATE(TABLE3.FIELD1,'-','_'), to_char(MYTABLE1.FIELD4,'MM/DD/YYYY') || MYTABLE1.FIELD5), to_number(decode(TABLE3.FIELD6,'L0.01','0.0', TABLE3.FIELD6)) FROM MYTABLE1,TABLE2, TABLE3 WHERE MYTABLE1.FIELD1 = TABLE2.FIELD1 AND TABLE2.FIELD2 = TABLE3.FIELD2 AND TABLE2.FIELD1 IN ('TEST') ); When I run this, I get the following: ORA-00936: missing expression If I just run the select statement, it works fine! Could Oracle be getting confused with all of the functions and concatenations? Thanks |
|
#2
|
|||
|
|||
|
Code:
insert /*+APPEND*/ into TMP_MYTMPTABLE
(TAGNAME,TAGDATE,TAGVAL)
SELECT SUBSTR(MYTABLE1.FIELD1,3,2) || 'L.' || Lpad(TABLE1.FIELD2,3,'0') || '.' || TRANSLATE(TABLE2.FIELD2,'-','_') || '.' || TRANSLATE(TABLE3.FIELD1,'-','_'),
to_char(MYTABLE1.FIELD4,'MM/DD/YYYY') || MYTABLE1.FIELD5),
to_number(decode(TABLE3.FIELD6,'L0.01','0.0', TABLE3.FIELD6))
FROM MYTABLE1,TABLE2, TABLE3
WHERE MYTABLE1.FIELD1 = TABLE2.FIELD1
AND TABLE2.FIELD2 = TABLE3.FIELD2
AND TABLE2.FIELD1 IN ('TEST')
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Oracle 8.1.7.0.0 - INSERT using SELECT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|