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