Create Oracle Trigger through C# Web service

Y

Yogesh

Hello Everyone
I have to create Oracle tables in my application on the
fly, which have an Autonumber field. So, everytime I
create a table, I have to create a corresponding sequence
and trigger for the table. Let's consider the following
simple example:

-------------------
create table testTable(id NUMBER(10) PRIMARY KEY, name
VARCHAR(20));

create SEQUENCE testTable_seq;

create or replace TRIGGER testTable_trig
before insert on testTable
for each row
begin
select testTable_seq.nextval
into :new.id from dual;
end;
/
------------------
The problem I'm facing is while creating the trigger. It
seems like the "/" at the end of the trigger always needs
to typed after pressing a return. Now I'm not able to
give this return character through my C# code. The ways
in which I have tried it are:

------------------
string trigger = "create or replace TRIGGER
testTable_trig before insert on testTable for each row
begin select testTable_seq.nextval into :new.id from
dual; end; " + "0x0d" + "/";

OleDbCommand myTrigger = new OleDbCommand(trigger,
myConnection);

myTrigger.ExecuteNonQuery();

AND

string trigger11 = "create or replace TRIGGER
testTable_trig before insert on testTable for each row
begin select testTable_seq.nextval into :new.id from
dual; end; "

string trigger12 = "/";

OleDbCommand myTrigger11 = new OleDbCommand(trigger11,
myConnection);
OleDbCommand myTrigger12 = new OleDbCommand(trigger12,
myConnection);

myTrigger11.ExecuteNonQuery();
myTrigger12.ExecuteNonQuery();
----------------------
Both the methods seem very stupid and as expected, don't
work :).

Can someone please help me with this problem?

Regards
-yogesh
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top