Whether a userid is already in databse

Discussion in 'Perl Misc' started by Regent, Jan 2, 2004.

  1. Regent

    Regent Guest

    Hi friends,

    I'm doing some cgi programming these days, using MS Access database to store uid/pwd info from registration forms in HTML pages. I considered

    SELECT from Users WHERE userid = '$uid'

    to see whether the received uid (from webpage forms) is already in the database, but I guess there may be more convenient ways to do this?

    Thanks for ur advice!

    Regent
     
    Regent, Jan 2, 2004
    #1
    1. Advertising

  2. Regent

    Tintin Guest

    "Regent" <> wrote in message
    news:bt2nnc$1ed8$99.com...
    > Hi friends,
    >
    > I'm doing some cgi programming these days, using MS Access database to

    store uid/pwd info from registration forms in HTML pages. I considered
    >
    > SELECT from Users WHERE userid = '$uid'
    >
    > to see whether the received uid (from webpage forms) is already in the

    database, but I guess there may be more convenient ways to do this?

    What would Perl programmers know or care about SQL.
     
    Tintin, Jan 2, 2004
    #2
    1. Advertising

  3. Regent

    Nick Santos Guest

    "Regent" <> wrote in message
    news:bt2nnc$1ed8$99.com...
    > Hi friends,
    >
    > I'm doing some cgi programming these days, using MS Access database to

    store uid/pwd info from registration forms in HTML pages. I considered
    >
    > SELECT from Users WHERE userid = '$uid'
    >
    > to see whether the received uid (from webpage forms) is already in the

    database, but I guess there may be more convenient ways to do this?
    >
    > Thanks for ur advice!
    >
    > Regent
    >
    >

    I use MySql, and that's the way I do it, simply checking to see if anything
    is returned. I think it's fairly effective, because it doesn't require much
    coding either.
     
    Nick Santos, Jan 2, 2004
    #3
  4. Regent

    Regent Guest

    Re[1]: Whether a userid is already in databse

    ------------------------
    Fri, 02 Jan 2004 04:00:51 GMT £¬Nick Santos wrote:
    >>

    >I use MySql, and that's the way I do it, simply checking to see if anything
    >is returned. I think it's fairly effective, because it doesn't require much
    >coding either.
    >


    Thanks, and how do you check by the way?

    ------------------------
    Regent
     
    Regent, Jan 2, 2004
    #4
  5. Regent

    Keith Keller Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2004-01-02, Tintin <> wrote:
    >
    > What would Perl programmers know or care about SQL.


    Many Perl programmers know and care about SQL. Why any of them should
    answer SQL questions in a Perl newsgroup is another question altogether.

    - --keith

    - --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.3 (GNU/Linux)

    iD8DBQE/9RWchVcNCxZ5ID8RAnKwAJ9Du/s2oR0pmeyteNxjM1AGAHJIwACeMN3/
    5u39HJyjfY7wXPwmYBQyXWU=
    =NMz2
    -----END PGP SIGNATURE-----
     
    Keith Keller, Jan 2, 2004
    #5
  6. In article <bt2nva$2qi0e$-berlin.de>,
    "Tintin" <> wrote:

    >What would Perl programmers know or care about SQL.


    I write a lot of Perl (as well as C and other languages), and I use a
    lot of SQL with it. I have also used PHP with SQL, and guess what--I
    think Perl DBI is more advanced than anything PHP can offer.
     
    Lawrence D¹Oliveiro, Jan 2, 2004
    #6
  7. It was a dark and stormy night, and Tintin managed to scribble:

    >
    > "Regent" <> wrote in message
    > news:bt2nnc$1ed8$99.com...
    >> Hi friends,
    >>
    >> I'm doing some cgi programming these days, using MS Access database to

    > store uid/pwd info from registration forms in HTML pages. I considered
    >>
    >> SELECT from Users WHERE userid = '$uid'
    >>
    >> to see whether the received uid (from webpage forms) is already in the

    > database, but I guess there may be more convenient ways to do this?
    >
    > What would Perl programmers know or care about SQL.


    Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.

    The above query I would probably change to
    SELECT count(*) kount from Users WHERE userid = '$uid'

    then test for kount>0 (using the DBI syntax to reference kount).

    gtoomey
     
    Gregory Toomey, Jan 2, 2004
    #7
  8. Regent

    Regent Guest

    Re[1]: Whether a userid is already in databse

    >Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.
    >
    >The above query I would probably change to
    >SELECT count(*) kount from Users WHERE userid = '$uid'
    >
    >then test for kount>0 (using the DBI syntax to reference kount).


    >gtoomey


    Thanks. The idea is to check if the uid already exists and if not INSERT the new user into the db.
    Now that the SELECT is already a filter, I think this filter must be cancelled before the INSERT operation, right? How do I cancel this filter without disconnecting the db? Thanks again

    ------------------------
    Regent
     
    Regent, Jan 2, 2004
    #8
  9. Regent

    Regent Guest

    >Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.
    >
    >The above query I would probably change to
    >SELECT count(*) kount from Users WHERE userid = '$uid'
    >
    >then test for kount>0 (using the DBI syntax to reference kount).


    >gtoomey


    Thanks. The idea is to check if the uid already exists and if not INSERT the new user into the db.
    Now that the SELECT is already a filter, I think this filter must be cancelled before the INSERT operation, right? How do I cancel this filter without disconnecting the db? Thanks again

    ------------------------
    Regent
     
    Regent, Jan 2, 2004
    #9
  10. Re: Re[1]: Whether a userid is already in databse

    It was a dark and stormy night, and Regent managed to scribble:

    >>Lots. Well I've been using SQL for 15 years, and answer a lot of SQL
    >>questions here.
    >>
    >>The above query I would probably change to
    >>SELECT count(*) kount from Users WHERE userid = '$uid'
    >>
    >>then test for kount>0 (using the DBI syntax to reference kount).

    >
    >>gtoomey

    >
    > Thanks. The idea is to check if the uid already exists and if not INSERT
    > the new user into the db. Now that the SELECT is already a filter, I think
    > this filter must be cancelled before the INSERT operation, right? How do I
    > cancel this filter without disconnecting the db? Thanks again
    >
    > ------------------------
    > Regent
    >


    I'd just do an insert, and check the return code. If its OK, or record already present, then that's whay you want.

    If you do a select followed by insert, you are adding an extra database access. This may be significant if you are dealing with lots of records.

    gtoomey
     
    Gregory Toomey, Jan 2, 2004
    #10
  11. Regent

    Matt Garrish Guest

    "Regent" <> wrote in message
    news:bt2nnc$1ed8$99.com...
    > Hi friends,
    >
    > I'm doing some cgi programming these days, using MS Access database to

    store uid/pwd info from registration forms in HTML pages.
    >


    MS Access is a toy (and an ugly, resource-intensive one at that). Get MySQL.

    Matt
     
    Matt Garrish, Jan 2, 2004
    #11
  12. "Regent" <> wrote in message
    news:bt3c34$277t$99.com...
    > >Lots. Well I've been using SQL for 15 years, and answer a lot of SQL

    questions here.
    > >
    > >The above query I would probably change to
    > >SELECT count(*) kount from Users WHERE userid = '$uid'
    > >
    > >then test for kount>0 (using the DBI syntax to reference kount).

    >
    > >gtoomey

    >
    > Thanks. The idea is to check if the uid already exists and if not INSERT

    the new user into the db.
    > Now that the SELECT is already a filter, I think this filter must be

    cancelled before the INSERT operation, right? How do I cancel this filter
    without disconnecting the db?

    there is no such thing in SQL

    the correct way is just to INSERT. if the user is already present,
    you will get an error (assuming userid has a unique constraint)

    if you want to select first, then you need use lock or transaction
    to ensure no other process create the record between your select and insert

    anyways, you should test the result of your insert anyways, so why
    bother with a previous select?


    gnari
     
    Ragnar Hafstae, Jan 2, 2004
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ashish M Bhonkiya
    Replies:
    0
    Views:
    449
    Ashish M Bhonkiya
    May 5, 2004
  2. Patrick Olurotimi Ige
    Replies:
    6
    Views:
    524
    =?Utf-8?B?TmljZW1hbg==?=
    Mar 11, 2005
  3. LaHiRU
    Replies:
    3
    Views:
    355
    Juha Nieminen
    Aug 24, 2009
  4. wolverine
    Replies:
    1
    Views:
    141
    Thomas 'PointedEars' Lahn
    Aug 23, 2007
  5. wolverine
    Replies:
    0
    Views:
    113
    wolverine
    Aug 23, 2007
Loading...

Share This Page