cancel
Showing results for 
Search instead for 
Did you mean: 

multiple lines in dbisql

Former Member
0 Kudos

Hi, experts

Q1>

I tried to execute a SQL (like below).

but error occurs.

--------------- sql (bof)----------------

begin

   declare x int;

   set x=1;

   if x=1 then

      print 'x_value is 1';

   endif

end

-----------------(eof) -------------------

#### sybase IQ 15.4

dbisql -nogui

(DBA)> begin

Could not execute statement.

   Syntax error near '(end of line)' on line 1

   SQLCODE =-131, ODBC 3 State="42000"

Q2>

how to print output(for example, x_value is 1)

after executing batch sql like above sql ?

What is the option seems like "set serverouput on" in oracle ?

Unfortunately , I cannot access sap note....

please just a little comments...

Thanks in advance...

Accepted Solutions (0)

Answers (3)

Answers (3)

markmumy
Advisor
Advisor
0 Kudos

First, please consider not using the PRINT statement in IQ.  It behaves quite differently than in ASE and should be avoided if you want the statement to come back to the client.  The MESSAGE command with "TO CLIENT" is the best choice.

You can feed multiple lines from the command line without the need for a file.

sybase@sap-m6600:~$ dbisql -c "uid=DBA;pwd=SQL;eng=IQDB;dbn=IQDB" -nogui "begin declare x int; set x=1; if x=1 then message 'x_value is 1' to client; endif end"

x_value is 1

Execution time: 0.005 seconds

Simply remove the carriage returns from the input.

If you don't like that, wrap your code in double quotes like this:

sybase@sap-m6600:~$ dbisql -c "uid=DBA;pwd=SQL;eng=IQDB;dbn=IQDB" -nogui "

> begin

>    declare x int;

>    set x=1;

>    if x=1 then

>       message 'x_value is 1' to client;

>    endif

> end

> "

x_value is 1

Execution time: 0.005 seconds

Mark

tayeb_hadjou
Advisor
Advisor
0 Kudos

Hi,

For Q2, use "message...to client" command in dbisql:

message ' 'x_value is 1to client ;

in dbisql, If you use print or "message" without "to client", then the ' 'x_value is 1' is sent to srvlog file.

For Q1, note that Begin/End .. is generally used in batches, that's why reading from  file.sql is recommended as suggested by Jang.

Regards, Tayeb.

Gisung
Advisor
Advisor
0 Kudos

Hi,

There are no ways to have multiple lines in dbisql.

If you want to have multiple lines, you need to use an input file as follows.

> dbisql -c dsn=xxx -nogui read a.sql

---[a.sql]-------

  begin

....

   end

-------------------

You can have multiple lines when using isql (ASE Client) utility.

Best regards,

Gi-Sung Jang