[SQL] Scripting GRANT on functions

2005-10-05 Thread Stewart Ben (RBAU/EQS4) *
Is there any easy way to script granting privileges to a number of functions? I've got as far as the following code before realising that I'll need to pass in the arguments, and the arguments are stored as OIDs in pg_proc. Is there any easy way, such as GRANT FUNCTION OID 12345? ---CODE---

Re: [SQL] Use of partial index

2005-10-05 Thread Leif B. Kristensen
On Wednesday 05 October 2005 18:49, you wrote: [Leif] > > Now, here's an "explain select": > > > > pgslekt=> explain select event_date, place from principals where > > person=2 and tag_type=2; > >                                        QUERY PLAN > > --

Re: [SQL] Use of partial index

2005-10-05 Thread Leif B. Kristensen
On Wednesday 05 October 2005 18:44, you wrote: > As I understand it, partial indices are generally useful when you > only want to index a range of values, or if the select condition is > on a different field from the one being indexed (eg: ON foo (a) WHERE > b IS NOT NULL). > > I am just guessing h

Re: [SQL] Use of partial index

2005-10-05 Thread Stephan Szabo
On Wed, 5 Oct 2005, Leif B. Kristensen wrote: > I'm a little confused about partial indexes. I have a couple of tables, > like this: > > CREATE TABLE events ( > event_idINTEGER PRIMARY KEY, > tag_type_fk INTEGER REFERENCES tag_types (tag_type_id), > place_fkINTEGER REFERENCES

Re: [SQL] Use of partial index

2005-10-05 Thread Tom Lane
"Leif B. Kristensen" <[EMAIL PROTECTED]> writes: > I'm a little confused about partial indexes. I have a couple of tables, > like this: > CREATE TABLE events ( > event_idINTEGER PRIMARY KEY, > tag_type_fk INTEGER REFERENCES tag_types (tag_type_id), > place_fkINTEGER REFERENCES

Re: [SQL] Use of partial index

2005-10-05 Thread Dmitri Bichko
As I understand it, partial indices are generally useful when you only want to index a range of values, or if the select condition is on a different field from the one being indexed (eg: ON foo (a) WHERE b IS NOT NULL). I am just guessing here, but it sounds like 'person_fk = 2' is going to be a l

[SQL] Use of partial index

2005-10-05 Thread Leif B. Kristensen
I'm a little confused about partial indexes. I have a couple of tables, like this: CREATE TABLE events ( event_idINTEGER PRIMARY KEY, tag_type_fk INTEGER REFERENCES tag_types (tag_type_id), place_fkINTEGER REFERENCES places (place_id), event_date CHAR(18) NOT NULL DEFAULT

Re: [SQL] BirthDay SQL Issue

2005-10-05 Thread Kenneth Gonsalves
On Sunday 02 Oct 2005 4:02 am, brett wrote: > This is my first posting here, please forgive me if I make any > mistakes here. thought your question was dead simple. worked on the answer for hours at end. learnt a lot of sql, but couldnt solve it. Looks like a solution is out. All i can say is -

Re: [SQL] MOVE in SQL vs PLPGSQL

2005-10-05 Thread Tom Lane
Richard Huxton writes: > Ah, now I see what you're saying. You're quite right in your suspicions, > "MOVE..." isn't supported for plpgsql cursors. You could probably do > something with EXECUTE and returning a refcursor from a previous > function, but that sounds fiddly. > I must admit, on the

Re: [SQL] using pg_tables and tablename in queries

2005-10-05 Thread codeWarrior
"Tom Lane" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > solarsail <[EMAIL PROTECTED]> writes: >> I have a large number of tables with a common naming convention > >> mytable001, mytable002, mytable003 ... mytable00n > >> I would like to do a query across all of the tables, howeve

Re: [SQL] MOVE in SQL vs PLPGSQL

2005-10-05 Thread Richard Huxton
[EMAIL PROTECTED] wrote: Andrew - your question doesn't seem to make sense - can you give some more details? Are you having some problem with cursors in plpgsql? Yes. I'd like the effect of the plain SQL MOVE with a PLPGSQL cursor. I'm writing a procedure for which SQL is inadequate (I need co

Re: [SQL] BirthDay SQL Issue

2005-10-05 Thread Andreas Kretschmer
brett <[EMAIL PROTECTED]> schrieb: > Hi there > > This is my first posting here, please forgive me if I make any > mistakes here. > > Ok > > I have the structure > > {CLIENTS} = Client ID, First Name, Surname, DOB, Address, Home Phone > No, Mobile Phone No > > As one relation / table (There

Re: [SQL] Help with simple SQL query?

2005-10-05 Thread Joost Kraaijeveld
On Wed, 2005-10-05 at 14:21 +0200, Frank van Vugt wrote: > Hi Joost, > > Try joining and comparing the order table with/to an aggregated orderline > table, something like this: > > select order_id, order_price, sum_price, order_price - sum_price as diff > from order, (select parent_order_id, su

Re: [SQL] Help with simple SQL query?

2005-10-05 Thread Frank van Vugt
Hi Joost, Try joining and comparing the order table with/to an aggregated orderline table, something like this: select order_id, order_price, sum_price, order_price - sum_price as diff from order, (select parent_order_id, sum(orderline_price) as sum_price from orderline group by parent_

Re: [SQL] Help with simple SQL query?

2005-10-05 Thread Gregory S. Williamson
Joost -- You are correct in stating that the problem is that the subquery returns more than 1 row -- try using the NOT IN syntax ... it is not likely to be very efficient but at least avoids the syntax error: select order_id from order, orderline where order_id = parent_order_id and order_price

[SQL] Help with simple SQL query?

2005-10-05 Thread Joost Kraaijeveld
Hi, I have 2 tables with the following columns: order: order_id, order_price orderline: parent_order_id, orderline_price I want all orders order where _price <> sum(orderline_price). What is wrong with the following query: select order_id from order, orderline where order_id = parent_order_id

Re: [SQL] Getting user created tables from SQL

2005-10-05 Thread Richard Huxton
Cenk KIZILDAG wrote: TableQuery->SQL->Add ("SELECT TABLE_NAME AS TNAME FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_TYPE = 'BASE TABLE')"); CTableArr[f] = TableQuery->FieldByName ("TNAME")->AsString; the first Select statement work correct, counttables variable gets the right value but unfor

Re: [SQL] BirthDay SQL Issue

2005-10-05 Thread Richard Huxton
brett wrote: I need to be able to select two dates on my webby so I have a range of dates Then I want to be able to get, using some nifty query, everyone's birthday that falls between those two dates. So if someone's birthday was 04/09/79 it would return that tuple I have been stuck on this

Re: [SQL] creating postgres tables by passing a string to function

2005-10-05 Thread Richard Huxton
Scott cox wrote: I am storing data separated by month. How do I perform Inserts and Selects based on something like this. select * from (select 'shipped' || '0509') AS aShippingTable The table 'shipped' || '0509' exists. I am scanning barcode labels which have the '0509' on them and I want to

Re: [SQL] MOVE in SQL vs PLPGSQL

2005-10-05 Thread Richard Huxton
[EMAIL PROTECTED] wrote: I can't find a good way to skip over a large number of records in PLPGSQL (I want to fast-forward and I don't need the I/O of reading and throwing away hundreds of records.) In SQL, I could just use MOVE. That doesn't appear to be supported in PLPGSQL?! Help? Andrew - y