× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Roger,

I'd use this SQL to check for file existence, unless I had a reason not
to. I've not used this in a trigger before, but I've used code like this
in lots of SQL objects.

select char( case when TABLE_NAME is null then '0' else '1' end )
from ( values( 1 ) ) as V
into :TABLE_EXISTS
left join QSYS2.SYSTABLES
on TABLE_SCHEMA = :MY_SCHEMA_NAME
and TABLE_NAME = :MY_TABLE_NAME
;

--Or, if you prefer:
values
coalesce ( (
select char( '1', 1 )
from QSYS2.SYSTABLES
where TABLE_SCHEMA = :MY_SCHEMA_NAME
and TABLE_NAME = :MY_TABLE_NAME
), '0' ) into :TABLE_EXISTS

I don't recall the RPG embedding rules for the 2nd SQL, but the 1st one
should embed with simple static SQL.

Mike


date: Mon, 2 Nov 2015 15:48:12 -0800
from: Roger Harman <roger.harman@xxxxxxxxxxx>
subject: SQL Check If File Exists (via RPG)

I have a situation where I need to update/add/delete records in a
historical snapshot file (or files) if the current live file is changed
(retro-active changes).?

The historical files are named by year/month and may or may not exist for
a?selected?record.

Looking for suggestions on the quickest easiest way to verify a file's
existence. ?This will be in a trigger program.

Thanks.


Roger Harman
COMMON Certified Application Developer ? ILE RPG on IBM i on Power


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.