Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: Perl Access Database by SageMusings
in thread Perl Access Database by Lynn

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-10-03 04:53 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (13 votes). Check out past polls.