Home » Developer & Programmer » Forms » to move the record up and down (forms 10g)
to move the record up and down [message #311889] Mon, 07 April 2008 05:00 Go to next message
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 #311893 is a reply to message #311889] Mon, 07 April 2008 05:14 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
I would suggest that you should place / add a column "Sequence No." and put an order by clause on SEQUENCE_NO

On forms try to interst the sequence number in the field/item perform save and then re-query the block and you will get you record in an organized way.

Regards,
Azam Khan
Re: to move the record up and down [message #311902 is a reply to message #311893] Mon, 07 April 2008 06:01 Go to previous messageGo to next message
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 #311906 is a reply to message #311902] Mon, 07 April 2008 06:18 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Dear Friend,

I clearly understood what you are trying to say but if you do this it will involve lot effort and programming.

E.g. If the user try to move 1st record to 2nd then you will not just copy and paste the records you have to do some coding.

To move 2nd record to 1st position is not hard you just clear the 1st record and the 2nd record will be the first record but know how you will going to move this 1st record into second position.

Hmmm... Well there is nothing impossible in programming. I would suggest that you should read ARRAYs and populating block with procedures.

With the help of array you can rearrange them according to user's requirment and then again populate them in the block with the help of procedure.

Regards,
Azam Khan
Re: to move the record up and down [message #311909 is a reply to message #311902] Mon, 07 April 2008 06:23 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 #311923 is a reply to message #311919] Mon, 07 April 2008 06:42 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
My dear Friend,

As I said that it will require alot of effort and by the way it doesn't feel logical also.

As my dear friend Mr. Littlefoot try to explain it to you by giving a very good and logical example I would also suggest that you should do the same as I suggested before.

By the way Littlefoot I like the apple example you gave.

Regards,
Azam Khan
Re: to move the record up and down [message #311932 is a reply to message #311923] Mon, 07 April 2008 07:40 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
how can i achieve this i have product code,testcode,methodcode for unique key

Please, don't even think about changing primary key values! Are you aware of the consequences? What will you do with all of the foreign key values? Will you disable referential integrity, change primary key values and then try to re-establish referential integrity? If so, good luck. You'll need it.
Re: to move the record up and down [message #312007 is a reply to message #311932] Mon, 07 April 2008 14:05 Go to previous message
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

Previous Topic: how to make balleting application in forms 6i
Next Topic: OC4J error, help please
Goto Forum:
  


Current Time: Tue Mar 11 12:10:38 CDT 2025