Received: from fileserver002.intecsystems.co.uk ([194.200.14.125]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB6AHht02483 for ; Wed, 6 Dec 2000 05:17:44 -0500 (EST) (envelope-from Michael.Ansley@intec-telecom-systems.com) Received: from fileserver002.intecsystems.co.uk (unverified) by fileserver002.intecsystems.co.uk (Content Technologies SMTPRS 4.1.2) with ESMTP id ; Wed, 6 Dec 2000 10:19:46 +0000 Received: by fileserver002.intecsystems.co.uk with Internet Mail Service (5.5.2650.21) id ; Wed, 6 Dec 2000 10:19:46 -0000 Message-ID: <7F124BC48D56D411812500D0B747251480F315@fileserver002.intecsystems.co.uk> From: Michael Ansley To: "'Edmar Wiggers'" , pgsql-sql@postgresql.org Subject: RE: Using SELECT as DDL/DML statement is wrong (was RE: rei nitialize a sequence?) Date: Wed, 6 Dec 2000 10:19:45 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative ; boundary="----_=_NextPart_001_01C05F6E.0E73D58C" X-Archive-Number: 200012/35 X-Sequence-Number: 366 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C05F6E.0E73D58C Content-Type: text/plain; charset="iso-8859-1" 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 ********************************************************************** ------_=_NextPart_001_01C05F6E.0E73D58C Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: Using SELECT as DDL/DML statement is wrong (was RE: [SQL] reinit= ialize a sequence?)

In fact, I would have thought that this could be done usi= ng

ALTER SEQUENCE sequence_name SET property =3D value

But, altering the database in a procedure called from a s= elect is a design decision, and if somebody wants to do it, well, it's thei= r 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)) FRO= M 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
**********************************************************************
------_=_NextPart_001_01C05F6E.0E73D58C--