From: | SAKAIDA Masaaki <sakaida(at)psn(dot)co(dot)jp> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Getting OID in psql of recent insert |
Date: | 1999-11-23 09:24:52 |
Message-ID: | 383A5D641E0.D5F5SAKAIDA@smtp.psn.ne.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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(at)psn(dot)co(dot)jp>
Personal Software, Inc. Osaka, Japan
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Inoue | 1999-11-23 09:44:51 | RE: AW: [HACKERS] Getting OID in psql of recent insert |
Previous Message | Hiroshi Inoue | 1999-11-23 09:23:03 | RE: [HACKERS] Concurrent VACUUM: first results |