Re: [SQL] How to implement Aggregate Awareness?

2011-11-07 Thread Little, Douglas
Olgierd, This can be done, but it relies on a very strong metadata component that is not available in PG. In db2eee it's completed by having a construct known as automatic summary tables - similar to materialized views Where in ddl you tell the system how the aggregate and base table are

Re: [SQL] Schema partitioning

2011-09-02 Thread Little, Douglas
I generally would separate different apps into different schema. doug -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of David Johnston Sent: Friday, September 02, 2011 8:20 AM To: Charlie Cc: pgsql-sql@postgresql.org Subject:

[SQL] Delete rules

2010-08-04 Thread Little, Douglas
Hi, We'd like to give our applications truncate capability, but that would also give them drop table permission, which we don't want them to have. So, we created a truncate function that uses the definers security context. The issue is that we now have 1000's of programs to change to use the

Re: [SQL] question about partitioning

2010-06-24 Thread Little, Douglas
I don't know how you would partition by size. Date is a good candidate, and roughly wouldn't you have the same number of tx's/day You'll only benefit query performance if you include the partitioning column in the where clause. If you have a surrogate pk, you could also use this to partition.

Re: [SQL] what does this do

2010-06-10 Thread Little, Douglas
First remove the python select * from jfcs_balancedue(parameter) f(enrolleeid varchar,course_cost decimal, paid_amt decimal) the jfcs_balancedue is a table function, f is the alias (with the column alias list/datatype of the columns returned by the function). Doug -Original Message-

Re: [SQL] Difference between these two queries ?

2010-06-06 Thread Little, Douglas
Nilesh, They should generate equivalent results, But the difference is the constraint on bu.bid=5. In the 1st case it's being done after the join. In the 2nd case it is being done before the join. The end result should be the same, but the execution time can be hugely different. Suppose b

[SQL] Access Update error: solution.

2010-05-21 Thread Little, Douglas
A comment on the MS access/PG problem. We experienced this problem as well and I isolated the problem to access's support of timestamp. PG defaults to timestamp(6), While access only supports timestamp(2). When access fills the grid from the table, the values are truncated to ts(2).

Re: [SQL] Postgresql database

2010-05-14 Thread Little, Douglas
To do a better job, I’d need to see the data dictionary – eg to understand what capacity means. Is it the capacity of a model? Ok, but what about contact info for a model? Is this really the contact info of the plant? But this is what I’d do [cid:image002.png@01CAF33E.5FD30FB0] Mfg –

Re: [SQL] Greetings folks, dumb question maybe?

2010-05-12 Thread Little, Douglas
I've been using the generate_series function and finding it very useful. It generates an integer, but I cast to 'day' interval. Might be useful. doug -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Richard Broersma Sent:

Re: [SQL] string functions and operators

2010-03-23 Thread Little, Douglas
Here's a thought create table test1(col1 decimal(7,1)); insert into test1 values(77.1),(77.2),(134.1),(134.2),(134.3),(5.1),(5.2) select col1::integer from test1; select substr((col1-col1::integer),3) from test1; doug From: pgsql-sql-ow...@postgresql.org

Re: [SQL] Check type compatibility

2010-03-06 Thread Little, Douglas
Hello, I believe types are compatible if they can be cast automatically. The pg_cast table record all possible casts between types. If it castcontext is 'a' then I belive it's an automatic conversion which is what I think you want. 'i' implicit means that cast is possible, but must be

[SQL] Assigning NEW. anomoly

2010-03-06 Thread Little, Douglas
Hello, I have a trigger function designed to encrypt source data on insert/update. I have a problem where an assignment isn't happening, and I don't understand why. Any thoughts In the function, I unnecessarily reset new.pii_ccard_number to null. It must be null already for the else condition

Re: [SQL] check constraint on multiple tables?

2010-03-03 Thread Little, Douglas
Hello, I would have designed as ship cabin (PK of ship_id, Cabin_id) And a separate chain of cabin_type cabin_category cabin Type, and category are group classifiers and shouldn't be used to define the uniqueness of a cabin. Take an example where the cabin category and type are defined

Re: [SQL] check constraint on multiple tables?

2010-03-03 Thread Little, Douglas
- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Louis-David Mitterrand Sent: Wednesday, March 03, 2010 10:07 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] check constraint on multiple tables? On Wed, Mar 03, 2010 at 10:03:05AM -0600, Little, Douglas

Re: [SQL] check constraint on multiple tables?

2010-03-03 Thread Little, Douglas
Louis, Interesting discussion. Always fun to think about real world stuff. We have a similar problem for comparing hotel rooms. So the issue is that you aren't originating the data, just classifying it. I'd move toward a scheme where you reclassify the line marketing speak to common lay

[SQL] how to: refer to select list calculations other places in the calculations.

2009-09-09 Thread Little, Douglas
Hi, I have very complex sql (generated by cognos) I'm porting from Teradata that basically uses column alias in the calculated columns. Is there any way to do this type of thing in Psql? Essentially I need to do is refer to a calculated column later in the select list (but far more complex -