Dynamic graphics generation inside plperlu query, odbc and MS Access display
am 03.07.2006 11:44:05 von Philippe LangThis is a multi-part message in MIME format.
------=_NextPart_000_000F_01C69E95.FD10A500
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I'm trying to generate an image inside a plperlu function (PG 8.1.4), =
and to display it in a MS Access form, through ODBC.
I'm using the GD library for this. Here is the test code:
------------------------------------------------------------ -------------=
---
CREATE OR REPLACE FUNCTION test_gd
(
IN a int4,
IN b int4,=20
OUT val int4,
OUT image bytea
)
RETURNS SETOF record
AS
$$
=
#----------------------------------------------------------- -------------=
----
#-- Configuration des param=E8tres de la fonction
=
#----------------------------------------------------------- -------------=
----
@i =3D ('a', 'b');
@io =3D ();
@o =3D ('val','image');
=
#----------------------------------------------------------- -------------=
----
#-- Pr=E9paration des param=E8tres de la fonction
=
#----------------------------------------------------------- -------------=
----
&start_sub(@_);
=
#----------------------------------------------------------- -------------=
----
#-- Test GD
=
#----------------------------------------------------------- -------------=
----
use GD;
# create a new image
$im =3D new GD::Image(100,100);
# allocate some colors
$white =3D $im->colorAllocate(255,255,255);
$black =3D $im->colorAllocate(0,0,0); =20
# make the background transparent and interlaced
$im->transparent($white);
# Put a black frame around the picture
$im->rectangle(0,0,99,99,$black);
# Draw a blue oval
$im->arc(50,50,95,75,0,360,$black);
# And fill it with red
$im->fill(50,50,$black);
$output{'image'} =3D $im->gif;
$output{'val'} =3D $input{'a'} + $input{'b'};
ret(@_);
=
#----------------------------------------------------------- -------------=
----
#-- Helper functions
=
#----------------------------------------------------------- -------------=
----
end_sub(@_);
sub start_sub
{
init(@_);
}
sub end_sub
{
return undef;
}
sub init
{
$c =3D 0;
foreach $i (@i) {$input{$i} =3D @_[$c++]};
foreach $io (@io) {$input{$io} =3D @_[$c]; $output{$io} =3D =
@_[$c++]};
foreach $o (@o) {$output{$o} =3D @_[$c++]};
}
sub ret
{
while (($key, $value) =3D each %output) {if (!defined($value)) =
{elog(ERROR, 'Valeur ind=E9finie pour ' . $key)}};=20
return_next \%output;
init(@_);
}
$$
LANGUAGE 'plperlu';
------------------------------------------------------------ -------------=
---
The function looks good. If I run inside pgAdmin:
select * from test_gd('7', '3');
I get:
val image
--------------
10 GIF89ad
The problem is that I'm unable to display anything in a MS Access form, =
and I'm not quite sure how to do it. I've been using a "bytea" column =
type, is that correct?
In Ms Access, I've created a pass-through query, linked it to a form =
with an OLE Dependant Control. But... Nothing. Same Problem id I try =
wbmp or jpeg images.
Does anyone have an idea how to do this?
Thanks.
Note: I'm using the latest driver: psqlodbc-08_02_0002.zip
----------------------------------
Philippe Lang, Ing. Dipl. EPFL
Attik System
rte de la Fonderie 2
1700 Fribourg
Switzerland
http://www.attiksystem.ch
Tel: +41 (26) 422 13 75
Fax: +41 (26) 422 13 76 =20
------=_NextPart_000_000F_01C69E95.FD10A500
Content-Type: application/x-pkcs7-signature;
name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="smime.p7s"
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEH AQAAoIII/zCCAocw
ggHwoAMCAQICEEdYYafa1wkm0CP4DOffAiswDQYJKoZIhvcNAQEEBQAwYjEL MAkGA1UEBhMCWkEx
JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNV BAMTI1RoYXd0ZSBQ
ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MDYyMjE3MzE0NloX DTA3MDYyMjE3MzE0
NlowZzENMAsGA1UEBBMETGFuZzERMA8GA1UEKhMIUGhpbGlwcGUxFjAUBgNV BAMTDVBoaWxpcHBl
IExhbmcxKzApBgkqhkiG9w0BCQEWHHBoaWxpcHBlLmxhbmdAYXR0aWtzeXN0 ZW0uY2gwgZ8wDQYJ
KoZIhvcNAQEBBQADgY0AMIGJAoGBAOfvCPREDwfIbzsNRoyBDoSOWfI2NNWd RRMJXu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