Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Dynamic graphics generation inside plperlu query, odbc and MS Access display



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, 

    OUT val                     int4,
    OUT image			bytea
)
RETURNS SETOF record
AS

$$
    #----------------------------------------------------------------------------
    #-- Configuration des paramètres de la fonction
    #----------------------------------------------------------------------------
    @i = ('a', 'b');
    @io = ();
    @o = ('val','image');

    #----------------------------------------------------------------------------
    #-- Préparation des paramètres de la fonction
    #----------------------------------------------------------------------------
    &start_sub(@_);

    #----------------------------------------------------------------------------
    #-- Test GD
    #----------------------------------------------------------------------------
    use GD;

    # create a new image
    $im = new GD::Image(100,100);

    # allocate some colors
    $white = $im->colorAllocate(255,255,255);
    $black = $im->colorAllocate(0,0,0);       

    # 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'} = $im->gif;
    $output{'val'} = $input{'a'} + $input{'b'};
    ret(@_);

    #----------------------------------------------------------------------------
    #-- Helper functions
    #----------------------------------------------------------------------------
    end_sub(@_);

    sub start_sub
    {
        init(@_);
    }

    sub end_sub
    {
        return undef;
    }

    sub init
    {
	$c = 0;
        foreach $i (@i) {$input{$i} = @_[$c++]};
        foreach $io (@io) {$input{$io} = @_[$c]; $output{$io} = @_[$c++]};
        foreach $o (@o) {$output{$o} = @_[$c++]};
    }

    sub ret
    {
	while (($key, $value) = each %output) {if (!defined($value)) {elog(ERROR, 'Valeur indéfinie pour ' . $key)}}; 
	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  

Attachment: smime.p7s
Description: S/MIME cryptographic signature



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group