Oracle 5.0 Reference Manual page 1914

Table of Contents

Advertisement

}
catch (Exception ex)
{
}
conn.Close();
Console.WriteLine("Done.");
}
static void script_StatementExecuted(object sender, MySqlScriptEventArgs args)
{
Console.WriteLine("script_StatementExecuted");
}
static void script_ScriptCompleted(object sender, EventArgs e)
{
/// EventArgs e will be EventArgs.Empty for this method
Console.WriteLine("script_ScriptCompleted!");
}
static void script_Error(Object sender, MySqlScriptErrorEventArgs args)
{
Console.WriteLine("script_Error: " + args.Exception.ToString());
}
}
}
Note that in the
EventArgs.Empty. In the case of the
obtained, which is why the event object is EventArgs.Empty.
20.2.4.8.1. Using Delimiters with MySqlScript
Depending on the nature of the script, you may need control of the delimiter used to separate the
statements that will make up a script. The most common example of this is where you have a multi-
statement stored routine as part of your script. In this case if the default delimiter of ";" is used you will
get an error when you attempt to execute the script. For example, consider the following stored routine:
CREATE PROCEDURE test_routine()
BEGIN
SELECT name FROM TestTable ORDER BY name;
SELECT COUNT(name) FROM TestTable;
END
This routine actually needs to be executed on the MySQL Server as a single statement. However, with
the default delimiter of ";", the
first being:
CREATE PROCEDURE test_routine()
BEGIN
SELECT name FROM TestTable ORDER BY name;
Executing this as a statement would generate an error. To solve this problem
the ability to set a different delimiter. This is achieved through the Delimiter property. For example, you
could set the delimiter to "??", in which case the above stored routine would no longer generate an
error when executed. Multiple statements can be delimited in the script, so for example, you could have
a three statement script such as:
Connector/Net Tutorials
MySqlScript script = new MySqlScript(conn, sql);
script.Error += new MySqlScriptErrorEventHandler(script_Error);
script.ScriptCompleted += new EventHandler(script_ScriptCompleted);
script.StatementExecuted += new MySqlStatementExecutedEventHandler(script_StatementExecuted
int count = script.Execute();
Console.WriteLine("Executed " + count + " statement(s).");
Console.WriteLine("Delimiter: " + script.Delimiter);
Console.WriteLine(ex.ToString());
script_ScriptCompleted
ScriptCompleted
MySqlScript
event handler, the
EventArgs
event there is no additional data to be
class would interpret the above as two statements, the
1894
parameter
will be
e
supports
MySqlScript

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents