cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

What's the equivalent of SET NOEXEC ON in SQL Anywhere? I want to validate a stored procedure without creating it.

View Entire Topic
VolkerBarth
Contributor

A different approach is to run DBISQL/dbisqlc with the -x option and to supply the SQL statements that should be checked as a command or a SQL file.

According to the docs, that

scans commands but does not execute them. This is useful for checking long command files for syntax errors.

For example (cf. Breck's 3rd example):

"%SQLANY11%\\bin32\\dbisql" -c <ConnectInfo> -x CREATE PROCEDURE p() AS garbage

will return SQLCODE -131 as expected.

----------Addition----------

In a batch environment, one may use the ERRORLEVEL variable to check the result, something like

"%SQLANY11%\\bin32\\dbisql" -c <ConnectInfo> -x CREATE PROCEDURE p() AS garbage
if errorlevel 1 echo Invalid SQL batch returns ERRORLEVEL: %errorlevel%

Correct syntax returns ERRORLEVEL 0 (EXIT_OK = Success). The above sample sets the ERRORLEVEL to 1 (i.e. EXIT_FAIL = General failure). Can't say if this happens for all kinds of invalid constructs, though.

Breck_Carter
Participant
0 Likes

I went looking for that, you found it :)... does dbisql set an ERRORLEVEL that could be checked in a command file? I'm guessing Brad wants some level of automation.

VolkerBarth
Contributor

@Breck: Yes, it does (as documented) - see my edits.

Breck_Carter
Participant
0 Likes

@Volker: And now we wait, for your answer to be upvoted to the top!