RE: Best way to do this query

2002-02-27 Thread Jeffrey Polaski

I'd suggest using a stored procedure with a transaction and do it in 
the
database. CF is rather aggressive in how it locks the db, and this can 
lead
to performance problems if the db gets a lot of use. SP's give you a
performance boost, and aren't that hard to do, especially once you have 
the
SQL written.

And rather than do your increment in a function call, you could do it 
in
SQL:select buildcount + 1 from bbstat where id = #id# and buildtime=
#buildtime#


   Jeff Polaski
   Manager, Web Services
   Research & Graduate Studies
   University California, Irvine 


-Original Message-
From: Phillip Broussard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 12:03 PM
To: CF-Talk
Subject: Best way to do this query


Sorry to ask but I have a dead brain right now. (I hate it when I feel
dumb.)

X¿x
~~~
  
I need to check the database to see if a record is there. 
If it's there then increment it by one, otherwise add the record. 
If two people hit it at the right time I may get two records. What 
should I
do to prevent this? 
This is what the code would look like.


select * from bbstat where id = #id# and buildtime = #buildtime#





update bbstat
set buildcount=#IncrementValue(buildcount)#
where id=#id#



insert into bbstat 
(id,buildcount) 
values (#id#,1)


 

Phillip Broussard
Tracker Marine Group
417-873-5957



__
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Best way to do this query

2002-02-19 Thread Phillip Broussard

DOH!

I need to get some fresh air because that was too obvious. 

Thanks all. 

Phillip

> -Original Message-
> From: C. Hatton Humphrey [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 19, 2002 2:13 PM
> To: CF-Talk
> Subject: RE: Best way to do this query
> 
> Use CFLock.  It will put the two people in a single file line when
> executing
> the code, removing the possibility of a double-hit.
> 
> Hatton
> 
> 
> > -Original Message-
> > From: Phillip Broussard [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, February 19, 2002 3:03 PM
> > To: CF-Talk
> > Subject: Best way to do this query
> >
> >
> > Sorry to ask but I have a dead brain right now. (I hate it when I
feel
> > dumb.)
> >
> > X¿x
> > ~~~
> >
> > I need to check the database to see if a record is there.
> > If it's there then increment it by one, otherwise add the record.
> > If two people hit it at the right time I may get two records. What
> > should I
> > do to prevent this?
> > This is what the code would look like.
> >
> > 
> > select * from bbstat where id = #id# and buildtime = 
#buildtime#
> > 
> >
> > 
> >
> > 
> > 
> > update bbstat
> > set buildcount=#IncrementValue(buildcount)#
> > where id=#id#
> > 
> > 
> > 
> > insert into bbstat
> > (id,buildcount)
> > values (#id#,1)
> > 
> >
> > 
> >
> > Phillip Broussard
> > Tracker Marine Group
> > 417-873-5957
> >
> >
> >
> 
__
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Best way to do this query

2002-02-19 Thread NathanielHorwitz

I've faced this before and I usually use cflock to prevent 2 users from 
inserting the record at the same time.

> Sorry to ask but I have a dead brain right now. (I hate it when I feel
> dumb.)
> 
> X¿x
> ~~~
>   
> I need to check the database to see if a record is there. 
> If it's there then increment it by one, otherwise add the record. 
> If two people hit it at the right time I may get two records. What 
> should I
> do to prevent this? 
> This is what the code would look like.
> 
> 
> select * from bbstat where id = #id# and buildtime = #buildtime#
> 
> 
> 
> 
> 
> 
> update bbstat
> set buildcount=#IncrementValue(buildcount)#
> where id=#id#
> 
> 
> 
> insert into bbstat 
> (id,buildcount) 
> values (#id#,1)
> 
> 
>  
> 
> Phillip Broussard
> Tracker Marine Group
> 417-873-5957


Nathaniel Horwitz
Developer
http://www.nathanielhorwitz.com

__
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Best way to do this query

2002-02-19 Thread C. Hatton Humphrey

Use CFLock.  It will put the two people in a single file line when executing
the code, removing the possibility of a double-hit.

Hatton


> -Original Message-
> From: Phillip Broussard [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 19, 2002 3:03 PM
> To: CF-Talk
> Subject: Best way to do this query
>
>
> Sorry to ask but I have a dead brain right now. (I hate it when I feel
> dumb.)
>
> X¿x
> ~~~
>
> I need to check the database to see if a record is there.
> If it's there then increment it by one, otherwise add the record.
> If two people hit it at the right time I may get two records. What
> should I
> do to prevent this?
> This is what the code would look like.
>
> 
>   select * from bbstat where id = #id# and buildtime = #buildtime#
> 
>
> 
>
>   
>   
>   update bbstat
>   set buildcount=#IncrementValue(buildcount)#
>   where id=#id#
>   
> 
>   
>   insert into bbstat
>   (id,buildcount)
>   values (#id#,1)
>   
>
> 
>
> Phillip Broussard
> Tracker Marine Group
> 417-873-5957
>
>
> 
__
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Best way to do this query

2002-02-19 Thread Shawn Kernes

just wrap it up in a cflock  studio will give you the specifics

-Original Message-
From: Phillip Broussard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 12:03 PM
To: CF-Talk
Subject: Best way to do this query


Sorry to ask but I have a dead brain right now. (I hate it when I feel
dumb.)

X¿x
~~~

I need to check the database to see if a record is there.
If it's there then increment it by one, otherwise add the record.
If two people hit it at the right time I may get two records. What
should I
do to prevent this?
This is what the code would look like.


select * from bbstat where id = #id# and buildtime = #buildtime#






update bbstat
set buildcount=#IncrementValue(buildcount)#
where id=#id#



insert into bbstat
(id,buildcount)
values (#id#,1)




Phillip Broussard
Tracker Marine Group
417-873-5957



__
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Best way to do this query

2002-02-19 Thread Andrew Scott

Would a cftransaction be sufficient here, if you have the ability to
maybe a stored procedure would be better. If not swap a cflock around
the block of code should to the trick as well.


-Original Message-
From: Phillip Broussard [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, 20 February 2002 7:03 AM
To: CF-Talk
Subject: Best way to do this query

Sorry to ask but I have a dead brain right now. (I hate it when I feel
dumb.)

X¿x
~~~
  
I need to check the database to see if a record is there. 
If it's there then increment it by one, otherwise add the record. 
If two people hit it at the right time I may get two records. What 
should I
do to prevent this? 
This is what the code would look like.


__
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists