rodry has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Default values in functions arguments
by chromatic (Archbishop) on Sep 27, 2000 at 23:07 UTC | |
Re: Default values in functions arguments
by mdillon (Priest) on Sep 27, 2000 at 22:12 UTC | |
RE: Default values in functions arguments
by Adam (Vicar) on Sep 28, 2000 at 00:18 UTC | |
Re: Default values in functions arguments
by ar0n (Priest) on Sep 27, 2000 at 22:11 UTC | |
Re: Default values in functions arguments
by jptxs (Curate) on Sep 27, 2000 at 22:44 UTC | |
Re: Default values in functions arguments
by little (Curate) on Sep 27, 2000 at 22:45 UTC | |
RE: Default values in functions arguments
by runrig (Abbot) on Sep 28, 2000 at 01:53 UTC | |
A better way to accomplish this task (was Re: Default values in functions arguments)
by brother ab (Scribe) on Sep 28, 2000 at 11:03 UTC | |
by jplindstrom (Monsignor) on Sep 28, 2000 at 12:20 UTC |
Back to
Seekers of Perl Wisdom