Quote:
Originally Posted by przytula_guy
xx=`db2 -x "SELECT CURRENT_DATE FROM SYSIBM.SYSDUMMY1 WITH UR "`
echo $xx
|
It does not work. Here's my code
Code:
#!/bin/bash
...............
db2bin="/users/db2inst1/sqllib/bin"
$db2bin/db2 connect to CTSS_VW;
out=`$db2bin/db2 -x "SELECT CURRENT_DATE FROM SYSIBM.SYSDUMMY1 WITH UR "`
echo $out
$db2bin/db2 quit;
and this is the error I got
Code:
$>. test.sh
Database Connection Information
Database server = DB2/LINUXX8664 9.1.4
SQL authorization ID = CTSS_VW
Local database alias = CTSS_VW
SQL1024N A database connection does not exist. SQLSTATE=08003
DB20000I The QUIT command completed successfully.
To get around this error, I put all my code in a script like so
Code:
CONNECT TO CTSS_VW;SELECT CURRENT_DATE FROM SYSIBM.SYSDUMMY1 WITH UR;QUIT;
and executed this
Code:
xx=`$db2bin/db2 -tf test.sql`; echo $xx
It outputs the result
Code:
Database Connection Information Database server = DB2/LINUXX8664 9.1.4 SQL authorization ID = CTSS_VW Local database alias = CTSS_VW ---------- 10/04/2011 1 record(s) selected. DB20000I The QUIT command completed successfully.
but I would to clean it up which defeats the purpose ; is there a better way??