Page 1 of 1
(RPG) Offline : How to access local table
Posted: Wed Mar 04, 2015 3:54 pm
by rdevost
Hi,
I'm working on an offline form and I just want to check if a local table or a record in a local table exists or not. The local table is not bound to any form fields. I've checked the Offline examples but can only find SQL that are bound to form fields.
1. Is there a way to simply use the SQL statement (without having them bound to a form field) to access a local table or is this only possible through the use of ECL JScript?
2. Is it possible to use the /DB.Tr.BATCHROWCOUNT property to check for a record in a local table? Or is this solely for upload/download use?
3. Is it possible to use EZI_OffLine_GetTableInfo and EZI_OffLine_GetRowDetails for this? Or is this (again) for upload and download use only?
I'm trying to look for something similar in the examples but could not find any. Any help would be greatly appreciated.
Thanks,
Rocel
Re: (RPG) Offline : How to access local table
Posted: Thu Mar 05, 2015 2:40 pm
by MarkDuignan
1. Is there a way to simply use the SQL statement (without having them bound to a form field) to access a local table or is this only possible through the use of ECL JScript?
=> You would do a SELECT count(*) Where Key=something I guess to get a count of how many rows have that key. When you get back zero - how do you expect to deal with that situation? An elaboration here would help to advise whether to use ECL or not.
In the shipped LongRangeOfflineDemo.LXP schema look at Example Programs menu. Run the Download option to create some client side sample data. Then use EXAM0310 - Counts to see selection counts appearing on the screen. So if you made bound field visible=False then you have a value - but question is what you ant to do when it is zero.
If you use Advanced Examples -> EXAM0122 you can see some ECL script accessing a local table and then writing the results onto the screen.
The screen content is created from the executed SQL - nothing is predefined or bound in any way.
This shows the basic of how ECL script can execute SQL commands and process the results - but again question si what you want to do with the result.
The RPG and ECL source code for these examples should be in your LRNG_DEMO/SOURCEEXAM - member names the same as the program names.
2. Is it possible to use the /DB.Tr.BATCHROWCOUNT property to check for a record in a local table? Or is this solely for upload/download use?
=> It's only available to server side logic.
3. Is it possible to use EZI_OffLine_GetTableInfo and EZI_OffLine_GetRowDetails for this? Or is this (again) for upload and download use only?
=> They are for use on the server only.
Re: (RPG) Offline : How to access local table
Posted: Sat Mar 07, 2015 6:40 am
by rdevost
Thanks, Mark. I'm looking at everything you have mentioned.
What I'm trying to do is, check for existence of at least one record in say, LocalFileA. If I don't find any record, then I would call an online program to download the content from the server. But if there is at least one record in LocalFileA then I proceed to my setup and screen display.
Re: (RPG) Offline : How to access local table
Posted: Wed Mar 11, 2015 11:29 am
by MarkDuignan
Why not just download the content as part of the schema startup - then you won't have to test - the data will be there?
In LongRange Studio you can specify a special schema level program that is called the Local Object Generator.
Right mouse schema name, Edit Schema Properties, then Application Settings tab.
There is also an initial form view worth knowing about.
These can be used to 'initialize' the content of a local data base and to send down other locally stored resources such as images, scripts and even form layouts. A useful feature is that when the user refreshes the schema everything is wiped and it all downloads again. You can trigger the user being prompted to refresh if something significant changes (eg: a locally stored table of valid branches or application currencies, etc). Also the refresh option can be invoked from you own programs - so the user does not have to learn to use the refresh icon.
Re: (RPG) Offline : How to access local table
Posted: Wed Mar 11, 2015 11:35 am
by MarkDuignan
The shipped demosntrattion LongRangeOfflineDem.lxp uses a Local Object Generator.
If you open the schema in LongRange Studio you can see it is program EXAM0322.
The shipped ource code is member EXAM0322 in source file LRNG_DEMO/SOURCEEXAM.
It just send down images - but I am fairly sure it could send down data and data base requests.
You add RPG code exactly like it was any other uploader/downloader program.
Re: (RPG) Offline : How to access local table
Posted: Wed Mar 11, 2015 3:42 pm
by rdevost
Thanks, Mark,for this additional information.
However, my question with the use of Local Object Generator is, if the user is out-of-range of any wi-fi signal and he starts the offline app, wouldn't he get an error message saying "You need to be connected... etc" because it will try to download the content as part of schema startup?
What I'm trying to do is if the user is offline, and the local databases are already set in place, then the user should just be able to start his offline app and use it as normal. If the local databases are incomplete, then it should try to download the missing database from the server. If user is offline at this point, then it should throw an error message.
Will also have options available for the user to synchronize (download/upload data) if he so chooses. And if he is offline, this should throw an error message. But if he doesn't press the sync button, then he should be able to use the app as normal.