help needed with constructing query 
Author Message
 help needed with constructing query

I am trying to to construct a query to insert values into a database - this
is how  i want to do it

my $insert_sql="INSERT INTO $members VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
my $insert_handle=$oracle_dbh->prepare($insert_sql);
for my $id (keys %insert_members) {

Quote:
}

unfortunately some of the variable are dates ( so i use TO_DATE) and some
are numbers. What this means is that i get an error because
everything in the execute list get turned into a string (that is it gets
formatted as 'argument'). How can I get around this without
having to build the sql string from scratch each time ( and having all the
problems with escaping quotes etc)

thanks



Sun, 10 Aug 2003 23:43:24 GMT  
 help needed with constructing query

Quote:

> I am trying to to construct a query to insert values into a database - this
> is how  i want to do it

> my $insert_sql="INSERT INTO $members VALUES
> (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
> my $insert_handle=$oracle_dbh->prepare($insert_sql);
> for my $id (keys %insert_members) {

> }

> unfortunately some of the variable are dates ( so i use TO_DATE) and some
> are numbers. What this means is that i get an error because
> everything in the execute list get turned into a string (that is it gets
> formatted as 'argument'). How can I get around this without
> having to build the sql string from scratch each time ( and having all the
> problems with escaping quotes etc)

You can use the bind_param to specify types.  For example if 3 5 and
10 are dates you'd do:

$insert_handle->bind_param($_, undef , SQL_DATE) for 3,5,10;

(Personally I think this is an awful API!)

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Mon, 11 Aug 2003 01:44:47 GMT  
 help needed with constructing query

Quote:
>(Personally I think this is an awful API!)

Do you use something different?

Thanks, Matt

--
#!/usr/bin/perl
$A='A';while(print+($A.=(grep{($A=~/(...).{78}$/)[0]eq$_}"  A A A  "
=~m{(...)}g)?"A":" ")=~/([ A])$/){if(!(++$l%80)){print"\n";sleep 1}}



Mon, 11 Aug 2003 02:47:19 GMT  
 help needed with constructing query
Hi,

If I try:

    20  use Interpolation
    21      color      => \&get_color,
    22      colour     => \&get_color;

I get:

Values in argument list in `use Interpolation' must be code refs; aborting
 at ./qt line 22

In the following lines from Interpolation.pm:

    61      # Probably should use ISA or something here, because
    62      # $function might be blessed
    63      unless (ref $function eq CODE || exists $builtin{$function}) {
    64        croak "Values in argument list in `use $my_pack' must be
code refs; aborting\n";
    65      }

ref $function apparently has the value 'Interpolation' when it sees
\&get_color the second time, I guess because it got tie'ed to this package
the first time.

Or maybe I'm doing something wrong that I'm not seeing!  Or maybe this is
a feature.  :-)

This is perl, v5.6.0 built for sun4-solaris

Cheers,

Brad



Mon, 11 Aug 2003 03:42:52 GMT  
 help needed with constructing query
DBIx::Recordset is what I use when circumstances allow.

My articles on it are at www.SAHASH.org

Quote:

> >(Personally I think this is an awful API!)

> Do you use something different?

> Thanks, Matt

> --
> #!/usr/bin/perl
> $A='A';while(print+($A.=(grep{($A=~/(...).{78}$/)[0]eq$_}"  A A A  "
> =~m{(...)}g)?"A":" ")=~/([ A])$/){if(!(++$l%80)){print"\n";sleep 1}}



Mon, 11 Aug 2003 08:04:11 GMT  
 help needed with constructing query

Quote:

>    61      # Probably should use ISA or something here, because
>    62      # $function might be blessed
>    63      unless (ref $function eq CODE || exists $builtin{$function}) {

>ref $function apparently has the value 'Interpolation' when it sees
>\&get_color the second time, I guess because it got tie'ed to this package
>the first time.

If that's the problem, the fix is simple.  Delete the now-pointless
comment on lines 61 and 62, and rewrite line 63 to be:

  unless (UNIVERSAL::isa($function, 'CODE') or exists $builtin{$function}) {

I'm skeptical about whether that's the reason for the error, but it's
probably worth fixing anyway.

--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"If all you're looking for is pretty women dressed skimpily, there are
 better ways to satisfy that desire than watching such a spectacularly
 awful Star Trek series."   -- Erik Max Francis in rec.arts.sf.science

Please ignore Godzilla and its pseudonyms - do not feed the troll.



Mon, 11 Aug 2003 21:11:07 GMT  
 help needed with constructing query

Quote:

> >    61      # Probably should use ISA or something here, because
> >    62      # $function might be blessed
> >    63      unless (ref $function eq CODE || exists $builtin{$function}) {

> >ref $function apparently has the value 'Interpolation' when it sees
> >\&get_color the second time, I guess because it got tie'ed to this package
> >the first time.

> If that's the problem, the fix is simple.  Delete the now-pointless
> comment on lines 61 and 62, and rewrite line 63 to be:

>   unless (UNIVERSAL::isa($function, 'CODE') or exists $builtin{$function}) {

> I'm skeptical about whether that's the reason for the error, but it's
> probably worth fixing anyway.

Yes, that appears to fix the error.

Brad



Mon, 11 Aug 2003 22:11:32 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. need help with foreach construct and parsing of list

2. Help, I need a case-like construct!

3. need help with a query that has more than 1 row of results

4. Displaying query output to form, newbie needs help.

5. HELP: PERL construct

6. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

7. Need a basic cgi script that queries an Oracle DB:

8. Text::Query::Advanced - I need a simple example :)

9. I need to query metatdata from acess via DBI

10. need to encode a query string

11. Need cgi echo sample like post-query

12. New modules: Text::Query::Simple and Text::Query::Advanced

 

 
Powered by phpBB® Forum Software