Execute multiple DDL statements for Oracle...

K

Kelly Summerlin

If I have a text file with multiple DDL statements say:

CREATE TABLE PROFILE.GroupRoles (....);
CREATE TABLE PROFILE.UserGroups (....);
/* about ten more CREATE TABLE statements left out for brevity */

and in my OracleCommand I do something like this:

OracleCommand cmd = conn.CreateCommand();
//streamReader was opened on the text file.
cmd.CommandText = streamReader.ReadToEnd();
cmd.ExecuteNonQuery();

I get an OracleException "invalid character ORA-00911"

If there is a way to do this? I'd like to know because I'm trying to
stay away from doing things totally different for SQLServer and
Oracle. If I have to split the text at some terminator and execute
each CREATE individually then I can do that. But I'd like to take the
"easy way" if at all possible and submit one batch as I can do in
SQLServer.


TKS
 
P

Paul Clement

On 20 Apr 2004 13:56:40 -0700, (e-mail address removed) (Kelly Summerlin) wrote:

¤ If I have a text file with multiple DDL statements say:
¤
¤ CREATE TABLE PROFILE.GroupRoles (....);
¤ CREATE TABLE PROFILE.UserGroups (....);
¤ /* about ten more CREATE TABLE statements left out for brevity */
¤
¤ and in my OracleCommand I do something like this:
¤
¤ OracleCommand cmd = conn.CreateCommand();
¤ //streamReader was opened on the text file.
¤ cmd.CommandText = streamReader.ReadToEnd();
¤ cmd.ExecuteNonQuery();
¤
¤ I get an OracleException "invalid character ORA-00911"
¤
¤ If there is a way to do this? I'd like to know because I'm trying to
¤ stay away from doing things totally different for SQLServer and
¤ Oracle. If I have to split the text at some terminator and execute
¤ each CREATE individually then I can do that. But I'd like to take the
¤ "easy way" if at all possible and submit one batch as I can do in
¤ SQLServer.

Don't you need to wrap the statements with BEGIN...END;?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

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

Top