Unix Technical Forum

MAX NUMBER

This is a discussion on MAX NUMBER within the Oracle Miscellaneous forums, part of the Oracle Database category; --> hi ppl... i am entering dat in an access front end connect to an oracle database. i am using ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:12 AM
Reiro
 
Posts: n/a
Default MAX NUMBER

hi ppl...

i am entering dat in an access front end connect to an oracle database.
i am using max (number) + 1 increasing my id...

problem is ... if during testing i enter a number like 9999999 in the
database.
Even whn record is deleted i get the next value as 9999999 + 1.
how do retrieve the maximum value that is in the table.

thx in advance...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:12 AM
sybrandb
 
Posts: n/a
Default Re: MAX NUMBER


Reiro wrote:
> hi ppl...
>
> i am entering dat in an access front end connect to an oracle database.
> i am using max (number) + 1 increasing my id...
>
> problem is ... if during testing i enter a number like 9999999 in the
> database.
> Even whn record is deleted i get the next value as 9999999 + 1.
> how do retrieve the maximum value that is in the table.
>
> thx in advance...


By not allowing anyone to enter a number in this column.
Assuming the sql statement is correct, as you entered the maximum value
of 9999999 in this column, you will retrieve this number as the maximum
value.
Nothing can be done about that: what you see is what you get.

--
Sybrand Bakker
Senior Oracle DBA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 10:12 AM
Reiro
 
Posts: n/a
Default Re: MAX NUMBER


so even tho the record 9999999 has been deleted and the max number i
can see in the database in 200000. i wont be able to retrieve that
value.... which in fact is the maximum number existing in the database.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 10:12 AM
sybrandb
 
Posts: n/a
Default Re: MAX NUMBER


Reiro wrote:
> so even tho the record 9999999 has been deleted and the max number i
> can see in the database in 200000. i wont be able to retrieve that
> value.... which in fact is the maximum number existing in the database.



You never posted the exact sql statement, did you?
But if the record was really deleted, *and* you *committed* the
transaction,
either your statement is wrong, or your understanding of Oracle, or
there is a serious bug in the yet still unknown version of your
database.

--
Sybrand Bakker
Senior Oracle DBA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2008, 10:12 AM
Reiro
 
Posts: n/a
Default Re: MAX NUMBER

im using oracle 9i and my query for increase the id is
nz(max(asset_id),0) + 1 its incorpated into my insert statement.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-08-2008, 10:12 AM
Brian Peasland
 
Posts: n/a
Default Re: MAX NUMBER

Reiro wrote:
> hi ppl...
>
> i am entering dat in an access front end connect to an oracle database.
> i am using max (number) + 1 increasing my id...
>
> problem is ... if during testing i enter a number like 9999999 in the
> database.
> Even whn record is deleted i get the next value as 9999999 + 1.
> how do retrieve the maximum value that is in the table.
>
> thx in advance...
>


To retrieve the max number in a column of a table, use a query similar
to the following:

SELECT MAX(column_name) FROM table_name;

However, adding one to this max number smells suspiciously like one
should be using an Oracle Sequence as it will autoincrement an interval
based on the last value used. Please read the Oracle docs
(http://tahiti.oracle.com) for more information.

HTH,
Brian

--
================================================== =================

Brian Peasland
dba@nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-08-2008, 10:12 AM
Brian Peasland
 
Posts: n/a
Default Re: MAX NUMBER

Reiro wrote:
> im using oracle 9i and my query for increase the id is
> nz(max(asset_id),0) + 1 its incorpated into my insert statement.
>


What is the NZ function? Any reason why you can't code a trigger to do
this for you on INSERT? Any reason why you can't use a sequence to
determine the number?

Cheers,
Brian

--
================================================== =================

Brian Peasland
dba@nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-08-2008, 10:12 AM
DA Morgan
 
Posts: n/a
Default Re: MAX NUMBER

Reiro wrote:
> hi ppl...
>
> i am entering dat in an access front end connect to an oracle database.
> i am using max (number) + 1 increasing my id...
>
> problem is ... if during testing i enter a number like 9999999 in the
> database.
> Even whn record is deleted i get the next value as 9999999 + 1.
> how do retrieve the maximum value that is in the table.
>
> thx in advance...


If this is connecting to Oracle you should create a sequence and not be
doing manual numbering which will not scale.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-08-2008, 10:13 AM
Reiro
 
Posts: n/a
Default Re: MAX NUMBER


i having trouble with the sequence.... in my access query i have the
foll:


insert into asset(asset_id,parent_asset_id,content_title,asset _level)
values (asset_seq,parfld1,parfld2,parfld3)

if i try my parameter fields it works fine.... please let me know how
i can call the sequence in access through the query above..

thx alot
SORRY (im a beginner of all beginners)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-08-2008, 10:13 AM
Sybrand Bakker
 
Posts: n/a
Default Re: MAX NUMBER

On 24 Aug 2006 01:32:46 -0700, "Reiro" <ReiroGP@gmail.com> wrote:

>
>i having trouble with the sequence.... in my access query i have the
>foll:
>
>
>insert into asset(asset_id,parent_asset_id,content_title,asset _level)
>values (asset_seq,parfld1,parfld2,parfld3)
>
>if i try my parameter fields it works fine.... please let me know how
>i can call the sequence in access through the query above..
>
>thx alot
>SORRY (im a beginner of all beginners)



You can do that probably by using a passthrough query.
A workaround I used on interactive forms was to create a PL/SQL
function to run <sequence>.nextval, call that in a pass through query,
and assign the retrieved value to the ID column on my form.

--
Sybrand Bakker, Senior Oracle DBA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:52 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com