PDA

View Full Version : how do i get error details from running a sql script?



mcchuckle
06-09-2010, 09:17 PM
hi there,

i am using the 'run command line' function to run osql.exe which executes a sql script on a sql server. i then look at %_SB_ERRORCODE% to confirm it ran ok.

it seems to me that %_SB_ERRORCODE% only produces a 1 or 0 for an osql execution. this makes installation troubleshooting a bit difficult because an error could occur in numerous places and it would be useful to let the user know exactly what type of error occurred. eg it could be a problem with a foreign key violation in the database, or it could be that the user does not have permissions on the sql server.

i found some previous forum posts that advise that native sql execution is on the cards for SetupBuilder some time in the future. has this been progressed? if not, is there a way of getting the precise error details for an osql execution?

thanks

rob

linder
06-10-2010, 12:19 AM
Rob,

If you are using the "Run Command Line" function, then %_SB_ERRORCODE% holds the return value of the CreateProcess Windows API (if it succeeded) or the value of GetLastError (if available) if it failed.

I would suggest to use the "Run Program" function -- this allows you to retrieve the ExitCode of the executed application (if it returns any code).

Does this help?

Friedrich

mcchuckle
08-12-2010, 12:58 AM
hi frederich,

thanks for your post.

i believe i am already doing this but i only get back a 0 or a 1 for success or failure. if an error has occurred, there is no useful information to feed back to the user to tell him/her which particular part of the sql execution failed. ideally i would like to know if there is a mechanism by which the sql error code and the sql error text can be put into SetupBuilder variables and displayed to the user to show why the install failed. i would imagine that this requires native support for execution of tsql commands. i have seen other posts to this forum that indicate execution of tsql commands is on the drawing board. is it likely to be included in SetupBuilder any time soon?

(http://www.lindersoft.com/forums/showthread.php?t=21477&highlight=sql)

thanks

rob