By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

Create Oracle Trigger through C# Web service

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.