Sybase - Setting console output on for printing log statements

14,024

Solution 1

Are you using Interactive SQL in sybase? Or are you invoking dbisqlc with -nogui option and passing it an SQL file for it to run?

The 'message' method is only for interactive mode.

I'm trying to figure this out as well, but as far as I can tell the console output doesn't seem to work. I tried using 'select' statement such as:

SELECT "This is my message";

And it seems to work, but is a little too hacky for my tastes.

Please let me know if this works/you figured something better out :)

~Will

Solution 2

It depends on your setup. If you are using SQL Anywhere, PRINT 'Hello' will not be written to the client window if you are connected from an embedded SQL or ODBC application. The printed message will however be visible in the Server Messages in Sybase Central.

In your case, you'll probably need MESSAGE 'Hello' type status to client as @toniedzwiedz mentioned.

Share:
14,024
Gaurav
Author by

Gaurav

Updated on June 04, 2022

Comments

  • Gaurav
    Gaurav about 2 years

    Does somebody know how to turn the console output on in Sybase. The usual statement like print 'Hello', is not working for me, it just says command executed successfully without printing the log statement.

    • toniedzwiedz
      toniedzwiedz about 11 years
      Hi, I found this question while looking for a solution to a similar problem. I'm using the Sybase Interactive SQL tool and in order to print messages, I had to replace print 'foo bar' with message 'foo bar' type status to client. I don't know if this is what you were asking so I'm posting as a comment.
  • mani_nz
    mani_nz about 8 years
    If you are trying this hack, switch to single quotes as double doesn't work.
  • alex.b
    alex.b about 8 years
    Isn't it the same as print 'Hello' which isn't working for OP?
  • user121391
    user121391 over 7 years
    Unfortunately dbisql seems to ignore anything else after the first statement in each file, so this does not really work this way.
  • user121391
    user121391 over 7 years
    I have to clarify my last comment: it is possible, but you must first set dbisql to return all result sets with SET OPTION ISQL_PRINT_RESULT_SET='ALL'; as seen on wiki.scn.sap.com/wiki/display/SQLANY/… (default is LAST). Then it works as you described.