Re: [SQL] Index scan

2001-01-31 Thread Mark Volpe
Since you are selecting all the rows of media, there is no reason to use the index to do this as it would just slow things down. Mark Najm Hashmi wrote: > > Hi all, > I am unable to understand why my inidcies are not used in the query. > I have following indices: > index on categories.root

Re: [SQL] Permissions for foreign keys

2001-01-31 Thread Mark Volpe
The problem is fixed in the 7.1 beta series. Rick Delaney wrote: > > I'm using 7.0 and have noticed that I need to grant SELECT and UPDATE > permissions on any referentially-related tables. Can/should I get > around this? A somewhat contrived example: > > CREATE TABLE emp ( > id integer PRIM

Re: [SQL] interval query.

2001-01-31 Thread Mark Volpe
Try SELECT * FROM Towns WHERE id= OR id BETWEEN 3 AND 12 Antti Linno wrote: > > Good morning. > > Is there some way to make interval query? > > Towns table(estonia towns, heh :P) > > id | name > > 1 Elva > 2 Tartu > Tallinn > 3 Tallinn/Haabersti > 4 Tall

Re: [SQL] BTP_CHAIN errors fixed?

2001-01-27 Thread Mark Volpe
Tom Lane wrote: > > Mark Volpe <[EMAIL PROTECTED]> writes: > > I have been using PostgreSQL-7.0.0 and have had the problem that, when > > searching a btree index that contains large numbers of duplicate keys, > > Postgres crashes with a BTP_CHAIN error. Now that I h

[SQL] BTP_CHAIN errors fixed?

2001-01-27 Thread Mark Volpe
Hi, I have been using PostgreSQL-7.0.0 and have had the problem that, when searching a btree index that contains large numbers of duplicate keys, Postgres crashes with a BTP_CHAIN error. Now that I have installed 7.1beta3 the problem has seemingly been fixed. Was this problem actually fixed somewh

Re: [SQL] Re: NULL

2000-10-24 Thread Mark Volpe
\N is normally used to represent NULL in a text file, however you can change that to another string (or an empty string) using COPY FROM ... WITH NULL AS Mark Sandis Jerics wrote: > > Hello, > > how must i write a NULL value in a text file for the \copy command to > understand it? > NULL, \0 d

Re: [SQL] dynamic object creation

2000-10-12 Thread Mark Volpe
You may want to think about creating your table like this (for example): CREATE TABLE data ( key text, field_type char, value text ); CREATE UNIQUE INDEX data_key ON data(key, field_type, value); So this way each "record" takes up several rows in the table, and each "fie

[SQL] AFTER triggers, short question

2000-10-11 Thread Mark Volpe
If I create a trigger that runs AFTER a DELETE, and then I delete several rows, will the trigger function see the same thing every time it's called, namely that all the rows I deleted are actually gone? Mark

[SQL] Typecast a user-defined type?

2000-10-04 Thread Mark Volpe
Hi, I've created my own datatype for Postgres. I have found it necessary to be able to convert it to text, so I could match it up with a text column in a UNION. I figured Postgres would do this for me, but then, I'm naive. Can someone give me a hint, or point me to the appropriate material on how

Re: [SQL] Multiple Index's

2000-09-21 Thread Mark Volpe
CREATE TABLE user_info(user_id name, entry_date date, info text); CREATE UNIQUE INDEX user_info_key ON user_info(user_id, entry_date); "Brian C. Doyle" wrote: > > Hello all, > > How would I prevent a user from submitting information to a table once they > have already done so for that day. I w

Re: [SQL] Time Help

2000-08-22 Thread Mark Volpe
> > > If is use : > > > > > > SELECT '0:00:00'::time + '02:10:06'::timespan; > > > > > > It get > > > > > > No such function 'time_timespan' with the specified attributes > > > > > &

Re: [SQL] Time Help

2000-08-22 Thread Mark Volpe
et > > No such function 'time_timespan' with the specified attributes > > So i guess what I want to do is convert a timespan into time > How would I do that? > > At 09:55 AM 8/22/00 -0400, Mark Volpe wrote: > >I'm not sure at all what you are asking,

Re: [SQL] Time Help

