[SQL] Is there a way to build a query based on data in a table?

2013-08-28 Thread Herouth Maoz
Hello. I want to run an automatic archiving SQL script, that looks at a meta-table containing data about the tables to be archived. Basically, suppose I have this data in the meta-table: table_name varchar(100) datetime_column_name varchar(100) archive_interval interval Like this: public.foo

Re: [SQL] exclusion constraint for ranges of IP

2011-08-23 Thread Herouth Maoz
On 23/08/2011, at 13:31, Jasen Betts wrote: > On 2011-08-23, Herouth Maoz wrote: > >>EXCLUDE USING GIST ( customer_id WITH =, is_default WITH AND ) > > >> Basically, each customer can have several rows in this table, but only = >> one per customer is allow

Re: [SQL] exclusion constraint for ranges of IP

2011-08-23 Thread Herouth Maoz
My thanks to everyone who replied. I have decided not to implement that constraint at this time. Using a compound type will make the system more complicated and less readable, plus requires installing the package which is beyond vanilla PostgreSQL. Now I have another exclusion constraint I'm th

Re: [SQL] exclusion constraint for ranges of IP

2011-08-22 Thread Herouth Maoz
On 22/08/2011, at 01:19, Harald Fuchs wrote: > In article , > Herouth Maoz writes: > >> Hi, >> I'm designing a new database. One of the table contains allowed IP ranges >> for a customer (Fields: customer_id, from_ip, to_ip) which is intended to >>

[SQL] exclusion constraint for ranges of IP

2011-08-21 Thread Herouth Maoz
Hi, I'm designing a new database. One of the table contains allowed IP ranges for a customer (Fields: customer_id, from_ip, to_ip) which is intended to check - if an incoming connection's originating IP number falls within the range, it is identified as a particular customer. Naturally, I'd l

Re: [SQL] How to GROUP results BY month

2008-07-15 Thread Herouth Maoz
Oliveiros Cristina wrote: Howdy, all, I have a problem. I have a table which one of the fields is of type date. I need to obtain the totals of the other fields in a by-month basis IS there any easy way to do this using the GROUP BY or any other construct? Yes, use date_trunc( 'month', time

Re: [SQL] How to GROUP results BY month

2008-07-15 Thread Herouth Maoz
Oliveiros Cristina wrote: Howdy, all, I have a problem. I have a table which one of the fields is of type date. I need to obtain the totals of the other fields in a by-month basis IS there any easy way to do this using the GROUP BY or any other construct? Yes, use date_trunc( 'month', time

Re: [SQL] Differentiate Between Zero-Length String and NULLColumn Values

2007-01-30 Thread Herouth Maoz
Andrew Sullivan Wrote: > On Tue, Jan 30, 2007 at 02:38:07PM +0100, Bart Degryse wrote: > > Andrew, I think you're wrong stating that Oracle would interpret > > NULL and empty string as equal. The Oracle databases I use (8, 9 > > and 10) certainly make a distiction between both values. Maybe > > ea