Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Handling Null or Undef values in DBI (and things of those nature)...

by rbc (Curate)
on Jan 08, 2002 at 04:49 UTC ( #137012=note: print w/replies, xml ) Need Help??


in reply to Handling Null or Undef values in DBI (and things of those nature)...

I hope this info can help you with your 2nd
question.

Off the top of my head there are aleast 3 ways
to check the table before you insert a new record.

way one) would be to define a unique constraint
on this table in the DBMS. This will prevent any
insertion of a record that is a duplicate.

way two) would be to define a before insert trigger
and have this trigger check for a duplicate.

way three) execute the query select count(*) into n from ...
and if n > 0 then the record exist.

--
Its like a dog that can sing and dance.
It's remarkable because it can do it.
Not that it can do it well.
  • Comment on Re: Handling Null or Undef values in DBI (and things of those nature)...

Replies are listed 'Best First'.
Re: Re: Handling Null or Undef values in DBI (and things of those nature)...
by data67 (Monk) on Jan 08, 2002 at 05:10 UTC
    Can you please give me an example or two on your seggestions.

    As far as my first question i got it done by doing this

    while (@row = $sth->fetchrow_array) { foreach (@$row) { $_ = '' unless defined; ### HANDLE NULL FIELDS } }
Re: Re: Handling Null or Undef values in DBI (and things of those nature)...
by rbc (Curate) on Jan 09, 2002 at 02:28 UTC
    Find an SQL manual or on-line doc. and look up
    the ALTER TABLE and CREATE TRIGGER commands.
    They do a much better job than I could :)

    --
    Its like a dog that can sing and dance.
    It's remarkable because it can do it.
    Not that it can do it well.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://137012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2022-08-09 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?