Home » SQL & PL/SQL » SQL & PL/SQL » what's wrong in this script (oracle 10gR2)
what's wrong in this script [message #576314] Sun, 03 February 2013 03:25 Go to next message
7anona
Messages: 57
Registered: February 2012
Member
hello every one please let me know what's wrong in this script
insert into history values (
:col1,
:col2,                   
:col3,                            
                       
select num from num_table where num_id='2'))

where the last column will take value from another table
Re: what's wrong in this script [message #576315 is a reply to message #576314] Sun, 03 February 2013 04:22 Go to previous messageGo to next message
dariyoosh
Messages: 532
Registered: March 2009
Location: Iran / France
Senior Member
This may help you understand what's the problem:

http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9014.htm#i2121671

Therefore, either a value_clause or a subquery but not a mixture of both.

Regards,
Dariyoosh

[Updated on: Sun, 03 February 2013 04:25]

Report message to a moderator

Re: what's wrong in this script [message #576317 is a reply to message #576314] Sun, 03 February 2013 04:54 Go to previous messageGo to next message
Michel Cadot
Messages: 59293
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
insert into history 
select :col2, :col3, num from num_table where num_id='2'
/

Regards
Michel

[Updated on: Sun, 03 February 2013 04:56]

Report message to a moderator

Re: what's wrong in this script [message #576318 is a reply to message #576314] Sun, 03 February 2013 04:55 Go to previous messageGo to next message
Michel Cadot
Messages: 59293
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Forgot to mention:

With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Re: what's wrong in this script [message #576870 is a reply to message #576314] Fri, 08 February 2013 23:53 Go to previous messageGo to next message
7anona
Messages: 57
Registered: February 2012
Member
Thanks for reply it worked now Smile
Re: what's wrong in this script [message #576884 is a reply to message #576870] Sat, 09 February 2013 06:44 Go to previous message
Solomon Yakobson
Messages: 2036
Registered: January 2010
Senior Member
And if you want to use subquery in values caluse you must enclose it in parenthesis:

insert
  into history
  values(
         :col1,
         :col2,                   
         :col3,                            
         (select num from num_table where num_id='2')
        )
/


SY.
Previous Topic: Char to Date Conversion
Next Topic: precedence
Goto Forum:
  


Current Time: Thu Oct 02 04:15:30 CDT 2014

Total time taken to generate the page: 0.05302 seconds