Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old January 25th, 2005, 09:44 AM
wilsoct wilsoct is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 wilsoct User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 40 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old January 25th, 2005, 10:13 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
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')

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle 8.1.7.0.0 - INSERT using SELECT


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway