pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jie Liang <jliang@ipinc.com>
To: nbrito@cmet.net
Cc: pgsql-sql-owner@hub.org
Cc: pgsql-sql@hub.org
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Cc: pgsql-general@hub.org
Subject: Re: how to store a query, that results in a table
Date: Fri, 22 Sep 2000 14:41:25 -0700
Message-ID: <39CBD205.9A922DDE@ipinc.com> (raw)
References: <39CB65A0.9DEF7ABB@cmet.net>

Hi, there,

If the client machine is a trusted machine in your company, use remote
shell 'rsh' can
call a script of SQL.
If not , you had better use embeded SQL.

I don't know how visual basic embed SQL, but I think is same way as other
language,
in postgres:
#db> create  user robot with password 'wowwow';
$db> grant all on table1 to robot;

In perl , it's very similar like this:
use Pg;
my $conn;
        sub connectDb {
           $conn = Pg::connectdb("dbname=db host=dbserver port=5432
user=robot password=wowwow");
           if ( $conn->status != Pg::PGRES_CONNECTION_OK ) {
                die "Cant open postgres! : " . $conn->errorMessage . "\n";
                }
           return;
         }
#main
        connectDb();
        my $query="select * from table1 where row1=parameter1";
        print $query,"\n";
        my $res=$conn->exec($query);
        $res->cmdStatus || die $conn->errorMessage.":$!\n";
        my $rows= $res->ntuples;
        for (my $k = 0 ; $k < $rows; $k++){
                my $field1=$res->getvalue($k,0);
                my $field2=$res->getvalue($k,1);
                print $field1,"\t",field2,"\n";
        }


root wrote:

> hi.
> I have a problem.
> I require to store a query sql in postgresql-7.0 like:
> example.
> select * from table1 where row1(table1)=parameter1
> If i execute this query directly, I don't have problem.
> I want to store this query in order to execute from a client program
> (visual basic 6.0), but i don't know how to?
> I tried to store the query like a function (create function ...), but it
> was impossible to find a way in order to obtain a table like result.
> Only we could obtain a single row by using the rtype " returns setof
> varchar".
> I hope a soon answer.
> Thank you.
>  Nelson B.

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com

view thread (7+ messages)  latest in thread

Message-ID: <39CBD205.9A922DDE@ipinc.com>
Permalink:  ../39CBD205.9A922DDE@ipinc.com/
Also on:    postgresql.org/message-id/39CBD205.9A922DDE@ipinc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jliang@ipinc.com, nbrito@cmet.net, pgsql-sql-owner@hub.org, pgsql-sql@hub.org, pgsql-general@postgresql.org, pgsql-general@hub.org
  Subject: Re: how to store a query, that results in a table
  In-Reply-To: <39CBD205.9A922DDE@ipinc.com>
  References: <39CB65A0.9DEF7ABB@cmet.net> <39CBD205.9A922DDE@ipinc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox