Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2006

Tip: Looking for answers? Try searching our database.

Newbie Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randy - 10 Feb 2006 22:40 GMT
I can't seem to find the eqivalent to the MSSQLServer "print" command ?
Serge Rielau - 11 Feb 2006 00:55 GMT
> I can't seem to find the eqivalent to the MSSQLServer "print" command ?

There is none. What are your trying to do?
If you want to compose a report us a cursor or a temporrary table.
If you want to debug, use the SQL Procedure debugger.

Cheers
Serge

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Randy - 11 Feb 2006 01:26 GMT
Thanx Serge.

>> I can't seem to find the eqivalent to the MSSQLServer "print" command ?
>>
[quoted text clipped - 4 lines]
> Cheers
> Serge
cheng.j3@gmail.com - 11 Feb 2006 05:12 GMT
Are you trying  to print out character strings from db2 clp ?   try
"echo"

>db2 echo "Hello World !"
Hello World !

Cheng
Randy - 11 Feb 2006 17:09 GMT
Thanx Cheng. Is there any way I can Declare variables and use "select
into's" etc, within a CommandEditor session? I would like to mix commands
like EXPORT into the PL. I think I am limited in what I can do with stored
procedures and I am limited with what I can do with clp ( same as
CommandEditor?) ... or so it seems.

Randy

> Are you trying  to print out character strings from db2 clp ?   try
> "echo"
[quoted text clipped - 3 lines]
>
> Cheng
Serge Rielau - 12 Feb 2006 00:28 GMT
> Thanx Cheng. Is there any way I can Declare variables and use "select
> into's" etc, within a CommandEditor session? I would like to mix commands
[quoted text clipped - 10 lines]
>>
>>Hello World !

Take your pick at PERL, PHP, shell-scripts...

Cheers
Serge

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

adik_q@wp.pl - 13 Feb 2006 13:12 GMT
You can declare variables in "a compound statement block, which groups
multiple independent SQL statement into single block".
(See SQL Cookbook, Graeme Birchall)

BEGIN ATOMIC
   DECLARE v_rows INT;

   SET  v_rows = (SELECT Count(*) AS c  FROM SYSCAT.COLUMNS WHERE
TABNAME = 'TAB1' AND COLNAME = 'ID');

       IF v_rows=0 THEN
           CALL sample_proc();
       END IF;
END
#

HTH,
Adrian
Randy - 14 Feb 2006 01:13 GMT
Thanx ! I tried using a "compound statement block" in my Command Editor
session and it returned an error.

BEGIN ATOMIC
DECLARE v_rows INT
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "INT" was found followin

If I can use 'blocking' in CLP or Command Editor, it would solve  my woes
...

> You can declare variables in "a compound statement block, which groups
> multiple independent SQL statement into single block".
[quoted text clipped - 14 lines]
> HTH,
> Adrian
Knut Stolze - 14 Feb 2006 09:00 GMT
> Thanx ! I tried using a "compound statement block" in my Command Editor
> session and it returned an error.
[quoted text clipped - 8 lines]
> If I can use 'blocking' in CLP or Command Editor, it would solve  my woes
> ...

Which version of DB2 are you running and on which platform?
What are you using as statement terminator?

Your statement worked quite fine for me, suggesting that you have some other
problem, not related to the statement itself.

$ db2 -td@

db2 => begin atomic
db2 (cont.) => declare v_rows int;
db2 (cont.) => set v_rows = 1;
db2 (cont.) => end@
DB20000I  The SQL command completed successfully.

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

Randy - 15 Feb 2006 01:42 GMT
I have the personal edition at home. I haven't tried this stuff at the
office yet.

DB2 UDB 8.1.1 / Windows XP
CLP says DB2/NT 8.2.3
My terminator is ; that's what it says at the bottom of the Command Editor
windows.

Randy

>> Thanx ! I tried using a "compound statement block" in my Command Editor
>> session and it returned an error.
[quoted text clipped - 24 lines]
> db2 (cont.) => end@
> DB20000I  The SQL command completed successfully.
Knut Stolze - 15 Feb 2006 07:40 GMT
> DB2 UDB 8.1.1 / Windows XP
> CLP says DB2/NT 8.2.3
> My terminator is ; that's what it says at the bottom of the Command Editor
> windows.

Try a different statement terminator first.  The thing is that the single
SQL statements inside a dynamic compound statement must always be
terminated with a ';'.  So you should a different terminator for the
dynamic compound statement (DCS) itself.  Otherwise, DB2 will assume at the
first ';' that the DCS is finished now, and when it parses the stuff from
the BEGIN ATOMIC ... to the INT, it finds a syntax error as at least the
closing END keyword is missing.

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

Randy - 16 Feb 2006 01:06 GMT
Works for me now. Thank you !

>> DB2 UDB 8.1.1 / Windows XP
>> CLP says DB2/NT 8.2.3
[quoted text clipped - 10 lines]
> the BEGIN ATOMIC ... to the INT, it finds a syntax error as at least the
> closing END keyword is missing.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.