Page 1 of 1

Fetch data on multiple files

Posted: Thu Nov 16, 2023 1:27 am
by FBuckham
Hi,

Can anyone help me with accessing multiple files data on the AS400? I have tried the select_sql method but I do not have local data as all my data is in the 400. I can fetch data on one file, but I cannot fetch data on multiple files. Your assistance will be highly appreciated.

Re: Fetch data on multiple files

Posted: Thu Nov 16, 2023 1:52 am
by cesarrafael
Hi FBuckham,

Can you be a little bit more specific? What are you trying to achieve? Is it client/server data fetch? Is it OTHER File data?

Re: Fetch data on multiple files

Posted: Thu Nov 16, 2023 2:03 am
by FBuckham
In normal sql i want to :
Select (Fields) from tableA, tableB Where tableA.id = tableB.id


This is what I found on this
SELECT_SQL FIELDS((#EMPNO PSLMST.EMPNO) #SKILCODE #DATEACQR) FROM_FILES((PSLMST)(PSLSKL)) WHERE('PSLMST.EMPNO=PSLSKL.EMPNO AND SKILCODE=''4GL''') ORDER_BY(DATEACQR);

But with the previous method, the problem is that it is looking at the local db and not the db2(as400)

Thank you.

Re: Fetch data on multiple files

Posted: Thu Nov 16, 2023 3:02 am
by cesarrafael
It's true.
To use the Select_sql in that way, you'll need to call a server function and pass data from the server function in a list to your local function
e.g. Use Builtin(CALL_SERVER_FUNCTION) With_Args(*SSERVER_SSN MYSERVFN Y Y #MYLIST) To_Get(#IO$STS)

Re: Fetch data on multiple files

Posted: Thu Nov 16, 2023 7:05 am
by appbuilder
Check out the Predetermined Join logic to link fields from other files and use the LANSA Fetch to retrieve all the data.

Re: Fetch data on multiple files

Posted: Thu Nov 16, 2023 7:27 pm
by kno_dk
Hi

you can use USING on the SELECT_SQL to execute your SQL command - like this:
Select_Sql Fields(#DatoALFA #Ugedag #RUTTXT #RUTKOD #ton #tono #tonp #steder #linjer #linjerp #snit #Snitsavet #Ordre #ordreo #ordrep) Using(#SQLCMD)

Where you have your SQL command in the #SQLCMD and it returns the fields in the FILEDS parm. but you have to run it on the server.

Re: Fetch data on multiple files

Posted: Fri Nov 17, 2023 12:31 am
by FBuckham
I will try creating a function and running the call server function BIF. Thanks for your suggestions, they help!!