Hi,
> > testdb=> \set singlestep on
> > testdb=> \set sql_interpol '#'
> > testdb=> \set foo 'pg_class'
> > testdb=> select * from #foo#;
In order to solve these problems, I have adopted a approach
which is different from psql. It is 'pgbash'. The pgbash is
the system which offers the direct SQL/embedded SQL interface
for PostgreSQL by being included in the BASH(Version 2) shell.
Please refer to the next URL. http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html
ex.)
pgbash> exec_sql "insert into test values(111,'aaa','bbb')"
pgabsh> rOID=$SQLOID <---- OID of recent insert
pgbash> exec_sql "begin"
pgbash> exec_sql "declare cur cursor fr select * from test
> where oid >= $rOID2 and oid <= $rOID"
pgbash> exec_sql "fetch in cur into :NUM1, :NAME1"
pgbash> exec_sql "fetch in cur into :NUM2, :NAME2"
pgbash> NUM=$(( $NUM1+$NUM2 ))
pgbash> echo $NUM, $NAME1, $NAME2
pgbash> exec_sql "end"
Now, pgbash version is 1.2.3 and this version needs 'exec_sql'
to execute SQL. However, I have changed a parser of BASH-2.03,
and pgbash becomes BASH itself in the next version. It does not
need to describe 'exec_sql' in order to execute SQL.
ex.)
pgbash> insert into test values(111,'aaa','bbb');
pgbash> rOID = $SQLOID
pgbash> select * from test where oid=$rOID; &> /tmp/work.dat
'SQL;' becomes one command of BASH shell. Therefore, it is
possible to use ridirection/pipe with SQL. By this, pgbash has
the operability equal to psql and it will also have many functions
which are higher than psql.
I think this approach useful. Comments?
--
Regards,
SAKAIDA Masaaki <sakaida@psn.co.jp>
Personal Software, Inc. Osaka, Japan