![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Wed, May 20 2009 5:48 PM | Permanent Link |
"Richard Speiss" | I just discovered that the EDBQuery can't execute multiple SQL statements so
I am using EDBScript, separating out the individual statements, and executing them. So my code looks something like iCount := 0; bError := False; MyDatabase.StartTransaction; repeat MyScript.SQL.Text := MyList.Strings[iCount]; try MyScript.ExecScript // I want to test for general db errors here like a key violation // MSSQL e.g. iErrorCount := Connection.Errors.Count; except bError := True; Break; end iCount := iCount + 1; until iCount = MyList.Strings.Count; if bError = False then begin MyDatabase.Commit; end else begin MyDatabase.Rollback; end; In Microsoft SQL, executing the command can generate an exception because of a syntax problem, etc. But if the error is something like a key violation no exception is generated and I just check the errors property on my ADO connection after each execute to see if there was a problem. I am just wondering how I can do that with ElevateDB 2? Thanks Richard Speiss |
Thu, May 21 2009 2:34 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Richard
The EDBScript component comes with a number of error handler events: OnEditError OnDeleteError OnPostError They should let you do what you want Roy Lambert [Team Elevate] |
Thu, May 21 2009 3:35 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Richard,
<< I just discovered that the EDBQuery can't execute multiple SQL statements so I am using EDBScript, separating out the individual statements, and executing them. So my code looks something like >> You should be using a TEDBQuery component in that case, not a TEDBScript component. << In Microsoft SQL, executing the command can generate an exception because of a syntax problem, etc. But if the error is something like a key violation no exception is generated and I just check the errors property on my ADO connection after each execute to see if there was a problem. I am just wondering how I can do that with ElevateDB 2? >> Just use something like this: iCount := 0; bError := False; MyDatabase.StartTransaction; repeat MyQuery.SQL.Text := MyList.Strings[iCount]; try try MyQuery.ExecSQL; except on E: Exception do begin if (E is EEDBError) then begin with EEDBError(E) do begin case ErrorCode of EDB_ERROR_COMPILE: begin // Handle compilation (parse/syntax) error raise; end; EDB_ERROR_CONSTRAINT: Inc(iErrorCount); end; end; end; end; end; except bError := True; Break; end iCount := iCount + 1; until iCount = MyList.Strings.Count; I've shown trapping for a syntax error vs. a constraint error, and you can include other error codes in the case statement. You can find the error codes in the edberror unit provided with EDB, and they are detailed here: http://www.elevatesoft.com/manual?action=manerrmsg&id=edb2&product=d&version=7 -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |