pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Some questions about PLpgSql
4+ messages / 4 participants
[nested] [flat]

* Some questions about PLpgSql
@ 2001-03-15 11:03 datactrl <quals@bigfoot.com>
  2001-03-15 16:23 ` Re: Some questions about PLpgSql Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 4+ messages in thread

From: datactrl @ 2001-03-15 11:03 UTC (permalink / raw)
  To: pgsql-sql

Hi, all

By using 'PLpgsql', is that possible to

1) check if a specific table exists?
2) check if an INSERT/UPDATE/ DELETE has done successfully?


Is there some more documents or samples for PLpgsql except  USER GUIDE and
PostgreSQL Introduction & concept?

THANK YOU

JACK





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Some questions about PLpgSql
  2001-03-15 11:03 Some questions about PLpgSql datactrl <quals@bigfoot.com>
@ 2001-03-15 16:23 ` Josh Berkus <josh@agliodbs.com>
  2001-03-15 16:35   ` Re: Some questions about PLpgSql Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Josh Berkus @ 2001-03-15 16:23 UTC (permalink / raw)
  To: pgsql-sql

Jack,

> 2) check if an INSERT/UPDATE/ DELETE has done successfully?

This happens automatically, within a PL/pgSQL function.  If the
INSERT/UPDATE errors out, the function automatically halts.  Actually,
this kind of behaviour can be annoying the other way (sometimes one
doesn't care about the error).  

Now, testing how many rows were inserted/updated/deleted ... that I'm
not sure about.  It would be nice to have a ROWS_AFFECTED returned from
a data manipulation query in PL/pgSQL, but I don't believe that that has
been implemented.

> Is there some more documents or samples for PLpgsql except  USER GUIDE and
> PostgreSQL Introduction & concept?

No. Some of us user-types are working on expanded documentation; until
then, you'll just have to muddle through.

-Josh Berkus

-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 565-7293
   for law firms, small businesses       fax  621-2533
    and non-profit organizations.       San Francisco



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Some questions about PLpgSql
  2001-03-15 11:03 Some questions about PLpgSql datactrl <quals@bigfoot.com>
  2001-03-15 16:23 ` Re: Some questions about PLpgSql Josh Berkus <josh@agliodbs.com>
@ 2001-03-15 16:35   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2001-03-15 16:35 UTC (permalink / raw)
  To: josh@agliodbs.com; +Cc: pgsql-sql

Josh Berkus <josh@agliodbs.com> writes:
> Now, testing how many rows were inserted/updated/deleted ... that I'm
> not sure about.  It would be nice to have a ROWS_AFFECTED returned from
> a data manipulation query in PL/pgSQL, but I don't believe that that has
> been implemented.

It has as of 7.1 --- see GET DIAGNOSTICS foo = ROW_COUNT.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: Some questions about PLpgSql
@ 2001-03-15 12:32 Sondaar Roelof <roelof.sondaar@scania.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Sondaar Roelof @ 2001-03-15 12:32 UTC (permalink / raw)
  To: 'datactrl' <quals@bigfoot.com>; pgsql-sql

Hello jack,

To check if a table exists you could use:
select tablename from pg_tables;
For instance:
dhcp=# select count(*) from pg_tables where tablename='dhcp_subnet';
 count
-------
     1
(1 row)
 
dhcp=# select count(*) from pg_tables where tablename='dhcp_subnetaa';
 count
-------
     0
(1 row)

To see the system tables use \dS


The second I don't really know what you would like to see.
Perhaps a trigger could do this after the insert/update/delete ?

Best regards,
Roelof

> -----Original Message-----
> From:	datactrl [SMTP:quals@bigfoot.com]
> Sent:	15 March 2001 12:04
> To:	pgsql-sql@postgresql.org
> Subject:	[SQL] Some questions about PLpgSql
> 
> Hi, all
> 
> By using 'PLpgsql', is that possible to
> 
> 1) check if a specific table exists?
> 2) check if an INSERT/UPDATE/ DELETE has done successfully?
> 
> 
> Is there some more documents or samples for PLpgsql except  USER GUIDE and
> PostgreSQL Introduction & concept?
> 
> THANK YOU
> 
> JACK
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-03-15 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-15 11:03 Some questions about PLpgSql datactrl <quals@bigfoot.com>
2001-03-15 16:23 ` Josh Berkus <josh@agliodbs.com>
2001-03-15 16:35   ` Tom Lane <tgl@sss.pgh.pa.us>
2001-03-15 12:32 RE: Some questions about PLpgSql Sondaar Roelof <roelof.sondaar@scania.com>

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