Re: [SQL] cannot alter column data type to "date"

2005-12-07 Thread Michael Fuhr
On Thu, Dec 08, 2005 at 03:12:07PM +0800, Noel Doydora wrote: > Below is the message I receive when I try to alter the data type of > a column to "date". I had to drop the column and add it again just > so I can set its data type to "date". How do I change a column's > data type to "date" withou

[SQL] cannot alter column data type to "date"

2005-12-07 Thread Noel Doydora
Below is the message I receive when I try to alter the data type of a column to "date". I had to drop the column and add it again just so I can set its data type to "date". How do I change a column's data type to "date" without dropping and then creating it again? Hoping for a kind response. Th

Re: [SQL] Error from trigger

2005-12-07 Thread Tom Lane
"Leif B. Kristensen" <[EMAIL PROTECTED]> writes: > On Thursday 08 December 2005 00:23, Tom Lane wrote: >> Offhand this looks like you might have dropped and recreated the >> event_citations table? If so it's just the known problem that >> plpgsql caches plans and doesn't throw them away when the r

Re: [SQL] dow question

2005-12-07 Thread Keith Worthington
Michael Glaesemann wrote: On Dec 8, 2005, at 11:03 , Keith Worthington wrote: Is there a better way to do this? The CASE seems inefficient and wordy but perhaps not. I was hoping for day_name(tbl_detail.ship_by_date) || tbl_detail.ship_by_date::text AS sort_by_string but AFAIK day_nam

Re: [SQL] dow question

2005-12-07 Thread Michael Glaesemann
On Dec 8, 2005, at 11:03 , Keith Worthington wrote: Is there a better way to do this? The CASE seems inefficient and wordy but perhaps not. I was hoping for day_name(tbl_detail.ship_by_date) || tbl_detail.ship_by_date::text AS sort_by_string but AFAIK day_name(date) or something like i

[SQL] dow question

2005-12-07 Thread Keith Worthington
Hi All, I am working on a query which in part is CASE WHEN extract(dow from tbl_detail.ship_by_date) = 0 THEN 'Sunday ' || tbl_detail.ship_by_date::text WHEN extract(dow from tbl_detail.ship_by_date) = 1 THEN 'Monday ' || tbl_detail.ship_by_date::text WHEN extract(dow from t

[SQL] Locale and pattern matching

2005-12-07 Thread Hélder M . Vieira
A question about encoding, some days ago, led me to concentrate my attention on the subject and perform a few tests on two different 8.1 installations, configured as follows: Machine 1 - pt_PT(Portuguese_Portugal.28591)/LATIN1 Machine 2 - pt_PT(Portuguese_Portugal.28605)/LATIN9 In both machi

Re: [SQL] Error from trigger

2005-12-07 Thread Leif B. Kristensen
On Thursday 08 December 2005 00:23, Tom Lane wrote: >Is there a reason you don't just mark the FK reference as ON DELETE >CASCADE, rather than using a handwritten trigger? I could have done that, of course. I'm still a little shaky on "best practice" with these things. Besides, I haven't found ou

Re: [SQL] Error from trigger

2005-12-07 Thread Tom Lane
"Leif B. Kristensen" <[EMAIL PROTECTED]> writes: > I have a trigger that will delete records referring to an "events" table > upon deletion. I have used it without problems for a number of times: > CREATE OR REPLACE FUNCTION delete_event_cascade() RETURNS TRIGGER AS $$ > BEGIN > DELETE FROM e

[SQL] Error from trigger

2005-12-07 Thread Leif B. Kristensen
Hello, I have a trigger that will delete records referring to an "events" table upon deletion. I have used it without problems for a number of times: CREATE OR REPLACE FUNCTION delete_event_cascade() RETURNS TRIGGER AS $$ BEGIN DELETE FROM event_citations WHERE event_fk = OLD.event_id; DE

Re: [SQL] Help on function creating

2005-12-07 Thread Aaron Koning
Have you considered using a view to create the report? AaronOn 12/7/05, Alexandre Gonçalves Jacarandá <[EMAIL PROTECTED]> wrote: Hello everyone, I'm using postgresql form an year and I have somedifficult to write a function to make an report. I'm running PostgreSQL7.5.3 on i686-pc-linux-gnu (Mandr

Re: [SQL] constrains problem...

2005-12-07 Thread Richard Huxton
Jure Kodzoman wrote: What i would like to do is create a trigger or a constraint which would on delete of an entry from table1 also deleted all entries containing code from table1 in table_rel. When i try to put a constraint via PgAdmin3 it says it can't do it because 't1code' is not primary ke

[SQL] How to increase row deletion efficiency?

2005-12-07 Thread Alexander Stanier
I am currently trying to separate two environments contained in one database. Essentially I need to break that one database down into two with a portion of the data going to each new database. I am intending to achieve this by duplicating the database and then stripping out the data that is not

Re: [SQL] How to increase row deletion efficiency?

2005-12-07 Thread Tom Lane
Alexander Stanier <[EMAIL PROTECTED]> writes: > I am currently trying to separate two environments contained in one > database. Essentially I need to break that one database down into two > with a portion of the data going to each new database. I am intending to > achieve this by duplicating the

Re: [SQL] Database with "override" tables

2005-12-07 Thread Michael Burke
Lane Van Ingen wrote: Not quite sure how to answer this, but one thought does occur to me: I was perhaps assuming that an override table would override an entire record in the 'original' table(that is what we are doing), and we require that critical fields in the override field be NOT NULL (and

[SQL] constrains problem...

2005-12-07 Thread Jure Kodzoman
Hy list, i would like to ask you for help. I have 3 tables. table1 has primary key 't1code' and table_rel is 'many to many' relation for table2. table2 primary key is 't2code' table_rel has two fields: 't1code' and 't2code', where both of them together make a primary key for the rela

[SQL] Help on function creating

2005-12-07 Thread Alexandre Gonçalves Jacarandá
Hello everyone, I'm using postgresql form an year and I have some difficult to write a function to make an report. I'm running PostgreSQL 7.5.3 on i686-pc-linux-gnu (Mandriva 10.1). My table structure is: Tabela "public.matricula" Column | Type |Modifiers