Home » Developer & Programmer » Forms » How do I query the table I want to fetch data from(control block)
How do I query the table I want to fetch data from(control block) [message #612527] Mon, 21 April 2014 02:21 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi All,


Usually, in a form with a database block, you use execute_query to fill the form items with data.
If I want to use a control block instead, how do I query the table I want to fetch data from?

If possible please provide me sample code.


Thanks in advanced.


[EDITED by LF: fixed topic title typo; was "ow" instead of "How"]

[Updated on: Mon, 21 April 2014 03:21] by Moderator

Report message to a moderator

Re: How do I query the table I want to fetch data from(control block) [message #612532 is a reply to message #612527] Mon, 21 April 2014 03:22 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You'll have to do it manually. Usual way is to create a cursor FOR loop which fetches data and populates block items. Don't forget to navigate to next record before running another LOOP round because you'll keep overwriting the first record's values.

As of sample code, search the board.
Re: How do I query the table I want to fetch data from(control block) [message #612535 is a reply to message #612532] Mon, 21 April 2014 03:47 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
Don't forget to navigate to next record before running another LOOP round because you'll keep overwriting the first record's values.


Hi Littlefoot,

Could you please explain(or) provide me a sample code please and in where to write(Trigger)

Thank You

[Updated on: Mon, 21 April 2014 03:49]

Report message to a moderator

Re: How do I query the table I want to fetch data from(control block) [message #613900 is a reply to message #612535] Tue, 13 May 2014 07:48 Go to previous messageGo to next message
pramod.sramesh
Messages: 23
Registered: November 2011
Location: Bangalore
Junior Member
DECLARE
	CURSOR c_emp IS
	SELECT empno FROM emp;
BEGIN	
	GO_BLOCK('YOUR_CONTROL_BLOCK');
	FIRST_RECORD;
	OPEN c_emp;
	LOOP
		FETCH c_emp INTO :CONTROL.your_item;
		EXIT WHEN c_emp%NOTFOUND;
		next_record;
	END LOOP;
	CLOSE c_emp;
END;

If you could give the action when you want to query i would suggest you the trigger where you have to write the code.

[Updated on: Tue, 13 May 2014 07:50]

Report message to a moderator

Re: How do I query the table I want to fetch data from(control block) [message #613967 is a reply to message #613900] Wed, 14 May 2014 01:36 Go to previous message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi
pramod.sramesh

Thanks for sent and i already Done this issue... Smile

Once again thanks
Previous Topic: Writing data on comm port
Next Topic: list of item
Goto Forum:
  


Current Time: Thu May 02 06:00:47 CDT 2024