#12 Cannot execute CREATE TRIGGER SQL statement

closed-fixed
nobody
None
5
2004-10-09
2004-10-07
No

(I hope I get this right, I've never used SF for anything
before)

I ran into some trouble trying to execute a CREATE
TRIGGER statement via the SQLiteCommand object. I
tracked it down to being a potential issue in
the .CommandText property.

Since each line of the trigger codes requires a semicolon
at the end, the CommandText parser routine was
prematurely truncating it.

Here is how I patched it, I'm sure you guys could do a
way better job. This way is slow and will probably mess
up the parameters. I basically just added a check to
see if "CREATE" and "TRIGGER" have already been issued
for this statement, and if the "END" has been reached
yet. If "END" hasn't been found, just append the
semicolon.

EXCERPT from Command.cs, .CommandText property:

if( ch == ';' )
{
//-------------------------------------------
--------
// 10.06.2004 MGB - Cheesy CREATE TRIGGER
hack

// If the current SQL statement has the words
CREATE
// and TRIGGER in it, but does NOT have "END"
at the
// end of it, just add the semicolon to the
query

string sSQL = sb.ToString().Trim().ToLower();
if((sb.Length > 0) &&
(sSQL.IndexOf("create") >= 0) &&
(sSQL.IndexOf("trigger") >= 0) &&
(!sSQL.EndsWith("end")))
{
sb.Append(ch); //
Append the semicolon
}

else // MGB: Original code follows ...
{
// One SQL statement is terminated.
// Add this statement to the
collection and
// reset all
oneCmdText = sb.ToString().Trim();
if( oneCmdText.Length > 0 )
mStatements.Add( new
OneSQLStatement(this,oneCmdText,paramNames) );
sb.Length = 0;
paramNames = new ArrayList();
}

// END Cheesy CREATE TRIGGER hack
//-------------------------------------------
--------
}

Discussion

  • Alexander Gavrilov

    • status: open --> closed-fixed
     
  • Alexander Gavrilov

    Logged In: YES
    user_id=1000441

    Fixed in CVS

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks