Hi Monks, What Poj suggested did not work, I tried everything including adding absolute path for the images dir, now I want to try a different approach i.e. to get the images first to a folder and pass that to the insert_image() method, for which I have to use COPY command using DBI which again giving errors this command works fine when executed on the command line but DBD::Pg is giving syntax error, here is my script :
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect("DBI:Pg:dbname=northwind;host=localhost", "post +gres", "postgres", {'RaiseError' => 1}); my $empid = $dbh->prepare('SELECT DISTINCT("EmployeeID") as empid FROM + "Employees" ORDER BY 1'); $dbh->do("SET search_path to northwind") or die; $empid->execute(); while(my $ref = $empid->fetchrow_hashref()) { $dbh->do("SET search_path to nortwind") or die; $dbh->do("COPY (SELECT encode(\"Photo\", 'hex') FROM \"Employees\" WHERE \"EmployeeID\"='$ref->{'empid'}') TO '/home/postgres/scripts/images/'$ref->{'empid'}.hex'") o +r die; system("/usr/bin/xxd -p -r /home/postgres/scripts/images/'$ref->{'empi +d'}.jpg'"); } $dbh->disconnect(); exit;
Here is the error :
DBD::Pg::db do failed: ERROR: syntax error at or near "1." LINE 8: '/home/postgres/scripts/images/'1.hex' ^ at photo.pl li +ne 17. DBD::Pg::db do failed: ERROR: syntax error at or near "1." LINE 8: '/home/postgres/scripts/images/'1.hex' ^ at photo.pl li +ne 17.
Please do help. Thanks Terry

In reply to Re: Need help with inserting images to excel from db by terrykhatri
in thread Need help with inserting images to excel from db by terrykhatri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.