getting rownumber [message #267839] |
Sat, 15 September 2007 11:40 |
ashish2345
Messages: 50 Registered: September 2007
|
Member |
|
|
Hi friends actually i want to auto insert in following table the product id
pid pname
3 Lux
4 Dettol
5 Nirma
6 Milk
7 Sugar
now for it it had to know what is the value of pid from last row.. how to get it...
regards
ashish
|
|
|
Re: getting rownumber [message #267843 is a reply to message #267839] |
Sat, 15 September 2007 11:50 |
|
vamsi kasina
Messages: 2112 Registered: October 2003 Location: Cincinnati, OH
|
Senior Member |
|
|
There is no first / last row concept in Oracle.
You need to have a date column, which will be holding te creation date (or) some other criteria to sort them out.
If the pid is in ascending order, while you insert, you can order by desc and rownum = 1.
Edit: If you want only pid, then you can use max(pid).
By
Vamsi
[Updated on: Sat, 15 September 2007 11:57] Report message to a moderator
|
|
|
Re: getting rownumber [message #267845 is a reply to message #267839] |
Sat, 15 September 2007 11:53 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
In order to keep your application scalable, you should use a sequence.
If you use a sequence, you will end up with gaps, but there is hardly any real business case that does not allow for gaps. The most important reason for people to search for gap-free IDs is very often leaving at 5..
|
|
|