pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedUsing SELECT as DDL/DML statement is wrong (was RE: reinitialize a sequence?)
3+ messages / 2 participants
[nested] [flat]
* Using SELECT as DDL/DML statement is wrong (was RE: reinitialize a sequence?)
@ 2000-12-05 16:49 Edmar Wiggers <edmar@brasmap.com>
0 siblings, 0 replies; 3+ messages in thread
From: Edmar Wiggers @ 2000-12-05 16:49 UTC (permalink / raw)
To: pgsql-sql
If and when stored procedures are supported, there should be some way to
prevent functions called in a SELECT statement to modify the database
(create, insert, etc.).
It is confusing (and wrong IMHO) to use statements like
SELECT setval('tablename_serfield_seq',max(serfield)) FROM tablename;
(which is used to reset a sequence)
That should be done with
EXECUTE procedure(tablename_name,sequence_name);
(not sure if execute is the right keyword)
Yours sincerely,
Edmar Wiggers
BRASMAP Information Systems
+55 48 9960 2752
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: Using SELECT as DDL/DML statement is wrong (was RE: rei nitialize a sequence?)
@ 2000-12-06 10:19 Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ansley @ 2000-12-06 10:19 UTC (permalink / raw)
To: 'Edmar Wiggers' <edmar@brasmap.com>; pgsql-sql
In fact, I would have thought that this could be done using
ALTER SEQUENCE sequence_name SET property = value
But, altering the database in a procedure called from a select is a design
decision, and if somebody wants to do it, well, it's their problem. There
may (on very few occasions, one would hope) actually be some good reasons to
do this.
Cheers...
MikeA
-----Original Message-----
From: Edmar Wiggers [mailto:edmar@brasmap.com]
Sent: 05 December 2000 16:50
To: pgsql-sql@postgresql.org
Subject: Using SELECT as DDL/DML statement is wrong (was RE: [SQL]
reinitialize a sequence?)
If and when stored procedures are supported, there should be some way to
prevent functions called in a SELECT statement to modify the database
(create, insert, etc.).
It is confusing (and wrong IMHO) to use statements like
SELECT setval('tablename_serfield_seq',max(serfield)) FROM tablename;
(which is used to reset a sequence)
That should be done with
EXECUTE procedure(tablename_name,sequence_name);
(not sure if execute is the right keyword)
Yours sincerely,
Edmar Wiggers
BRASMAP Information Systems
+55 48 9960 2752
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
Nick West - Global Infrastructure Manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: Using SELECT as DDL/DML statement is wrong (was RE: reinitialize a sequence?)
@ 2000-12-06 12:43 Edmar Wiggers <edmar@brasmap.com>
parent: Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
0 siblings, 0 replies; 3+ messages in thread
From: Edmar Wiggers @ 2000-12-06 12:43 UTC (permalink / raw)
To: pgsql-sql
> But, altering the database in a procedure
> called from a select is a design decision,
> and if somebody wants to do it, well, it's
> their problem. There may (on very few
> occasions, one would hope) actually be some
> good reasons to do this.
Ok, it's their problem. But, as a DBA, I would like to have stored
procedures. Having that, I would also like a way to prevent any application
development that uses SELECT statements to alter the database. By
definition, that's not what SELECT is for (and so it is bad practice to use
it that way).
Currently however, that's the only whay to do it (use something similar to
stored procs). And, true, that's much better than not doing it at all.
Yours sincerely,
Edmar Wiggers
BRASMAP Information Systems
+55 48 9960 2752
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-12-06 12:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-05 16:49 Using SELECT as DDL/DML statement is wrong (was RE: reinitialize a sequence?) Edmar Wiggers <edmar@brasmap.com>
2000-12-06 10:19 RE: Using SELECT as DDL/DML statement is wrong (was RE: rei nitialize a sequence?) Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
2000-12-06 12:43 ` Edmar Wiggers <edmar@brasmap.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