I wrote functions to perform the INSERT, UPDATE, and DELETE queries in the database. They take the column values as named parameters.
Sometimes, in UPDATE and INSERT queries, I do not have values for all the columns. I would like the function to simply use the default value I assign to them in the hash of values, like this:
sub function_sql {
my %values = ( VALUE1 => 'one value',
VALUE2 => 'two values',
@_
);
You get the idea. For example, let's say I only pass it arguments for VALUE1. I would like VALUE2 to contain "two values". However, the @_ seems to replace it with UNDEF.
Thanks.
PS: If you know of a better way to accomplish this task (have functions do the SQL for you), I would also like to hear them.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.