>
> Sidebar:
>
> If I wanted to insert a pdf file into a field, are the code below and the
> code you supplied yesterday the same way to insert the BLOB into an
> Access database?

Yes, read it in binary mode and use SQL_LONGVARBINARY (I think).  Access is
quirky about this, but see

http://search.cpan.org/src/JURL/DBD-ODBC-0.45_17/mytest/longbin.pl

(download it)

This is a program I wrote to test binding long, binary files and inserting
them into the database.  The MD5 stuff is there to validate the data in and
out are the same.

>
> I have asked the list several times, but no one seems to have given a
> straight answer for a newbie like me.

Hmm... I don't remember the question, but I do remember answering one like
it a few months back.  My recommendation is that if you are going to do this
for a LOT of files, insert the PATH into the database (or relative path from
some known local server, depending upon your setup) and pull the file from
the file system, rather than the database.  It's much faster and turns out
to be much easier to manage (backups are easier ,etc )
>
> FYI:  Perl documentation is fragmented, to say the least.  ActiveState's
> PPM/VPM and SOAP directories were a nice attempt at cohesion, but,
> alas, they have failed.  Available printed resources are sparse:  a
> wonderful magazine was absorbed by a miopic company that thinks
> Perl only applies to *NIX sys admins.  When and how does a newbie
> like me (not really.  I have been programming Perl solely for nearly 5
> years on Win32, mostly for cgi call/response) ever get to the stage of
> understanding better?
>
I'd look at Tim Bunce's and Alligator Descarte's book on the DBI as one
resource.  I've been doing perl a (seemingly) long time now and I don't feel
that I scratch the surface either.  There's a lot there and there's many
ways to accomplish the same thing.  Perldoc, though, has been the biggest
help for me over the years...

Regards,

jeff

>
> On 10 Sep 2002 at 7:48, Jeff Urlwin wrote:
>
> > Brad,
> >
> > In theory, this should work too, BTW:
> >
> >   $sth = $dbh->prepare("insert into foo (a, b) values (?, ?)");
> >    # tell DBD::XXXX what types the values are going to be
> >    $sth->bind_param(1, $a_value, SQL_LONGVARCHAR);
> >    $sth->bind_param(2, $b_value, SQL_LONGVARCHAR);
> >    while (get_my_data) {
> >       # then, for each execute re-bind the current values.
> >   $sth->execute($a_value, $b_value);
> >    }
> >
> >
> >
> > > Jeff,
> > >
> > > Thank you tremendously for your help.  I will compile our email
> > > correspondance into a summary email and send it off to the list for
> > > the sake of archiving.
> > >
> > > After your last email, everything is working a-ok!
> > >
> > > Sincerely,
> > > Brad Smith
> > >
> > >
> > >
> > > On 9 Sep 2002 at 21:07, Jeff Urlwin wrote:
> > >
> > > > Sorry -- first of all, please keep dbi-users on the mailing cc
> > > > line or the to line.  Others may see something I don't or be able
> > > > to offer help that I can't.
> > > >
> > > > Since you are using ? for the place holders, you need to
> > > > bind_param(N,xxxx, yyyy) where N is the numerical order for the ?.
> > > > I.e.
> > > >
> > > >  $sth = $dbh->prepare("insert into foo (a, b) values (?, ?)");
> > > >  while (get_my_data) {
> > > >   $sth->bind_param(1, $a_value, SQL_LONGVARCHAR);
> > > >   $sth->bind_param(2, $b_value, SQL_LONGVARCHAR);
> > > >   $sth->execute;
> > > >  }> >
> > > > Try that pattern and see if that works for you.
> > > >
> > > > Jeff
> > > >
> > > > > -----Original Message-----
> > > > > From: Brad Smith [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Monday, September 09, 2002 8:14 PM
> > > > > To: Jeff Urlwin
> > > > > Subject: RE: Quirky problem with DBI
> > > > >
> > > > >
> > > > > Jeff:
> > > > >
> > > > > Still, no luck.  I have altered the code (below), but it fails
> > > > > with the following error.  PArdon my ignorance.  I am a newbie
> > > > > w/ DBI.  I was also wondering how a bind_param works in this
> > > > > situation, since I want to use a WHERE statement (like the #'d
> > > > > lines).
> > > > >
> > > > > The code:
> > > > >
> > > > >     my $dbh = DBI->connect("dbi:ODBC:gatekeepers") || die
> > > > >     DBI::errstr;
> > > > >
> > > > > my $sth1->bind_param('case_notes1',undef,SQL_LONGVARCHAR);
> > > > >       $sth1->execute($in{'case_notes1'});
> > > > > my $sth2->bind_param('case_notes2',undef,SQL_LONGVARCHAR);
> > > > >       $sth2->execute($in{'case_notes2'});
> > > > > my $sth3->bind_param('case_notes3',undef,SQL_LONGVARCHAR);
> > > > >       $sth3->execute($in{'case_notes3'});
> > > > > my $sth4->bind_param('case_notes4',undef,SQL_LONGVARCHAR);
> > > > >       $sth4->execute($in{'case_notes4'});
> > > > >
> > > > >
> > > > > #    my $sth = $dbh->prepare("UPDATE gatekeepers
> > > > > #                              SET   case_notes1 = ?
> > > > > #                              WHERE sid         = ?
> > > > > #                            ") || die DBI::errstr;
> > > > > #
> > > > > #    $sth->execute($in{'case_notes1'}, $in{'sid'});
> > > > >
> > > > >     $dbh->disconnect();
> > > > >
> > > > > The error:
> > > > > Can't call method "bind_param" on an undefined value at c:/i-
> > > > > networks/soar/cgi-bin/collab_gatekeepers_channel_open.pl line
> > > > > 960.
> > > > >
> > > > > Thanks for your help.  I am under the gun right now, and nothing
> > > > > seems to be working correctly.
> > > > >
> > > > > Brad Smith
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 9 Sep 2002 at 18:12, Jeff Urlwin wrote:
> > > > >
> > > > > > Yes, access is sometimes quirky about longs/memos.  Try doing
> > > > > > this (in pseudo code) (warning, may wrap long lines):
> > > > > >  #!perl -w
> > > > > >  # above line makes sure perl is running with warnings.
> > > > > >  use strict; # make sure we have strict on to check for dumb
> > > > > >  typos use DBI qw(:sql_types); # make sure we use DBI and
> > > > > >  import type names, such
> > > > > > as SQL_LONGVARCHAR
> > > > > >  connect()
> > > > > >  $sth = prepare()
> > > > > >
> > > > > >   # only for memos/long fields, where N is the column number
> > > > > >  $sth->bind_param(N, undef, SQL_LONGVARCHAR);
> > > > > >
> > > > > >  etc
> > > > > >
> > > > > >  $sth->execute(args)
> > > > > >
> > > > > > If that fails for some reason, let me know.  The fall back is
> > > > > > to use bind_param() for each of them and pass no arguments to
> > > > > > execute().
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > Jeff
> > > > > >
> > > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>


Reply via email to