Check If Object Exists (OBJEXISTS) UDF

Index

Schema IQUERY

OBJEXISTS( library_name => '*LIBL', 
           object_name => 'object-name', 
           object_type => '*FILE'
           quietMode = 0 )

The Check if Object Exists (OBJEXISTS) User Defined Function returns 1 if the object exists otherwise it returns 0.

Returns

1 = Object Found.

0 = Object Not Found.

Parameters

LIBRARY_NAME

The library name of the object. If unspecified, *LIBL is used.

OBJECT_NAME

The name of the object being checked. This is a required parameter, unless the fully qualified object is specified on the LIBRARY_NAME parameter using non-parameter syntax.

OBJECT_TYPE

The object type of the object being checked. If unspecified *FILE is used. It must be a valid IBM i OS Object Type, such as *FILE, *PGM, *DTAARA, but can also be special SQL Object Types, such as *SQLVAR, *SCHEMA, in addition *SAVF may be specified.

QUIETMODE

Default: 0

When specified with a value of 1, messages such as "Object not found." will not be written to the joblog.

Examples

select 1 from sysibm.sysdummy1 where iQuery.objExist('QIWS/QCUSTCDT') = 1

In SQL iQuery script, it can be used on the IF statement:

if iQuery.ifsExists(object_name=>'DEBUGDA', object_type=>'*dtaara') = 1;
 #msg The DEBUGDA data area exists!
else;
 #msg Data area DEBUGDA not found.
endif;