Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How can I get a consecutive unique !!

3 posts in FoxPro Last posting was on 2010-01-08 10:33:34.0Z
Hugo Glez. Macias Posted on 2010-01-07 22:18:50.0Z
From: "Hugo Glez. Macias" <gomh7172@hotmail.com>
Newsgroups: Advantage.FoxPro
Subject: How can I get a consecutive unique !!
Date: Thu, 7 Jan 2010 16:18:50 -0600
Lines: 26
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
NNTP-Posting-Host: 189.169.140.52
Message-ID: <4b465d64@solutions.advantagedatabase.com>
X-Trace: 7 Jan 2010 15:17:08 -0700, 189.169.140.52
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!189.169.140.52
Xref: solutions.advantagedatabase.com Advantage.FoxPro:337
Article PK: 1109691

Hi,

I need to get a consecutive number unique for Appointments, and I have the
next code, but when 4 or more users give appointments at the same time,
repeats the number to 2 users, some times happens but happens. this is my
code
the field is "prog_cita" and the table is "ctrl"

FUNCTION get_cons_appoint
lccomand = 'select prog_cita from CTRL'
prmRSTempR = CREATEOBJECT("ADODB.RecordSet")
lret = prmRSTempR.OPEN(lccomand,lcCnx)
IF NOT prmRSTempR.eof()
lnprog_cita = prmRSTempR.Fields(0).Value + 1

lcCommand = "update ctrl set prog_cita = " + ALLTRIM(STR(lnprog_cita))
IF prmRSTempR.state = 1
prmRSTempR.CLOSE()
ENDIF
prmRSTempR.OPEN(lcCommand, lcCnx)

ENDIF

RETURN lnprog_cita


Paul Posted on 2010-01-08 10:32:13.0Z
Date: Fri, 08 Jan 2010 10:32:13 +0000
From: Paul <paul.hill@hoist-technology.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b2pre Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: Advantage.FoxPro
Subject: Re: How can I get a consecutive unique !!
References: <4b465d64@solutions.advantagedatabase.com>
In-Reply-To: <4b465d64@solutions.advantagedatabase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.138.165.82
Message-ID: <4b47090d@solutions.advantagedatabase.com>
X-Trace: 8 Jan 2010 03:29:33 -0700, 81.138.165.82
Lines: 35
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!81.138.165.82
Xref: solutions.advantagedatabase.com Advantage.FoxPro:338
Article PK: 1109693


On 07/01/2010 22:18, Hugo Glez. Macias wrote:
> Hi,
>
> I need to get a consecutive number unique for Appointments, and I have
> the next code, but when 4 or more users give appointments at the same
> time, repeats the number to 2 users, some times happens but happens.
> this is my code
> the field is "prog_cita" and the table is "ctrl"
>
> FUNCTION get_cons_appoint
> lccomand = 'select prog_cita from CTRL'
> prmRSTempR = CREATEOBJECT("ADODB.RecordSet")
> lret = prmRSTempR.OPEN(lccomand,lcCnx)
> IF NOT prmRSTempR.eof()
> lnprog_cita = prmRSTempR.Fields(0).Value + 1
>
> lcCommand = "update ctrl set prog_cita = " + ALLTRIM(STR(lnprog_cita))
> IF prmRSTempR.state = 1
> prmRSTempR.CLOSE()
> ENDIF
> prmRSTempR.OPEN(lcCommand, lcCnx)
>
> ENDIF
>
> RETURN lnprog_cita

Hi Hugo,

Run the update first and then read the new value. e.g.

update ctrl set prog_cita = prog_cita + 1
select prog_cita from ctrl

--
Paul


Paul Posted on 2010-01-08 10:33:34.0Z
Date: Fri, 08 Jan 2010 10:33:34 +0000
From: Paul <paul.hill@hoist-technology.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b2pre Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: Advantage.FoxPro
Subject: Re: How can I get a consecutive unique !!
References: <4b465d64@solutions.advantagedatabase.com> <4b47090d@solutions.advantagedatabase.com>
In-Reply-To: <4b47090d@solutions.advantagedatabase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.138.165.82
Message-ID: <4b47095d@solutions.advantagedatabase.com>
X-Trace: 8 Jan 2010 03:30:53 -0700, 81.138.165.82
Lines: 12
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!81.138.165.82
Xref: solutions.advantagedatabase.com Advantage.FoxPro:339
Article PK: 1109692


On 08/01/2010 10:32, Paul wrote:
> Hi Hugo,
>
> Run the update first and then read the new value. e.g.
>
> update ctrl set prog_cita = prog_cita + 1
> select prog_cita from ctrl

Sorry, I forgot to say you need a transaction around these!

--
Paul