to move the record up and down [message #311889] |
Mon, 07 April 2008 05:00  |
asadkhan_2
Messages: 36 Registered: January 2008
|
Member |
|
|
I want to move the whole record up and down in forms to change the sequence of records how can i achieve this i have product code,testcode,methodcode for unique key
thanks to all
|
|
|
|
Re: to move the record up and down [message #311902 is a reply to message #311893] |
Mon, 07 April 2008 06:01   |
asadkhan_2
Messages: 36 Registered: January 2008
|
Member |
|
|
i think that u have not understand the problem the problem is this that user want to change the order of records in which the records are saved
means when user click the down button on the first record then record goes to 20d number and the 2nd record comes on 1st position
thanks
|
|
|
|
Re: to move the record up and down [message #311909 is a reply to message #311902] |
Mon, 07 April 2008 06:23   |
 |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Quote: | user want to change the order of records in which the records are saved
|
This makes no sense (in an relational database, that is). Imagine your table as a basket full of apples (records). When it is full, do you know which apple was the first one that was put into the basket? No, you don't. Do you care? No, you shouldn't.
If you need to display records in some order, you MUST use the ORDER BY clause. Although in some Oracle database versions and certain cases pure SELECT statement returns records in an order that "looks like" the order you used to enter those records into a table, relying on it is very wrong. Forget that you've ever seen it.
However, if you really need to display records in an order you've inserted them into a table, create a column which will reflect that fact. Will it be a sequence number or timestamp (or something else), doesn't matter - but you'll have to do it that way (perhaps 11g (or even 10g?) offers another possibility, but I don't know about it).
So: moving records "up" and "down" is to be done the way Azam Khan suggested. ORDER BY is the key.
|
|
|
Re: to move the record up and down [message #311919 is a reply to message #311906] |
Mon, 07 April 2008 06:37   |
asadkhan_2
Messages: 36 Registered: January 2008
|
Member |
|
|
this is the structure of my table can u send me the code i m new to oracle forms
thanks a lot
METHOD_CODE VARCHAR2(200)
TEST_CODE VARCHAR2(50)
MIN_RANGE VARCHAR2(100) Y
MAX_RANGE VARCHAR2(100) Y
PROD_CODE VARCHAR2(50)
ACTIVE VARCHAR2(10) Y
ACTIVE_FOR VARCHAR2(10) Y
in this prod_code,test_code and method_code combine makes the primary key
thanks
|
|
|
|
|
Re: to move the record up and down [message #312007 is a reply to message #311932] |
Mon, 07 April 2008 14:05  |
solisdeveloper
Messages: 48 Registered: March 2008 Location: Mexico
|
Member |
|
|
The easiest way I can think of is by creating the sequence or using a time-stamp field to use for your "Order By" clause as it has been previously suggested by Mr. LittleFood and Mr.azamkhan.
If you want to control the order in wich the records are SAVED then as Mr. LittleFood said, you shouldn't care about it and just focus on an order by clause.
Now if what you realy need is that your application can change the order in wich records are displayed (before they are saved) when the end-user clicks on a Down or Up button, you would have to do a lot of coding to play with the visual aspect of the form, maybe this helps:
Create a procedure that navigates the block, let's say that the user clicks the Down-Button, you could navigate the block and then use the :SYSTEM.cursor_record property to check what number of record you are standing on and where do you want to place it now. then store both records in 2 Rowtye variables and then just switch the values.
But this is only to play with the visual order in wich they are displayed, once you save those records, you should not either worry ot care about the order, but then again it requires a lot of coding and validation.
Hope this helped!
[Updated on: Mon, 07 April 2008 14:09] Report message to a moderator
|
|
|