Home » SQL & PL/SQL » SQL & PL/SQL » Returning Value when i calling insert Query from Java
Returning Value when i calling insert Query from Java [message #321079] Mon, 19 May 2008 00:32 Go to next message
kathiresan.c
Messages: 23
Registered: February 2008
Location: Tamil Nadu, India
Junior Member
Hi Friends,

I have doubts in Insert statement,

My objective is i want to return a value when i call insert statement from the Java

For example

Insert into table_name1 values (select maxid+1 from table_name2, 'aaa',12);

Here i want get a maxid when i calling this query .
is it possible?
is there any return statement for returning the maxid value?

please help me?

Thanks in advance
Re: Returning Value when i calling insert Query from Java [message #321081 is a reply to message #321079] Mon, 19 May 2008 00:36 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Have a lok at "returning" clause.
Your syntax is wrong, you can't mix "insert values" and "insert select".

By the way, you should use a sequence instead of "maxid+1"...

Regards
Michel
Re: Returning Value when i calling insert Query from Java [message #321088 is a reply to message #321081] Mon, 19 May 2008 01:09 Go to previous messageGo to next message
kathiresan.c
Messages: 23
Registered: February 2008
Location: Tamil Nadu, India
Junior Member
Hi Michel,

Thank u for valued message... i got my value
but we can use select statement in insert statement
for example
var vcol1 varchar2(30);
insert into <table-name>(col1,col2) values ((select max(col1)+1 from <table-name>),'qqq')returning col1 into :vcol1





Re: Returning Value when i calling insert Query from Java [message #321094 is a reply to message #321088] Mon, 19 May 2008 01:24 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You're right it is now accepted (parenthesis convert your query into a value) but this is, in my opinion, awful, hardly readable and maintanable.

Regards
Michel
Re: Returning Value when i calling insert Query from Java [message #321118 is a reply to message #321094] Mon, 19 May 2008 02:30 Go to previous messageGo to next message
kathiresan.c
Messages: 23
Registered: February 2008
Location: Tamil Nadu, India
Junior Member
Hi Michel,

Everything is fine...
but when i call this query from java i got an error..

The error is ORA-00439: feature not enabled: RETURNING clause from this client type
How to solve this problem?

Re: Returning Value when i calling insert Query from Java [message #321126 is a reply to message #321118] Mon, 19 May 2008 03:19 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Client version?
Client type?
But the soluion is obviously either don't use "returning" clause or change client type.

Regards
Michel
Previous Topic: to print star in pl/sql
Next Topic: MAX INSERT PER SECOND
Goto Forum:
  


Current Time: Sun Dec 11 00:27:52 CST 2016

Total time taken to generate the page: 0.09953 seconds