From: | Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> |
---|---|
To: | Roy Souther <roy(at)silicontao(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: EXTPROC External Procedure |
Date: | 2005-02-09 19:19:21 |
Message-ID: | Pine.LNX.4.44.0502092016150.7904-100000@kix.fsv.cvut.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
code for genereting xml:
CREATE OR REPLACE FUNCTION ext.xml(varchar) RETURNS text AS $$
use DBI; use XML::Generator::DBI; use XML::Handler::YAWriter;
my $rv = spi_exec_query("SELECT current_setting('client_encoding'), " .
"current_database()", 1);
my $encoding = lc($rv->{rows}[0]->{current_setting[5~});
my $cdb = $rv->{rows}[0]->{current_database};
my $dbh = DBI->connect ("DBI:Pg:dbname=$cdb", "", "", { RaiseError =>
1, PrintError => 0});
my $ya = XML::Handler::YAWriter->new (Encoding=>$encoding,
Pretty => {PrettyWhiteNewline => 1, PrettyWhiteIndent => 1,});
my $gen = XML::Generator::DBI->new (Handler => $ya, dbh => $dbh,
ByColumnName => 1, ShowColumns => 1,);
$gen->execute ($_[0]);
$dbh->disconnect ();
return join('',@{$ya->{Strings}});
$$ LANGUAGE plperlu;
SELECT ext.xml('SELECT * FROM ext.jmena LIMIT 10');
Sending mail, or uploud file via HTTP isn't problem. PL/Perlu works very
fine.
Regards
Pavel Stehule
From | Date | Subject | |
---|---|---|---|
Next Message | Gavin M. Roy | 2005-02-09 19:41:19 | Re: PHP/PDO Database Abstraction Layer |
Previous Message | Alvaro Herrera | 2005-02-09 19:04:30 | Re: Understanding EXPLAIN ANALYZE output |