in reply to Need help with inserting images to excel from db
Here is the error :#!/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;
Please do help. Thanks TerryDBD::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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with inserting images to excel from db
by poj (Abbot) on Jun 29, 2014 at 14:14 UTC | |
by terrykhatri (Acolyte) on Jul 01, 2014 at 09:47 UTC | |
by poj (Abbot) on Jul 01, 2014 at 15:02 UTC |