Fetch data on multiple files

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
FBuckham
Posts: 5
Joined: Mon Oct 16, 2023 10:10 pm

Fetch data on multiple files

Post 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.
cesarrafael
Posts: 32
Joined: Tue Dec 01, 2015 3:44 am

Re: Fetch data on multiple files

Post 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?
FBuckham
Posts: 5
Joined: Mon Oct 16, 2023 10:10 pm

Re: Fetch data on multiple files

Post 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.
cesarrafael
Posts: 32
Joined: Tue Dec 01, 2015 3:44 am

Re: Fetch data on multiple files

Post 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)
appbuilder
Posts: 28
Joined: Sat Jan 16, 2016 9:53 am

Re: Fetch data on multiple files

Post by appbuilder »

Check out the Predetermined Join logic to link fields from other files and use the LANSA Fetch to retrieve all the data.
Thanks,

Don
kno_dk
Posts: 219
Joined: Tue Feb 23, 2016 12:00 am

Re: Fetch data on multiple files

Post 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.
FBuckham
Posts: 5
Joined: Mon Oct 16, 2023 10:10 pm

Re: Fetch data on multiple files

Post by FBuckham »

I will try creating a function and running the call server function BIF. Thanks for your suggestions, they help!!
Post Reply