[RPG] retreive the value of textbox which is bind to SQL statement

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
MegumiSawada
Posts: 268
Joined: Tue Feb 19, 2013 5:18 pm

[RPG] retreive the value of textbox which is bind to SQL statement

Post by MegumiSawada »

Hi,

On the formview for uploading local database table to server, there is a textbox and its value is retrieved from local database table by SQL. Uploading program is just like EXAM0302.

I would like to use that value of textbox in RPG after BUTTON1(Upload button) is tapped.

Code: Select all

A                                  3 10HTML('<<TEXT1>>              
A                                      TYPE: TEXTBOX                
A                                      LAYOUT.COLS : -1             
A*                                     NAME: TEXT1                  
A                                      VALUE.&.SQL: "SELECT         
A                                      SURNAME FROM CONTACT         
A                                      WHERE ROWID = 1"             
A                                      ')                           
A                                  4 10'<<BUTTON1>>'                
A                                  4 10HTML('                       
A                                       TYPE: BUTTON +              
A                                       VALUE: "Upload" +   
A                                       ONCLICK: UPLOAD +           
A                                      ')                           
I have tried to get the value of TEXT1 in several ways,such as LRNG_GetProperty, but am not able to succeeded in it.

Is it possible to retreive the value of textbox which is bind to SQL statement?

I appreciate your kind advice.

Best Regards,
Megumi Sawada
tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: [RPG] retreive the value of textbox which is bind to SQL statement

Post by tsupartono »

Value of bound properties can't be read directly in the RPG program using LRNG_GetProperty (or its variants), they are accessible only through the underlying data (that is, what the property is bound to, such as a field on a database table).

If the value that you want is part of the uploaded data, then it's already accessible from your RPG program.

If it's not part of the uploaded data, you can use form variable to explicitly send the value that you want to the server.
In your example, you want to send the result of query "SELECT SURNAME FROM CONTACT WHERE ROWID=1".
You can explicitly execute the query, and then send the result to a form variable.
When the form is submitted (provided you set Form.SubmitVars to Y), you can access this from your RPG program (using Form.Vars)

Example of ECL:

Code: Select all

lrexec
(
	function() 
	{ 
		this.q_sql("SELECT SURNAME FROM CONTACT WHERE ROWID=1", "scalar"); 
	} , 
	function(surname) 
	{ 
		this.TheSurname = surname;
		this.q_sendVars("TheSurname");
	}
);
You can access the value from your RPG code like so:

Code: Select all

SURNAME = LRNG_GetPropAsStr('/Form.Vars.TheSurname');
MegumiSawada
Posts: 268
Joined: Tue Feb 19, 2013 5:18 pm

Re: [RPG] retreive the value of textbox which is bind to SQL statement

Post by MegumiSawada »

Hi Tony,

Thank you!!
I have confirmed that I can get the value as expected with this way!

Best Regards,
Megumi Sawada
Post Reply