Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
TABNAME COL1 ADDITIONAL + __________________________________ TableA FOO TableA F* TableA FOO|BAR TableB &COLNAME=VALUE TableB &COLNAME=V* TableB &COLNAME=VALUE&COL2=VALU +E TableB &COLNAME=VALUE&COL2=VAL* TableB &COLNAME=VALUE|VALUE2&CO +L2=VALUE TableB Foo|BAR &COLNAME=VALUE|VALUE2&COL2=VA +LUE TableB Foo &DATERAGE=19910101:199101 +31 TableB Foo &DATERAGE=<19910101
#!/usr/bin/perl use strict; use warnings; use DBI; use Data::Dumper; use SQL::Abstract; # Subroutine to call sub process(){ my $processed = $_[0]; return sub { if ( @_ ){ #@_ =~ s/^&//; # strip leading & - this only occurs in the + 'additional field' print "recieved: @_\n"; # detect additional with multiple key value pairs. if ( index(@_,'&') >= 0 ){ print "@_ contaisn & character - so it's the additiona +l field with multiple key value pairs"; } # detect ors if ( index(@_,'|') >= 0 ){ print "@_ contains pipe character for ORs"; } # detect wildcards if ( index(@_,'*') >= 0 ){ print "@_ contains whidcard character"; } } } } # skip the actual fetching of the data via SQL query, I have no proble +ms with that part process->($TABNAME) if defined($TABNAME); process->($COL1) if defined($COL1); process->($ADDITIONAL) if defined($ADDITIONAL);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sub Routines and Building SQL statement
by Anonymous Monk on Nov 21, 2011 at 15:03 UTC | |
by Anonymous Monk on Nov 21, 2011 at 16:14 UTC | |
by Anonymous Monk on Nov 21, 2011 at 16:51 UTC | |
by aaron_baugher (Curate) on Nov 21, 2011 at 21:14 UTC |