Oracle: Multiple lines of SQL give ORA-00911 error

B

biteside

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top