Oracle Forms 6i – how to code ‘next’ button

75 pts.
Tags:
D2K 6i
Oracle 6i
Oracle Developer 2000
Oracle Forms
I want to know the coding for button which is named as 'next'...i want to fetch next records every time i press this button in my form... but my coding is not woking properly...i dont get any error...but i dont even get any output too...as the fields in output screen(form) remains empty...but yes in the screen at the bottom i can see records are being fetched like- 1/1 and then direct 14/14, and then 27/27 and so on,,,,but no output...plz help me out...this is the code i've used.. 

DECLARE

 CURSOR C1 IS 

SELECT a,b,c FROM emp; 

BEGIN 

for r_c1 in c1 loop 

:emp.a:= r_c1.a; 

:emp.b:=r_c1.b; 

:emp.c:= r_c1.c; 

 next_record; 

END LOOP; 

 END;


Software/Hardware used:
d2k

Answer Wiki

Thanks. We'll let you know when a new response is added.

You are fetching all records when the button is pressed (because you used a cursor), but your items are empty because you are calling the ‘next_record’ built-in procedure after fetching each record, and when you are at the last one this creates a new (blank) record. Try navigating backwards and you will see all previous recrods on the screen.

If you want to retrieve only one record, you should use a simple SELECT statement instead of a cursor. Something like this:

<pre>SELECT a,b,c
INTO :emp.a, :emp.b, :emp.c
FROM emp
WHERE <something>;</pre>

-CarlosDL

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Yaaa
    thanks for the quick reply.... but i cant use 'select' statement as it will just fetch single record regarding some provided information like a=' something'.... but i want to fetch next record everytime i press this button with respect to the last accessed recrd...and moreover the fields in the form are not database items.... is there any other way to fetch next records?plz reply soon...
      You are fetching all records when the button is pressed (because you used a cursor), but your items are empty because you are calling the 'next_record' built-in procedure after fetching each record, and when you are at the last one this creates a new (blank) record. Try navigating backwards and you will see all previous recrods on the screen. If you want to retrieve only one record, you should use a simple SELECT statement instead of a cursor. Something like this: SELECT a,b,c INTO :emp.a, :emp.b, :emp.c FROM emp WHERE <something>; -CarlosDL
      i want to know the coding for button which is named as'next'...i want to fetch next records every time i press this button in my form... but my coding is not woking properly...i dont get any error...but i dont even get any output too...as the fields in output screen(form) remains empty...but yes in the screen at the bottom i can see records are being fetched like- 1/1 and then direct 14/14, and then 27/27 and so on,,,,but no output...plz help me out...this is the code i've used.. DECLARE CURSOR C1 IS SELECT a,b,c FROM emp; BEGIN for r_c1 in c1 loop :emp.a:= r_c1.a; :emp.b:=r_c1.b; :emp.c:= r_c1.c; next_record; END LOOP; END; Software/Hardware used: d2k
    75 pointsBadges:
    report
  • carlosdl
    Yaaa, when you talk about a 'next record', an order is necessarily involved. Based on that order you can use an appropriate WHERE clause to get the next record. If you want to fetch ALL records as your original code does, you should do that in other procedure (not in a trigger of your NEXT button), and after doing it you should call the FIRST_RECORD built-in procuedure so the form starts at the first record. Then in your NEXT button trigger, you could use the NEXT_RECORD and PREVIOUS_RECORD built-in procedures to navigate between records. Just curious, why are you using a non-database block ?
    68,525 pointsBadges:
    report
  • Yaaa
    next_record and previous_record built in procedures are not working as i am using non-databse fields...fields remain empty when i use them.... if i make fields as database-items then my 'update button' coding doesnt work properly...it updates the secified record as well as creates a duplicate entry too... so poperties of all fields have been set to non-database.... now can u plz tellme some coding for 'next button'...
    75 pointsBadges:
    report
  • carlosdl
    "next_record and previous_record built in procedures are not working as i am using non-databse fields…" Did you try ??? Those procedures work whether the block and items are 'database' or not, but you have to populate your records first, as mentioned in my previous post. "If you want to fetch ALL records as your original code does, you should do that in other procedure (not in a trigger of your NEXT button), and after doing it you should call the FIRST_RECORD built-in procuedure so the form starts at the first record. Then in your NEXT button trigger, you could use the NEXT_RECORD..." If your update button doesn't work well when using database items, you should correct the code for that button. It is recommended to use database blocks/items unless it is really impossible. If you insist in using non-database items, you could do something like this: In the when-new-form-instance trigger, populate your block:
    DECLARE
    	CURSOR C1 IS
    		SELECT a,b,c FROM emp;
    BEGIN
    	FOR r_c1 in c1 loop
    		:emp.a:= r_c1.a;
    		:emp.b:=r_c1.b;
    		:emp.c:= r_c1.c;
    		 next_record;
    	END LOOP; 
    	FIRST_RECORD;
    END;
    And call the NEXT_RECORD procedure in the when-button-pressed trigger of your button
    68,525 pointsBadges:
    report
  • Yaaa
    thnx 4 replying....its working fine with this latest code u've provided me...
    75 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following