Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Perl Access Database

by SageMusings (Beadle)
on May 23, 2001 at 00:10 UTC ( #82375=note: print w/replies, xml ) Need Help??

in reply to Perl Access Database

You have at least two options:
1. You can edit the properties of your MS Access database in the design window. Fields can be designated to accept blank values. However, for referential integrity when relating to other tables, this is not an elegant solution.
2. The best solution is to test a field for an undefined value prior to inserting data into the table. Simply, insert a text value "NULL". Here is an example of code I wrote to prevent just such an occurence:

sub validate { $valid_data = 1; @parameters = qw/LASTNAME FIRSTNAME RANK BILLET EMAIL ERO UNIT DSN RUC NOMEN NSN SERNO COMPANY CONDITION DEFECT SHIP +MENT CORRECT COMMENTS/; @req_param = qw/LASTNAME FIRSTNAME RANK BILLET EMAIL ERO UNIT DSN RUC NOMEN NSN SERNO COMPANY/; foreach $response (@parameters) { print h3($response, " = ", uc(param($response))), hr; $CGI_hash{$response} = param($response); # remove punctuation( ' )which will crash the SQL $CGI_hash{$response} =~ s/'//g; # remove hyphens from numbers for consistency $CGI_hash{"NSN"} =~ s/-//g; # database demands non-blank values if ($CGI_hash{$response} eq "") { $CGI_hash{$response} = "NULL"; } $accumulator = $accumulator . uc($CGI_hash{$response}) . "','" +; } &parse_nulls; chop($accumulator); chop($accumulator); $NSN_len = length($CGI_hash{"NSN"}); if ($NSN_len != 13) { $valid_data = 0; } return;

I hope this helps you.

Replies are listed 'Best First'.
Re: Re: Perl Access Database
by Anonymous Monk on May 24, 2001 at 17:08 UTC
    It's beginning to look like I need to know more about Access Databases. BTW what is handling the file/recordlock when I'm using ODBC? Thanks for you help! Also is there a proper way to thank everyone who has posted solutions?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2022-08-16 13:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found