...Next_record. to get the next value [message #133820] |
Mon, 22 August 2005 06:07 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
orcl_dba
Messages: 84 Registered: March 2005
|
Member |
|
|
Hi to all a very basic level question but i m trying hard to solve the problem.
I hve a data block.
and a layout editor for that datablock
I have created 3 buttons, Namely . Enter, next record, and previous record.
What i want is that whever i enter primar key value nd press Enter
The querry run and display the value for the corresponding records.
It is working fine .. ( remember thati have set the property of database item = NO ) for all fields
Now i want is that whenever user press next Record or previous record
the fields will show the next or previous record in the database.
How to do that .. i m trying for Next_record();
but what it does is that it makes current fields Clear instead of showing any value...
Hope u ppl got it .. plz reply me soon this would be great helpf for all of us JUnior Developer/New Developer...
Thanx alot for taking you precious time out for this simple Querry....
|
|
|
|
Re: ...Next_record. to get the next value.. Strange. things [message #133839 is a reply to message #133820] |
Mon, 22 August 2005 06:51 ![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) |
orcl_dba
Messages: 84 Registered: March 2005
|
Member |
|
|
yeah you are rite.. but suppose when u create a datablock, then layout editor.. n database iTem=yes for the fields..
Now ehn you run the Form, it gives you a default interface,
where if you execute a querry it shows you the first record in the base table of the data blcok.
the it had an arrow li " >>"
which when pressed it shows the next record in the database..
i want to do the sam thing manually .. like iw ant ot give a button which when user press can search for next value..
i do not want to use the default Forms Next record Arrow..
Hope you got my point of view..
How to do that ..
Kindly tell me '
Urgent..
BR
|
|
|
|
Re: ...Next_record. to get the next value [message #133844 is a reply to message #133820] |
Mon, 22 August 2005 07:07 ![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) |
orcl_dba
Messages: 84 Registered: March 2005
|
Member |
|
|
yeah this seems close but this is what i does not want..
I want that fields shoould be created to display 1 record at one time..
I think i m not ablt to make u understand the questin for whcih i m extremely sorry..
WEll let me try again..
Suppose i have a table ABS having columns, site id, Region , City, Hieght
Now i make a datablock with base table as ABS
I create a layout editor. put text boxes representing each of site id, region , city and height.
Now i created 3 buttons Enter, Next, previous..
I wrote a trigger behind the When button pressed trigger of Enter button
here is the part of Code..
Declare
stid varchar2(10);
regions varchar2(20);
bh number(3);
Begin
select Bh into bh from ali.trans where st_id = :txtstid;
select region into regions from ali.trans where st_id= :txtstid;
:txtbh := bh;
:txtreg := regions;
End;
Now when i press the buttong it shows me the vlaue of city , region etc for site it which user gives in the text id of site id..
i want ot give user a facility that he can move to next record of the table from the record he querried or to the previous record of the table from the record he qurried or is currentl displayed...
so ... what shoudl i do.. hope u r getting me now..
See if you rememeber this facility is built in In Forms..
IF you make all the fields as database items..
then when u run the forms.. 1 record per field..
still there is an arrow in the default toolbar.
which have a next record button ,, that displayed the next record..
thasts whati want ..
Please gimme ur kind suggestion...
It wil be great learning.. for me..
BR
|
|
|
Re: ...Next_record. to get the next value [message #133888 is a reply to message #133844] |
Mon, 22 August 2005 11:01 ![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) |
![](/forum/images/custom_avatars/67693.png) |
saadatahmad
Messages: 452 Registered: March 2005 Location: Germany/Paderborn
|
Senior Member |
![saadatahmad](/forum/theme/orafaq/images/yahoo.png)
|
|
hi,
First of all, why do you want to reinvent the wheel?
You have the built-in functionality in forms then why do you want to do it yourself?
Secondly, I'm getting what you want but the problem is that you still didn't provide enough information to suggest a solution to you.
Do you just want to query the table from this form?
Do you want to insert the data from this form as well? etc...
Can you tell me onething?
Consider the normal behaviour of the form.
You have a single record form for the emp table. When you'll run that form and query the form by providing the condition empno = 7369, how much records will you get?
Only one record and then you cannot use previous or next record.
If, however, you give the condition deptno = 10 then it will return you more than one record and then you can use previous and next record from the form toolbar and move around the records.
Now I provided you one URL and asked you to check that and modify it according to your needs.
You didn't do your work.
So I created the same form going throgh the instructions given there and after that I modified it according to your needs.
I'm attaching that form. I created this form for the emp table. You can change it with your own table.
Here, in this form, when the form opens, give any department number and then press ENTER button, it will query all the records for that department number. And you can scroll through the records from previous and next buttons.
This is a single record block. I think this is exactly what you want. Don't tell me now that you also want to Inser, Update, Delete the data from your database from this form.
Regards.
Saadat Ahmad
-
Attachment: ENTER.fmb
(Size: 52.00KB, Downloaded 1548 times)
|
|
|
Re: ...Next_record. to get the next value [message #134032 is a reply to message #133820] |
Tue, 23 August 2005 06:45 ![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) |
orcl_dba
Messages: 84 Registered: March 2005
|
Member |
|
|
Hi..
Thanx alot alot alot for you kind help..
You have correctly understood the problem.. but your question that Why i want this..
hmm
The reason is that i want to create the application manually..
and want to give my own toolbar instead of windows toolbar..
SO i want to know the exact functionality behind the arrow buttons..
i dont think it is a bad things..
Secondly the solutin you provideis not exaclty what i m looking for.. may b my lack of knowledge with form is what makes me asking this stupid question from you again and again...
Sorry for that ..
Yuor solution is based on Foerign key having multiple primary key records..
I want is that oracle / myu application should go exactly to the row/record id ..
Even if user has querried a record on the basis of a given Id
when he press Next, the next record displayed would be the one which is next row in the actual table.( remeber that my table is sorted /order by/ Primary key already . ) ..
I was thinking that i should bring the whole table in cursor and then display each row with next record.
but then this means tht every time i do this , it will start from first record other wise it will not show me anything.
So i was wondering if user querry a particular row, . and i can hold/store the row/record id ,,
then if he wants to c the next record from that record he querried, he can do that ..
This situatin do occur if suppose user querry st number 20
then he thinks that ok, let me go to the record till 25 and see if /who exists there ..
simple way is to use next record.. .
It shouldnt happen that if he pressed next record, agina he has to press button 2 times again .. as he is already at the 20th record..
thats what all i wanted..
Thanx for your help and taking time for this stupit querry from yor precious time..
This help i think is the basic cause of establishment of this Forum
BR to all
|
|
|
Re: ...Next_record. to get the next value [message #134047 is a reply to message #134032] |
Tue, 23 August 2005 07:27 ![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) |
![](/forum/images/custom_avatars/67693.png) |
saadatahmad
Messages: 452 Registered: March 2005 Location: Germany/Paderborn
|
Senior Member |
![saadatahmad](/forum/theme/orafaq/images/yahoo.png)
|
|
ok
Look at this,
SQL> SELECT empno, ename, deptno, rowid
2 FROM emp;
EMPNO ENAME DEPTNO ROWID
---------- ---------- ---------- ------------------
7369 SMITH 20 AAAHIFAABAAAUMSAAA
7499 ALLEN 30 AAAHIFAABAAAUMSAAB
7521 WARD 30 AAAHIFAABAAAUMSAAC
7566 JONES 20 AAAHIFAABAAAUMSAAD
7654 MARTIN 30 AAAHIFAABAAAUMSAAE
7698 BLAKE 30 AAAHIFAABAAAUMSAAF
7782 CLARK 10 AAAHIFAABAAAUMSAAG
7788 SCOTT 20 AAAHIFAABAAAUMSAAH
7839 KING 10 AAAHIFAABAAAUMSAAI
7844 TURNER 30 AAAHIFAABAAAUMSAAJ
7876 ADAMS 20 AAAHIFAABAAAUMSAAK
7900 JAMES 30 AAAHIFAABAAAUMSAAL
7902 FORD 20 AAAHIFAABAAAUMSAAM
7934 MILLER 10 AAAHIFAABAAAUMSAAN
14 rows selected.
SQL> SELECT empno, ename, deptno, rowid
2 FROM emp
3 WHERE rowid >=
4 (SELECT rowid
5 FROM emp
6 WHERE empno = 7900);
EMPNO ENAME DEPTNO ROWID
---------- ---------- ---------- ------------------
7900 JAMES 30 AAAHIFAABAAAUMSAAL
7902 FORD 20 AAAHIFAABAAAUMSAAM
7934 MILLER 10 AAAHIFAABAAAUMSAAN
The idea is to search the records by rowid.
Remove the previous code from the Enter button. Copy and paste this code exactly on you When-Button-Pressed trigger for the Enter button in the same form. Run the form and give there any empno and Push the Enter button.
It will Select that record and the records which are coming after that empno.
--:GLOBAL.g_text := '%'||:control.v_text||'%';
:GLOBAL.g_empno := :CONTROL.empno;
DECLARE
cursor c1 IS
SELECT empno, ename, deptno
FROM emp
WHERE rowid >=
(SELECT rowid
FROM emp
WHERE empno = :GLOBAL.g_empno);
BEGIN
OPEN c1;
FIRST_RECORD;
LOOP
FETCH c1 INTO :CONTROL.empno, :CONTROL.ename, :CONTROL.deptno;
EXIT WHEN c1%NOTFOUND;
NEXT_RECORD;
END LOOP;
CLOSE c1;
END;
FIRST_RECORD;
Erase('GLOBAL.g_empno');
Now the form is populated by the primary key values. You can move to previous and next records by the buttons.
I hope that this will solve your problem.
Regards.
|
|
|
Re: ...Next_record. to get the next value [message #134378 is a reply to message #133820] |
Wed, 24 August 2005 11:04 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
orcl_dba
Messages: 84 Registered: March 2005
|
Member |
|
|
Declare
stid varchar2(10);
stcity varchar2(30);
stlongg number(12,9);
Cursor c1 IS
select st_city,st_long from site where rowid >=(select rowid from site where
st_id = :txtstid);
begin
OPEN c1;
FIRST_RECORD;
LOOP
FETCH c1 INTO stcity,stlongg;
EXIT WHEN c1%NOTFOUND;
NEXT_RECORD;
END LOOP;
CLOSE c1;
end;
This is the code i wrote behind the Next REcord Button .
When i press Enter , the code execute and returns the values realted to a particualr Site Id
after that when i press the Next Record Button ...
it gives me Error..
FRM 4010 etc.. Records must be entered or deleted first.
I hope yuou ppl dont mind my simple question as this is a learning curve for me. but i m amazed as to why this is not working .. '
can u test this code or any code with this logic on your Forms.
Hope that would be a great booost
ALso kindly hightlihght how to ge to the previous record.. as
you can bring record in cursor and move forward, how to move back..
sequentially back..
is it .. Previous_record..
Thnx for the help
|
|
|