Home » Infrastructure » Windows » bug of ODP.NET
bug of ODP.NET [message #145133] Tue, 01 November 2005 01:07 Go to next message
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 #145151 is a reply to message #145133] Tue, 01 November 2005 06:27 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Any error messages? Any piece of code that might be interesting for us to look into your problem?

Perhaps your code handles only DML statements and not DDL?

Any additional info would be helpful.

Perhaps this thread at the Oracle forums might help.

MHE
Re: bug of ODP.NET [message #145270 is a reply to message #145151] Wed, 02 November 2005 02:14 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 Go to previous message
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;
}
}
Previous Topic: Oracle account on Windows 200
Next Topic: How to record response file for Oracle Client 8.1.7
Goto Forum:
  


Current Time: Mon Nov 25 05:12:17 CST 2024