Re: how to store a query, that results in a table

From: Jie Liang <jliang(at)ipinc(dot)com>
To: nbrito(at)cmet(dot)net
Cc: pgsql-sql-owner(at)hub(dot)org, pgsql-sql(at)hub(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, pgsql-general(at)hub(dot)org
Subject: Re: how to store a query, that results in a table
Date: 2000-09-22 21:41:25
Message-ID: 39CBD205.9A922DDE@ipinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

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(at)ipinc(dot)com
www.ipinc.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nelson 2000-09-22 22:09:07 [SQL] how to store a query, that results in a table
Previous Message Richard Harvey Chapman 2000-09-22 21:22:43 Re: Re: c function

Browse pgsql-novice by date

  From Date Subject
Next Message Nelson 2000-09-22 22:09:07 [SQL] how to store a query, that results in a table
Previous Message root 2000-09-22 14:54:01 how to store a query, that results in a table

Browse pgsql-sql by date

  From Date Subject
Next Message Nelson 2000-09-22 22:09:07 [SQL] how to store a query, that results in a table
Previous Message Stephan Szabo 2000-09-22 17:12:02 Re: sql query not using indexes