Home » SQL & PL/SQL » SQL & PL/SQL » shifting records
icon1.gif  shifting records [message #287621] Wed, 12 December 2007 23:37 Go to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Hi I have records as follows

I have thosand record in a table like this out of 10000


No Loc Name Sal Gender
-------------------------------------------------------
1 101 A 2000 M
1 100 B 2500 F
2 201 C 1200 F
2 200 D 2100 M
...............
...............





Now I need to update these records as


No Loc Name Sal Gender
-------------------------------------------------------
1 101 A 2000 F
1 100 B 2500 M
2 201 C 1200 M
2 200 D 2100 F
..........
..............
.............


It's look like a homework. But I am facing prob with this issue.
So please give me idea for this issue.

Thank you.

Smile
Re: shifting records [message #287622 is a reply to message #287621] Wed, 12 December 2007 23:40 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
use DECODE
Re: shifting records [message #287623 is a reply to message #287621] Wed, 12 December 2007 23:49 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

I did not want to do homework, but tried.

SQL> select * from m_or_f;

G         NO
- ----------
F          1
M          2
F          3
M          4

SQL> update m_or_f set gender=decode(gender,'M','F','M');

4 rows updated.

SQL>  select * from m_or_f;

G         NO
- ----------
M          1
F          2
M          3
F          4
Re: shifting records [message #287629 is a reply to message #287623] Thu, 13 December 2007 00:21 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Thank you....

I have another issue.

What my requirement is I have input like
Item   loc   orders   qtyrcv
-----------------------------
1001   101     0        230
1001   100     230      null
2001   201     0        908
2001   200     900       null
...........
...............


Item   loc   orders   qtyrcv
-----------------------------
1001   101     0        0
1001   100     230      230
2001   201     0        0
2001   200     900      908
........
...........


This is the issue.Please help me for this.

regards,
Re: shifting records [message #287630 is a reply to message #287621] Thu, 13 December 2007 00:25 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
user71408,
What are YOU contributing to this situation?

You're On Your Own (YOYO)!
Re: shifting records [message #287632 is a reply to message #287629] Thu, 13 December 2007 00:25 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What is the rationale?

Regards
Michel
Re: shifting records [message #287634 is a reply to message #287621] Thu, 13 December 2007 00:27 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions074.htm#i83834
Re: shifting records [message #287916 is a reply to message #287634] Fri, 14 December 2007 01:03 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

hi,
but in that link example it shows last record as empty. But I need to shift the records. and update the data.

Thank you.
Re: shifting records [message #287928 is a reply to message #287916] Fri, 14 December 2007 01:22 Go to previous message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
shift? from what to what, you still don't explain what is the algorithm.
How can you expect we give a solution to a problem you don't specify?

Regards
Michel

[Updated on: Fri, 14 December 2007 01:23]

Report message to a moderator

Previous Topic: about multiple values passing in single parameter
Next Topic: records
Goto Forum:
  


Current Time: Thu Dec 08 22:15:02 CST 2016

Total time taken to generate the page: 0.10335 seconds