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

Re: [INTERFACES] Pg and Perl!!

From: Constantin Teodorescu <teo(at)flex(dot)ro>
To: "Ilhuicatzi Cortes J(dot) Henry" <ic94006(at)solar6(dot)ingenieria(dot)uatx(dot)mx>, PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [INTERFACES] Pg and Perl!!
Date: 1999-04-29 05:42:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
"Ilhuicatzi Cortes J. Henry" wrote:
> Hi:
>    im using Pg to make CGI's beetwen Postgres and perl, where can i find
> examples about Pg. I have tried to make any CGI's and doesn't work fine.
>   Does someone have any examples about CGI?

Sorry , they are in romaniana language !


# Decomentati urmatoarea linie daca lucrati cu Postgres
use Pg;

   $datele = <STDIN>;
   @pairs = split(/&/, $datele);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);
      # restore blank
      $value =~ tr/+/ /;
      # restore special char
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      # store them into associative array %VAR
      chomp $value; $value =~ s/\r//;
      $VAR{$name} = $value ;

#  preluam cimpurile transmise in variabile
   $database   = $VAR{'db'};
   $data       = $VAR{'data'};
   $dolar        = $VAR{'dolar'};

   if ( $an < 100) { $an += 1900;} $data=$luna.'-'.$zi.'-'.$an;

# Acest rind este obligatoriu pentru inceput de HTML raspuns
print "Content-type:text/html\n\n";

print <<EOM;
<TITLE>Adaugare curs dolar</TITLE>
<H1>Curs dolar</H1>

S-a solicitat actualizarea cursului dolarului
pentru data de <b>$oldata</b> la valoarea de <b>$dolar


$res=PQexec($con,"select * from valuta where data='$data'");
if($errmsg ne '') {
   print "EROARE : ",$errmsg;
   print "</body></html>\n";
   exit 1;
if(PQntuples($res) > 0) {
   print "<B>Informatia valutara pentru data $oldata era introdusa
   print "Cursul valutar pentru aceasta zi era
   print "Modificam cu noul curs : ",$dolar,"<br><br>\n";
   $sqlcmd="update valuta set dolar=$dolar where data='$data'";
} else {
   $sqlcmd="insert into valuta (data,dolar) values ('$data',$dolar)";
$errmsg = PQerrorMessage($con);
if ( $errmsg ne '' ) {
     print '<font color="#FF0000">';
     print "<b>EROARE : ",$errmsg,"</b></font><br>";
     print "SQL=$sqlcmd<br>";
} else {
     print "Baza de date a fost actualizata cu succes.";


Constantin Teodorescu
FLEX Consulting Braila, ROMANIA

In response to

  • Pg and Perl!! at 1999-04-28 21:51:02 from Ilhuicatzi Cortes J. Henry

pgsql-interfaces by date

Next:From: Leon HarrisDate: 1999-04-29 06:16:39
Subject: pgaccess and autonumber fields.
Previous:From: Constantin TeodorescuDate: 1999-04-29 05:39:32
Subject: Re: [INTERFACES] RPM for PgAccess 0.96

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group