Last record in a table

Michael McWilliams wrote:
> Any on know how I would grab the last record in a table? I need to
> create a next number program for auto creation of lot numbers.

Isn't there a "sequence" you can define and have the DB maintain, to auto-increment a counter for just such a purpose?

-Wayne
Any on know how I would grab the last record in a table? I need to
create a next number program for auto creation of lot numbers.
MAX([LotNumber]) +1









Gerard M Wadman

Sr. Network Systems Engineer



Scandius BioMedical Inc.

11A Beaver Brook Road

Littleton, MA 01460

________________________________

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Michael McWilliams
Sent: Monday, June 25, 2007 9:13 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Last record in a table



Any on know how I would grab the last record in a table? I need to
create a next number program for auto creation of lot numbers.





[Non-text portions of this message have been removed]
Are you doing this in BPM or Customization?



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Michael McWilliams
Sent: 25 June 2007 14:13
To: vantage@yahoogroups.com
Subject: [Vantage] Last record in a table



Any on know how I would grab the last record in a table? I need to
create a next number program for auto creation of lot numbers.





[Non-text portions of this message have been removed]
Customization.


--- In vantage@yahoogroups.com, "Stephen Edginton" <stephene@...>
wrote:
>
> Are you doing this in BPM or Customization?
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
Behalf
> Of Michael McWilliams
> Sent: 25 June 2007 14:13
> To: vantage@yahoogroups.com
> Subject: [Vantage] Last record in a table
>
>
>
> Any on know how I would grab the last record in a table? I need to
> create a next number program for auto creation of lot numbers.
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
How far have you go so far, you would use an adapter to create an auto
search with a where clause.

You can then do a count on the rows or iterate them to determine the
last lot number.



Regards,

Stephen



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Michael McWilliams
Sent: 25 June 2007 14:50
To: vantage@yahoogroups.com
Subject: [Vantage] Re: Last record in a table



Customization.

--- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ,
"Stephen Edginton" <stephene@...>
wrote:
>
> Are you doing this in BPM or Customization?
>
>
>
> From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
> Of Michael McWilliams
> Sent: 25 June 2007 14:13
> To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> Subject: [Vantage] Last record in a table
>
>
>
> Any on know how I would grab the last record in a table? I need to
> create a next number program for auto creation of lot numbers.
>
>
>
>
>
> [Non-text portions of this message have been removed]
>





[Non-text portions of this message have been removed]
I am not exactly sure how to accomplish that. I was thinking, would
it be easier by creating an ODBC connection? If i use SELECT With
No WHERE will that always return the last item entered in the table.
For instance:

Dim conn As OdbcConnection
Dim comm As OdbcCommand
Dim dr As OdbcDataReader
Dim connectionString As String
Dim sql As String
connectionString = "DSN=mfgsys803;UID=******;Pwd=******;"
sql = "SELECT PartNum, LotNum FROM Pub.PartLot"

conn = New OdbcConnection(connectionString)
conn.Open()
comm = New OdbcCommand(sql, conn)
dr = comm.ExecuteReader()
while (dr.Read())

Dim strLotNum As String = dr.GetValue(1)

conn.Close()
dr.Close()
comm.Dispose()
conn.Dispose()


--- In vantage@yahoogroups.com, "Stephen Edginton" <stephene@...>
wrote:
>
> How far have you go so far, you would use an adapter to create an
auto
> search with a where clause.
>
> You can then do a count on the rows or iterate them to determine
the
> last lot number.
>
>
>
> Regards,
>
> Stephen
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
Behalf
> Of Michael McWilliams
> Sent: 25 June 2007 14:50
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: Last record in a table
>
>
>
> Customization.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ,
> "Stephen Edginton" <stephene@>
> wrote:
> >
> > Are you doing this in BPM or Customization?
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%
40yahoogroups.com> ] On
> Behalf
> > Of Michael McWilliams
> > Sent: 25 June 2007 14:13
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] Last record in a table
> >
> >
> >
> > Any on know how I would grab the last record in a table? I need
to
> > create a next number program for auto creation of lot numbers.
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
> I am not exactly sure how to accomplish that. I was thinking, would
> it be easier by creating an ODBC connection? If i use SELECT With
> No WHERE will that always return the last item entered in the table.
> For instance:

I don't think that you're guaranteed that the last record in the table is
going to hold the highest serial number. I would do the select and sort in
descending sequence, grab the first record, and then (serial number + 1)

Mark W.
I am just having trouble using the First(LotNum)
Here is what I have and I am getting an error. I do not know how I
should have the syntax when I am required to use PartNum and LotNum.

sql = "SELECT PartNum, LotNum(First) FROM Pub.PartLot ORDER BY LotNum
DESC "

--- In vantage@yahoogroups.com, "Mark Wonsil" <mark_wonsil@...> wrote:
>
> > I am not exactly sure how to accomplish that. I was thinking, would
> > it be easier by creating an ODBC connection? If i use SELECT With
> > No WHERE will that always return the last item entered in the
table.
> > For instance:
>
> I don't think that you're guaranteed that the last record in the
table is
> going to hold the highest serial number. I would do the select and
sort in
> descending sequence, grab the first record, and then (serial number
+ 1)
>
> Mark W.
>