cancel
Showing results for 
Search instead for 
Did you mean: 

SQLCLI error return values

Former Member
0 Kudos

Hello,

I'm hoping someone can advise me on the return code from sqlcli.

I would like to get a different return code back from the program based on whether or not the query succeeded or faild.

For example when calling from a Windows batch file.

sqlcli -n server -d MAXDB1 -u USER,pw "SELECT 1 FROM DUAL"

%errorlevel% is 0

When calling with a bad SQL statement

sqlcli -n server -d MAXDB1 -u USER,pw "BAD SQL"

Results in this return information:

  • -3005: POS(1) Invalid SQL statement SQLSTATE: 42000

But %errorlevel% is still 0

I tried the -E option to set a different return value but any value I set is returned whether or not the SQL statement succeeds.

Is there a way to determine whether or not the SQL statement was successful by checking the return value?

Thanks,

Troy

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

OK,

Would you happen to know the purpose of the -E option?

The value I set using that option always appears to be the return code from sqlcli whether or not there are any errors.

Thanks,

Troy

lbreddemann
Active Contributor
0 Kudos

> Would you happen to know the purpose of the -E option?

> The value I set using that option always appears to be the return code from sqlcli whether or not there are any errors.

Yep - looks like this is the case.

Since the documentation is not very elaborate on this, I'm gonna drop the developer a line.

regards,

Lars

lbreddemann
Active Contributor
0 Kudos

HI Troy,

I mailed with the developer of SQLCLI and the current behavior is in fact a bug.

The PTS no. for this is 1182577.

regards,

Lars

Former Member
0 Kudos

Thank you for following up!

Troy

lbreddemann
Active Contributor
0 Kudos

statement succeeds.

>

> Is there a way to determine whether or not the SQL statement was successful by checking the return value?

No, there isn't such a way.

The program itself worked as it should and handling SQL-errors that may occur won't leave sqlcli with a returncode <>0.

regards,

Lars