[SQL] Re: Cascading Deletes

2000-09-06 Thread K Parker

> 1. re_create your table set _ID as primary key 

This is not going to work unless a parent is prohibited from having more than one 
child.  From the brief sample data supplied, this is clearly not the case.




Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



[SQL] Re: many-to-many mapping

2000-10-16 Thread K Parker

Am I the only one who's nervous about these
two tables referencing each other like this?
I would have a concern that this is being
imposed, perhaps, by some external format
that the data arrives in, and that a
decently normalized design will have a
simple all-key table containing nothing
but serial # id's from both primary
tables.




Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



Re: [SQL] fetching rows

2000-10-30 Thread K Parker

I hate to be the bearer of bad news, but if you're using PHP and you wanted to fetch 
just 25 rows at a time for a single page, and then fetch more when the user clicks on 
a NEXT button or link, you're completely out of luck.  Each http transaction is 
completely separate and so you can't maintain a cursor between pages.  Perhaps LIMIT 
would help you here; but I've found it more useful to make sure there is a unique key 
for the order I'm displaying, and then say "WHERE key > 
highest_key_value_on_current_page"




Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



RE: [SQL] INSERT [IGNORE] INTO TABLE

2000-10-31 Thread K Parker

>Not a good feature for me.

Me neither, but...

>Check existence and then insert or update.

At least once a week I seem to be responding to this exact same suggestion.  Somebody 
_please_ tell me if I'm the only one in the whole world who worries about race 
conditions?  What's wrong with just making sure there's a proper unique key, and then 
just inserting the row?  The returned error message will tell you if a failure is due 
to duplicate key, missing non-null column, or an actual disaster.



Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



[SQL] Re: unique sequences

2000-06-26 Thread K Parker

> Rather, each time you wish to do an insert,
> query the existing data to see what the
> maximum value is existing in the database.
> Add 1 to that and use this as your new value.
> This is guaranteed to not have any holes in
> the sequence.

True, but alas it _doesn't_ guarantee uniqueness, since there's nothing to prohibit 2 
or more back ends getting the same max() at the
same time...

Thinking off the top of my head, I'm not sure you can apply FOR UPDATE to an aggregate 
function, so there's probably no solution there, either.



Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



[SQL] Re: Wildcard in date field

2000-06-23 Thread K Parker

The suggest solution works:

>  SELECT  * FROM my_table WHERE
>  date_part('month', col_name::datetime) = '06' 
>  AND date_part('year', col_name::datetime) =
>  '2000';

But you can also just do a comparison:

  where col_name >= '2000-06-01' AND col_name <= '2000-06-30'

Using the correct date format for your environment, of course.



Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com



[SQL] Re: m4 macros plus PostgreSQL anyone?

2000-07-09 Thread K Parker

No advice, just a big question: why M4?

I've made great use of M4 myself for gluing a constant- and macro-defining capability 
to languages that don't have such (even Foxpro--no, no, please don't ask!) but in this 
day and age perl would be far more expressive and capable for the things you are 
trying to do, wouldn't it?  



Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at 
http://www.eudoramail.com