Page 1 of 1
Access to tables in different partition
Posted: Wed Feb 19, 2025 7:59 pm
by RomainG
Hello,
I am trying to learn how to create a desktop application and I am working in a different partition than the one I used for developing my web applications. I am having trouble accessing tables that I have defined in the "web" partition. I tried 2 different ways:
1) Using select_sql to try and retrieve fields from a table like this:
Code: Select all
Select_Sql Fields(#LBMACH #CDGRMC) Using(#SQLQUERY)
Add_Entry To_List(#ListView1)
Endselect
But I have this error:
The SQL database interface is not setup correctly. One cause of this is using SELECT_SQL without a local database connection as it does not work across a SuperServer connection.
Routine : X_DBM_OP macro
2) Using the option "import tables from ibm i" and then using select like this:
Code: Select all
Select Fields(#LBMACH #CDGRMC) From_File(MACH)
Add_Entry To_List(#ListView1)
Endselect
But I have this error:
Unable to load/locate OBJECT ACCESS MODULE (OAM) mach. OS Error Message : OS Error Message Number : -9999 Routine : pfnLoadObject
Thank you in advance for your help,
Romain
Re: Access to tables in different partition
Posted: Wed Feb 19, 2025 11:48 pm
by adale
Romain,
I do not know about the SQL side, but we utilize fields and files defined in our IBM db exclusively, and sometimes the fields/files are used in different partitions. In our case, when a file is needed in a new or different partition, we would: A) Import the file with the "import tables from IBM i", making note of the OAM location. We use the "Partition module folder (M)" as our default. Then once the table has been import, SAVE and Check IN all the fields first. Then save, compile, and check in the file. Then it should be good to go with the Select Fields from File. Hope this helps.
Re: Access to tables in different partition
Posted: Thu Feb 20, 2025 6:29 pm
by RomainG
Hi Arlyn,
Thanks for your reply.
I tried following your steps but it did not do the trick for me unfortunately.
I will do some more digging.
Romain
Re: Access to tables in different partition
Posted: Fri Feb 21, 2025 12:46 am
by lawingo
Would you not have to access the files via the Load Other Function?
For example file WEBLIB/XXXX is maintained in the the Partition that is set up to use WEBLIB ( your web Partition ). If the you need to access that file from PRDLIB then you would have to do a LOAD OTHER and load WEBLIB/XXXX into the production Partition. Once you do that you should be able to access the file.
Re: Access to tables in different partition
Posted: Fri Feb 21, 2025 1:01 am
by Dino
By having a different partition you are making the things complicated, still, there are solutions.
If everything were in the same partition the desktop application will know the files and fields and they will be located in the correct default library list, so all will be seamless
But if they are in a different partition, you will need to export and import the fields and files, so programs in both partitions talk about the same... but, you will be working in a blank copy of those files with no access to data.
If we were talking all in the as400 with web or green screen, a point command in the code will fix this quickly or indicating the library/schema in the select sql.
One option could be to move the actual physical files out of the partition libraries to a common one and have that library added to the library list of the users involved in the web and windows applications. I used that before for multiple companies in the same as400 where they share some common files.
Other option could be to have your windows program connect to the i5 and run a remote call server function there. That function will run in the as400 and can have all the control to access the data, select sql, or point with select, then return the result to your windows application.
Re: Access to tables in different partition
Posted: Sat Feb 22, 2025 2:40 am
by RomainG
Hi Dino,
1) Regarding this:
If everything were in the same partition the desktop application will know the files and fields and they will be located in the correct default library list, so all will be seamless
I tried creating a table in the same partition and I can access the table when I execute the application from the IDE but when I try it after deploying it using the deployment tool and installing it, I have this error:
Message : (0276) - SQL operations are not permitted in this environment. You indicated that no data base / source was available in the DBID= parameter, so you cannot now try to access one.
Routine : X_PDF_Execute_IO_Module
I added the Built-in functions DEFINE_ANY_SERVER and CONNECT_SERVER and the connection works fine.
Would you happen to know why or if I am missing something?
2) Regarding this :
Other option could be to have your windows program connect to the i5 and run a remote call server function there. That function will run in the as400 and can have all the control to access the data, select sql, or point with select, then return the result to your windows application.
I tried this method and it works fine using the same Built-in functions DEFINE_ANY_SERVER and CONNECT_SERVER as above.
Thank you for your help,
Romain