on 04-14-2016 2:52 AM
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...
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For Q2, use "message...to client" command in dbisql:
message ' 'x_value is 1' to 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.