2000-08-22 Thread Mark Volpe
I'm not sure at all what you are asking, but I'm thinking you're trying to convert a "timespan" to a "time". Try adding it to a time like this: SELECT '0:00:00'::time + '02:10:06'::timespan; Mark "Brian C. Doyle" wrote: > > Hello all, > > I have a query result of @ 2 hours 10 mins 6 secs and I

[SQL] NULL function arguments?

2000-08-21 Thread Mark Volpe
It seems that why I provide a NULL argument to a PL/pgSQL function it makes the rest of the arguments NULL, too! Consider this function: CREATE FUNCTION callme(text, text) RETURNS boolean AS ' BEGIN RAISE NOTICE ''$1: %'', $1; RAISE NOTICE ''$2: %'', $2;

Re: [SQL] select an entry with a NULL date field

2000-08-14 Thread Mark Volpe
The syntax you're looking for is: SELECT entry_id FROM tbl_date WHERE date_02 IS NULL; Mark Web Manager wrote: > > Hello, > > I have a problem with PostgreSQL when I try to select or delete an entry > with an empty date. That's a typical entry > > Table tbl_date > ---

Re: [SQL] Rules aren't doing what I expect

2000-08-11 Thread Mark Volpe
Tom Lane wrote: > > Queries added by non-INSTEAD rules are always performed before the > initially-given query, so you're right, the rule will see the unmodified > value. > > I'd suggest folding the log-entry-making into your trigger, actually. > If you have a trigger anyway then the insert into

Re: [SQL] Rules aren't doing what I expect

2000-08-10 Thread Mark Volpe
The actual trigger function I'm working with is over two screens long and rather expensive to be calling twice! Perhaps I need to add another trigger that updates the log table with the correct values after the fact. Recursive triggers, fun! Thanks for the help, Mark Ang Chin Han wrote: > > Eit

[SQL] Rules aren't doing what I expect

2000-08-09 Thread Mark Volpe
Hi again, I have a table with a trigger that can potentially modify a row before it gets inserted or updated: CREATE TABLE t1 (a int); CREATE FUNCTION t1_validate() RETURNS opaque AS ' BEGIN IF (NEW.a>10) THEN NEW.a=10; END IF;

Re: [SQL] foreign key take too much time to check

2000-08-07 Thread Mark Volpe
Try creating the tables without the constraint first, then populate them, and then add the foreign key constaint as the last step using ALTER TABLE/ADD CONSTRAINT. Mark Jie Liang wrote: > > Hi, there, > > I want add a constraint to my tables: > I have 2 tables: > 1. Table_A(id int 4 primary k

Re: [SQL] PL/pgSQL evaluation order

2000-08-03 Thread Mark Volpe
Doesn't seem like a bad idea. I did find a better workaround, though - cond:=TG_OP=''INSERT''; IF cond=FALSE THEN cond:=NEW.ip!=OLD.ip; END IF; IF cond=TRUE ... so it won't kill me. Anyway, I've been totally impressed with the 7.0 release. I'm building the EPA IP address registration sys

[SQL] PL/pgSQL evaluation order

2000-08-03 Thread Mark Volpe
Hi, I have trigger function with the statement: IF TG_OP=''INSERT'' OR NEW.ip!=OLD.ip THEN expecting the TG_OP=''INSERT'' to be evaluated first, and if true, proceed with the body. But it gets evaluated as the result of an INSERT statement, I get a (rather strangly worded) error: ERROR: record

[SQL] Re: PL/pgSQL

2000-08-03 Thread Mark Volpe
Oh yeah, I'm using v7.0 Mark

Re: [SQL] SQL (table transposition)

2000-08-03 Thread Mark Volpe
Hope you like black magic :) SELECT IND AS T1_INDEX, MIN(CASE WHEN KEY=1 THEN VALUE ELSE NULL END) AS KEY1VAL, MIN(CASE WHEN KEY=2 THEN VALUE ELSE NULL END) AS KEY2VAL, MIN(CASE WHEN KEY=3 THEN VALUE ELSE NULL END) AS KEY3VAL FROM T2 GROUP BY IND ORDER BY IND; Mark [EMAIL PROTECTED] wrote: > >