Maybe your system isn't up-to-date with TR's or PTF's. And I can only guess - probably your system doesn't support the Boolean keywords True and False, since they are somehow new.
And finally - we all are trying to help you - but most of us don't like doing someone else's "homework". So we at least expect some effort from your side.
I hope that you can get the query running and it helps you.
Original Message:
Sent: Tue February 18, 2025 04:32 AM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
for that i already replied in #20 what error i got and same error for below SQL as well where i have trimmed this SQL as per advice here:
"select systables.system_table_schema, systables.system_table_name,
related_objects.library_name, related_objects.system_name, related_objects.sql_object_type
from qsys2.systables as systables
join lateral (
select *
from table(
systools.related_objects(systables.system_table_schema, systables.system_table_name)
)
) as related_objects on true
where
systables.table_type in ('P', 'T')
"
Same error--- Message ID SQL0199
Message : Keyword Where not expected......
Thanks...
------------------------------
jerry ven
Original Message:
Sent: Tue February 18, 2025 01:09 AM
From: Daniel Gross
Subject: LFs pointing to PFs from incorrect libraries
#19 should work the way you described.
------------------------------
Daniel Gross
#IBMChampion
Senior Core Developer, Geis Group
Pegnitz, Germany
https://blog.qpgmr.de/
Original Message:
Sent: Mon February 17, 2025 11:44 PM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
Could we please have corrected complete SQL query here ?
Thanks...
------------------------------
jerry ven
Original Message:
Sent: Mon February 17, 2025 02:28 PM
From: Daniel Gross
Subject: LFs pointing to PFs from incorrect libraries
Jerry,
you have to reduce the SYSTABLES results to PFs and TABLEs:
systables.table_type in ('P', 'T')
Because other object types might not give the needed 2nd parameter to RELATED_OBJECTS
.
Try that please - it should work.
HTH
Daniel
------------------------------
Daniel Gross
#IBMChampion
Senior Core Developer, Geis Group
Pegnitz, Germany
https://blog.qpgmr.de/
Original Message:
Sent: Mon February 17, 2025 02:06 PM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
So tried below SQL query for the same :
"
Select Table_Schema as PFTable_Schema, Table_Name as PFTable,
Schema_Name as LFSchema, SQL_Name as LFSQLName, System_Name as LFSYSName
from SysTables a cross join
Lateral(Select *
from Table(Systools.Related_Objects(
Library_Name => a.Table_Schema,
File_Name => a.Table_Name))
Where SQL_Object_Type like '%LOGICAL%'
and Schema_Name <> a.Table_Schema
)
"
But i got this error : Message ID SQ20484
Message: Parameter 2 required for routine RELATED_OBJECTES in SYSTOOLS.
Cause: A Call statement for routine RELATED_OBJECTS in schema SYSTOOLS specified with a named parameter is not valid. Parameter 2 must be specified on the call statment because it has no default value.
Recovery: Specify a value for parameter 2. Try the request again.
So what should be the coorected SQL query here now?
Thanks ...
------------------------------
jerry ven
Original Message:
Sent: Mon February 17, 2025 10:56 AM
From: Birgitta Hauser
Subject: LFs pointing to PFs from incorrect libraries
If you want to loop through all libraries, just remove the WHERE Condition ... but do not complain about the query is running too long
------------------------------
Birgitta Hauser
Database and Software Engineer
Birgitta Hauser - Modernization-Education-Consulting on IBM i (selfemployed)
Kaufering
+49 170 5269964
Original Message:
Sent: Mon February 17, 2025 10:25 AM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
in this example also (as per post no. 5) under where systables.system_table_schema = '...your-lib...' we have to provide libary name manually which i want to avoid , so that when we run this sql query system automatically searches all such libraries and give us such LFs list .
------------------------------
jerry ven
Original Message:
Sent: Mon February 17, 2025 10:19 AM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
I am getting this error for post no. 19
Message ID : SQL0199
Message: "Keyword WHERE not expected. valid tokens: <> = <> <= !<
Cause : The keyword WHERE was not expected here. A sysntax error was detected at keyword WHERE.
Thanks..
------------------------------
jerry ven
Original Message:
Sent: Mon February 17, 2025 09:35 AM
From: Daniel Gross
Subject: LFs pointing to PFs from incorrect libraries
Jerry - no, you don't need to supply a library in my example (post #15) - just try this:
select systables.system_table_schema, systables.system_table_name,
related_objects.library_name, related_objects.system_name, related_objects.sql_object_type
from qsys2.systables as systables
join lateral (
select *
from table(
systools.related_objects(systables.system_table_schema, systables.system_table_name)
)
) as related_objects on true
where
systables.table_type in ('P', 'T')
and systables.system_table_schema <> related_objects.library_name;
But be prepared, that this might run a while - depending on your machine.
HTH
Daniel
------------------------------
Daniel Gross
#IBMChampion
Senior Core Developer, Geis Group
Pegnitz, Germany
https://blog.qpgmr.de/
Original Message:
Sent: Mon February 17, 2025 09:30 AM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
it's giving me an error "Not authorized to object QADBFDEP in QSYS type *FILE" also in advice post no. 5 and 15 we need to supply library name manually which i want to avoid and want SQL query to track and list down all such LFs without providing library name there manually.
Thanks..
------------------------------
jerry ven
Original Message:
Sent: Mon February 17, 2025 09:19 AM
From: Bryan Dietz
Subject: LFs pointing to PFs from incorrect libraries
not sure where i got this one:
-- description: _logical-not-same-lib-as-pf.sql
-- DBFTDP = Dependency: D-data,V-view,I-indirect
--
SELECT DBFFIL AS Physical_file,
DBFLIB as Physical_file_lib,
DBFFDP as Logical_file,
DBFLDP AS LogLib_file_lib
,i.*
FROM QSYS.QADBFDEP i
WHERE dbflib <> dbfldp
and DBFLIB not in('QSYS');
------------------------------
Bryan Dietz
Original Message:
Sent: Fri February 14, 2025 03:55 AM
From: jerry ven
Subject: LFs pointing to PFs from incorrect libraries
Hi,
I need to extract all such LFs which are created on PFs (which are created in incorrect libraries)
for example LF1 which is there in Lib1 and has been created on PF1 in Lib2.
So any SQL query to extract names of all such LFs ?
Thanks...