Loop through all views with PHP

Started by Stefan Schwarzeralmost 19 years ago3 messagesgeneral
Jump to latest
#1Stefan Schwarzer
stefan.schwarzer@grid.unep.ch

Hi there,

my app is creating views for a certain task; now, I would like to run
on a regular basis a script which deletes these views. As they are
named with the date/hour/min/sec-appendix to make each view unique, I
don't know the names myself (Ok, I could stock the names in a
separate table as well).

Is there any way via PHP to loop through the whole set of views to
delete those with a specific name?

Thanks for any help.

Stef

#2Francisco Reyes
lists@stringsutils.com
In reply to: Stefan Schwarzer (#1)
Re: Loop through all views with PHP

Stefan Schwarzer writes:

Is there any way via PHP to loop through the whole set of views to
delete those with a specific name?

See pg_views.
In particular the viewname column.

#3A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: Stefan Schwarzer (#1)
Re: Loop through all views with PHP

am Mon, dem 18.06.2007, um 14:59:34 +0200 mailte Stefan Schwarzer folgendes:

Hi there,

my app is creating views for a certain task; now, I would like to run
on a regular basis a script which deletes these views. As they are
named with the date/hour/min/sec-appendix to make each view unique, I
don't know the names myself (Ok, I could stock the names in a
separate table as well).

Is there any way via PHP to loop through the whole set of views to
delete those with a specific name?

You can scripting this,
http://people.planetpostgresql.org/greg/index.php?/archives/38-Scripting-with-psql.html#extended.

Modify the query there, change "WHERE relkind = 'r'" and compare with
'v' (VIEW).

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net