bug of ODP.NET [message #145133] |
Tue, 01 November 2005 01:07 |
rushing
Messages: 135 Registered: January 2004 Location: Beijing,China
|
Senior Member |
|
|
create trigger SQL statement could not run in ODP.NET and C#.
|
|
|
|
Re: bug of ODP.NET [message #145270 is a reply to message #145151] |
Wed, 02 November 2005 02:14 |
rushing
Messages: 135 Registered: January 2004 Location: Beijing,China
|
Senior Member |
|
|
create or replace trigger msg_trg
before insert on MessageTB
for each row when (new.msgid is null)
begin
select msg_seq.nextval into :new.msgid from dual;
end;
The SQL statement above could run in SQL plus , but could not run in C#.
|
|
|
Re: bug of ODP.NET [message #145284 is a reply to message #145270] |
Wed, 02 November 2005 04:06 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
I actually meant: "what is your calling code". I'm no C# programmer, but could you create a simple sample for us so we can have a closer look?
And what do you mean with "could not run in C#"? Any error messages from that side?
A long shot:
1. wrap your 'create trigger' code in an EXECUTE IMMEDIATE:
BEGIN
EXECUTE IMMEDIATE 'your create trigger statement';
END;
See whether that runs from your code.
As said: a long shot but it might work.
MHE
[Updated on: Wed, 02 November 2005 04:07] Report message to a moderator
|
|
|
Re: bug of ODP.NET [message #146370 is a reply to message #145133] |
Thu, 10 November 2005 01:25 |
rushing
Messages: 135 Registered: January 2004 Location: Beijing,China
|
Senior Member |
|
|
private bool CreateTrigger()
{
try
{
string strSql = "create trigger msg_trg before insert on MessageTB for each row when (new.MsgID is null) begin select msg_seq.nextval into :new.MsgID from dual; end;";
strSql = "BEGIN EXECUTE IMMEDIATE " + strSql + " END;";
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = Conn;
cmd.CommandText =strSql ;
cmd.ExecuteNonQuery();
cmd = null;
return true;
}
catch (Exception ex)
{
Status += " CreateTrigger:" + ex.Message + "<br>";
return false;
}
}
|
|
|