From: Mike S. <mi...@mi...> - 2003-04-11 11:59:16
|
Carlos I've been looking at the source code :-) I see that you use an explicit ';' to split batch commands. This is essentially the same problem that the ISQL SET TERM command solves. Here's a proposed modification to FbCommand.cs that adds a CommandTerminator property to allow the user to set the command terminator to something other than semi-colon: // added these fields private string terminator = ";" ; private char[] terminatorChars = { ';' } ; // new property public string CommandTerminator { get { return terminator ; } set { if ( terminator != value ) { terminator = value ; terminatorChars = value.ToCharArray() ; } } } // modified CommandText /// <include file='xmldoc/fbcommand.xml' path='doc/member[@name="P:CommandText"]/*'/> public string CommandText { get { return commands[actualCommand] == null ? "" : commands[actualCommand]; } set { if (statement != null && commandText != value && commandText != String.Empty) { statement.DropStatement(); } commandText = value; commands = commandText.Split(terminatorChars); actualCommand = 0; } } Cheers, Mike. -----Original Message----- From: Carlos Guzman Alvarez [mailto:car...@te...] Sent: 11 April 2003 11:13 To: mi...@mi... Subject: Re: [Firebird-net-provider] Re: How to CREATE DATABASE using .Net FB Provider Hello: > But your last email suggested that you'd now got it to work with stored > procs. Here's some sample dialect 3 code to create a stored proc. Could you > try it and tell me how you got it to do it! :-) > > CREATE PROCEDURE "CreateUserKey" returns (AVALUE Integer) AS > begin > avalue = gen_id("UserID",1); > end You can do that using ExecuteNonQuery method, now batch command execution is restricted to ExecuteReader calls. A piece of code using your stored proc sample: FbConnection connection = new FbConnection(connectionString); connection.Open(); FbTransaction transaction = connection.BeginTransaction(); StringBuilder batchCommand = new StringBuilder(); batchCommand.Append( "CREATE PROCEDURE \"CreateUserKey\" returns (AVALUE Integer) AS \r\n" + "begin \r\n" + "\tavalue = gen_id(\"UserID\",1); \r\n" + "end"); FbCommand command = new FbCommand(batchCommand.ToString(), connection, transaction); command.ExecuteNonQuery(); command.Dispose(); transaction.Commit(); connection.Close(); > It seems that Firebird is using that semi-colon as a delimiter, so the only > way to get this to work is to change the delimiter, but I don't know how to > do that. It's not firebird it's the provider for allow batch command execution :) -- Best regards Carlos Guzmán Álvarez Vigo-Spain "No tengo dones especiales.Sólo soy apasionadamente curioso" Albert Einstein, científico. |