Fetching Data [message #474558] |
Tue, 07 September 2010 04:04 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Mozart
Messages: 7 Registered: March 2009 Location: Dubai
|
Junior Member |
|
|
Hello,
I have a detailed block with a user ID column. The user name is not available in the block. Therefore, I have created a non-database column to retrieve the user name into it.
Here is the code I've used.
PROCEDURE get_details IS
iLoop number := 1;
CURSOR c is
SELECT FULL_NAME
FROM GRP_EMPLOYEE
WHERE EMPLOYEE_NUMBER = :USER_ID;
BEGIN
OPEN c;
LOOP
message(iLoop);
FETCH c into :FULL_NAME;
message(:FULL_NAME);
iLoop := iLoop + 1;
EXIT WHEN iLoop = 6;
NEXT_RECORD;
END LOOP;
CLOSE c;
END;
However, it retrieves the first record only.
The results are displayed like this.
Loop: Result:
1 Full_Name
2 Empty
3 Empty
4 Empty
Any help will be much appreciated thanks.
[Updated on: Tue, 07 September 2010 04:06] Report message to a moderator
|
|
|
Re: Fetching Data [message #474559 is a reply to message #474558] |
Tue, 07 September 2010 04:11 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Scrap the procedure.
Put a select statement in the post-query trigger instead. This runs once for each record queried so no loops are needed.
|
|
|
|