HighTechTalks DotNet Forums  

Oracle: Multiple lines of SQL give ORA-00911 error

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss Oracle: Multiple lines of SQL give ORA-00911 error in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Oracle: Multiple lines of SQL give ORA-00911 error - 10-13-2003 , 02:47 AM






Hi,

I have a problem with inserting an record in Oracle. I am trying to
execute the following lines of code:

string query = "INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'" +
Username + "','" + UserPassword + "','" + UserEmailaddress + "');" +
Environment.NewLine;
query += "SELECT max(USERID) from USERS;" + Environment.NewLine;
query += "COMMIT;";
OracleConnection con = new
OracleConnection(ConfigurationSettings.AppSettings ["ConnectionString"]);
OracleDataAdapter ad = new OracleDataAdapter();
ad.SelectCommand = new OracleCommand(query, con);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;

When I do the following error occurs:
System.Data.OracleClient.OracleException: ORA-00911

when I execute the result of this piece of code (the value in the
query variable) in Toad it works fine
INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'test','test','test');
SELECT max(USERID) from USERS;
COMMIT;

I have tried to execute the code also without the
'Environment.NewLine' but then the result in the query variable won't
even execute in Toad.

Can anybody give any help on this matter? Or perhaps there is someone
out there who knows a better way to return the value of the last
inserted record in Oracle?

Thanks in advance.
B.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.