469,643 Members | 1,903 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Create Oracle Trigger through C# Web service

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

Nov 18 '05 #1
0 1883

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shashikant Khandelwak | last post: by
2 posts views Thread by David | last post: by
9 posts views Thread by Lauren Quantrell | last post: by
4 posts views Thread by Abram Friesen | last post: by
7 posts views Thread by peter.morin | last post: by
8 posts views Thread by =?Utf-8?B?RGF2aWQrKw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.