Unix Technical Forum

Newbie Question

This is a discussion on Newbie Question within the DB2 forums, part of the Database Server Software category; --> I can't seem to find the eqivalent to the MSSQLServer "print" command ?...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:03 AM
Randy
 
Posts: n/a
Default Newbie Question


I can't seem to find the eqivalent to the MSSQLServer "print" command ?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:03 AM
Serge Rielau
 
Posts: n/a
Default Re: Newbie Question

Randy wrote:
> 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

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:03 AM
Randy
 
Posts: n/a
Default Re: Newbie Question

Thanx Serge.

"Serge Rielau" <srielau@ca.ibm.com> wrote in message
news:454r0eF4vaplU1@individual.net...
> Randy wrote:
>> 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
>
> --
> Serge Rielau
> DB2 Solutions Development
> IBM Toronto Lab



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:03 AM
cheng.j3@gmail.com
 
Posts: n/a
Default Re: Newbie Question

Are you trying to print out character strings from db2 clp ? try
"echo"

>db2 echo "Hello World !"

Hello World !

Cheng

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 07:03 AM
Randy
 
Posts: n/a
Default Re: Newbie Question

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


<cheng.j3@gmail.com> wrote in message
news:1139634742.847085.216610@g47g2000cwa.googlegr oups.com...
> Are you trying to print out character strings from db2 clp ? try
> "echo"
>
>>db2 echo "Hello World !"

> Hello World !
>
> Cheng
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 07:03 AM
Serge Rielau
 
Posts: n/a
Default Re: Newbie Question

Randy wrote:
> 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
>
>
> <cheng.j3@gmail.com> wrote in message
> news:1139634742.847085.216610@g47g2000cwa.googlegr oups.com...
>
>>Are you trying to print out character strings from db2 clp ? try
>>"echo"
>>
>>
>>>db2 echo "Hello World !"

>>
>>Hello World !
>>

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

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-27-2008, 07:03 AM
adik_q@wp.pl
 
Posts: n/a
Default Re: Newbie Question

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-27-2008, 07:04 AM
Randy
 
Posts: n/a
Default Re: Newbie Question


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
....

<adik_q@wp.pl> wrote in message
news:1139836375.473547.194390@g43g2000cwa.googlegr oups.com...
> 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
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-27-2008, 07:04 AM
Knut Stolze
 
Posts: n/a
Default Re: Newbie Question

Randy wrote:

>
> 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
> ...


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.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-27-2008, 07:04 AM
Randy
 
Posts: n/a
Default Re: Newbie Question


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


"Knut Stolze" <stolze@de.ibm.com> wrote in message
news:dss67q$s3g$1@lc03.rz.uni-jena.de...
> Randy wrote:
>
>>
>> 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
>> ...

>
> 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.
>
> --
> Knut Stolze
> DB2 Information Integration Development
> IBM Germany



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com