Thread: Regarding selction of query

Regarding selction of query

From
SUMA R
Date:
Hi,  In the pgtclsh shell iam able to connect to the database and exec the
queries what i require, ex inserting, deleting etc.
  How can i use the pg_select? . for ex
  pg_exec connection "select * from emp"
  will get executed , but what will happen to the results of select.
  I want the result of the above query to a string.  Iam new to this postgres

from suma   




Re: [INTERFACES] Regarding selction of query

From
Constantin Teodorescu
Date:
SUMA R wrote:
> 
> Hi,
>    In the pgtclsh shell iam able to connect to the database and exec the
> queries what i require, ex inserting, deleting etc.
> 
>    How can i use the pg_select? . for ex
> 
>    pg_exec connection "select * from emp"
> 
>    will get executed , but what will happen to the results of select.
> 
>    I want the result of the above query to a string.
>    Iam new to this postgres

set dbc [pg_connect mydatabase]
pg_select $dbc "select name,age from people" rec {  puts "$rec(name) has $rec(age) years"
}
or
set pgres [pg_exec $dbc "insert into people(name,age) values('teo',36)"]
pg_result $pgres -clear

-- 
Constantin Teodorescu
FLEX Consulting Braila, ROMANIA