I assume you want to run logic like this?

begin
declare res_count int;
declare continue handler for sqlstate '42710' begin end;
create table qtemp.count_table (c int);
set res_count = (select count(*) from qsys2.systriggers);
if res_count > 100 then
insert into qtemp.count_table values res_count;
else
insert into qtemp.count_table values 999;
end if;
end;

It's been available since 2013 at 7.1 and up. Look in the SQL Reference
for compound (dynamic) statement.

Sue Romano
Db2 for IBM i Development


I have a curiosity question in regards to the iNav Run SQL
Scripts
dialog window... What exactly constitutes an SQL Script from iNav's
point
of view? I have entered multiple, standalone SQL statements in the
script
window and executed those statements one at a time. But, what I would
like to know is if you can enter multiple SQL statements that interact
with each other (a.k.a., a compound SQL statement) in much the same
manner
as an internal SQL stored procedure?

I know I could create an actual stored procedure and then execute

it, but I would like to be able to just enter the compound SQL statement
(loops, calculations, variables, and all) and execute it without having
to
create an SQL object. Basically, I have a need right now to be able to
spin through say, 600 libraries and count the number of rows in a
like-named table in each of those libraries, accumulate the output into a

temporary table, and then display the results at the end. Does the iNav
support that? I could just try it, but I thought I'd ask first. ;-)

Sincerely,

Dave Clark




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.