[SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread rawi
Hi please help me with the following scenario: I'd gladly have all persons (contacts, customers, staff etc) in one table people with some distinctive flags. My reason for this, is that simple contacts could become customers or even staff, staff members could be in the same time also customers

Re: [SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread Richard Huxton
On 01/03/10 10:07, rawi wrote: But - for the case, that an application-programmer or even I (tired, middle in the night) forget to program the insertion of the needed limiting WHERE condition - it would be great to have some sort of rule ON SELECT, so a SELECT without WHERE on the flags would

Re: [SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread rawi
Not quite the way you suggest. You could build a series of views with the WHERE conditions built in to them, and grant permissions on those though. Thank you very much for your help. Unfortunately is this not what I hoped... The permissions will be granted dynamic by the application out of

[SQL] placement of stored procedures and contrib modules

2010-03-01 Thread Michael Gould
We were trying to use a separate schema to put contrib modules, stored procedures and triggers from our database schema. We called the one where we stored all of the modules isscontrib and the other iss which is where the db is stored. We've fully qualified the names of our items from isscontrib

Re: [SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread Richard Huxton
On 01/03/10 12:16, rawi wrote: Not quite the way you suggest. You could build a series of views with the WHERE conditions built in to them, and grant permissions on those though. Thank you very much for your help. Unfortunately is this not what I hoped... The permissions will be granted

Re: [SQL] Using new.id in the WHERE condition of one UPDATE inside ON INSERT rule

2010-03-01 Thread Aron
On Jueves 25 Febrero 2010 16:28:56 usted escribió: Aron au...@wanadoo.es writes: I would like to avoid using SELECT MAX(id) FROM my_table (it doesn't seem a good method), but if I use new.id, I get new id values, not the id inserted with the rule, and the condition is always false.

[SQL] Create functions using a function

2010-03-01 Thread Gianvito Pio
Hi all, is there a way to define functions and/or triggers in a function? For example, can I create a function that takes an argument and defines a function that has the name passed as argument to the first function? Something like this . CREATE FUNCTION test (name varchar) RETURNS VOID AS

Re: [SQL] Create functions using a function

2010-03-01 Thread Petru Ghita
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yes, it's possible. Use EXECUTE. There is one example under Example 38-9. Porting a Procedure from PL/SQL to PL/pgSQL http://www.postgresql.org/docs/8.4/static/plpgsql-porting.html Also have look in: