Re: [SQL] Updating a specific number of rows in pl/pgsql

2009-08-11 Thread D'Arcy J.M. Cain
queue_id FROM queue WHERE id = p_queue_id ORDER BY rank LIMIT p_number_of_items); -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] Grass Root Protectionism

2009-02-08 Thread D'Arcy J.M. Cain
? What's next? Only help white folks? -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- Sent via pgsql-sql mailing list (pgsql-sql

Re: [SQL] Grass Root Protectionism

2009-02-08 Thread D'Arcy J.M. Cain
On Sun, 08 Feb 2009 10:39:26 -0500 Tom Lane t...@sss.pgh.pa.us wrote: D'Arcy J.M. Cain da...@druid.net writes: What's next? Only help white folks? This guy doesn't really deserve being responded to. Just ignore him. Yes, as I was hitting the send key I wondered if he was just a troll

Re: [SQL] MAY I HAVE YOUR ASSISTANCE

2008-09-01 Thread D'Arcy J.M. Cain
need MD5 or Blowfish it wouldn't be very hard to modify the code. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- Sent via pgsql-sql

Re: [SQL] Problem with FOREIGN KEY

2008-04-22 Thread D'Arcy J.M. Cain
the rule that you are trying to enforce with the new constraint. Also, I am pretty sure that you do not want the constraint FK1_SecurityRolePermission that you created on SecurityRole. What do you think that will accomplish? -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread D'Arcy J.M. Cain
On Tue, 18 Mar 2008 13:57:39 -0700 Steve Midgley [EMAIL PROTECTED] wrote: At 12:36 PM 3/18/2008, D'Arcy J.M. Cain wrote: On Tue, 18 Mar 2008 12:23:35 -0700 Steve Midgley [EMAIL PROTECTED] wrote: 1) Create a second field (as someone recommend on this list) that is an MD5 of your primary

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread D'Arcy J.M. Cain
and I hope the OP finds your input and mine useful in coming up with a final answer to his issue. Thanks for taking the time to consider the issue and I'll look forward to any additional ideas or comments you have on this too! Yes, discussion is always useful, and fun. :-) -- D'Arcy J.M

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread D'Arcy J.M. Cain
, what is the purpose of this? I suspect that this is either a homework problem or you may be attacking some real-world problem from the wrong angle. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread D'Arcy J.M. Cain
the error message should be that someone in the system already has the password that you tried to use? -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread D'Arcy J.M. Cain
on a calculation then you can't change that one person's security code. Generate a random number and store that. You will be much happier when something goes wrong and something always goes wrong. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] Bouncing replies [was: SQL standards in Mysql]

2008-02-25 Thread D'Arcy J.M. Cain
and Siegel! -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 2

Re: [SQL] Double query

2008-02-06 Thread D'Arcy J.M. Cain
and second but if you mean that you want a list of all clinics that match the clinic ID and you want to know of all of those which ones have the specified date then perhaps this is what you want. SELECT id, date = '%s' FROM schedule WHERE clinic_id = '%s'; -- D'Arcy J.M. Cain [EMAIL PROTECTED

Re: [SQL] transaction and triggers

2008-01-18 Thread D'Arcy J.M. Cain
different generator systems. Hope this gets you started. There's still lots of gotchas on the way. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's

Re: [SQL] Query Assistance

2007-12-12 Thread D'Arcy J.M. Cain
. :-) -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 7: You can help

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread D'Arcy J.M. Cain
to program defensively. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread D'Arcy J.M. Cain
-key field(s). - The primary key must be compact and contain the fewest possible attributes. - The primary-key value can?t be changed. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread D'Arcy J.M. Cain
be the primary key and have NULLs. It sounds to me like you have a design problem somewhere. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] fetch first rows of grouped data

2007-08-27 Thread D'Arcy J.M. Cain
not be a single query: - Select into temp table where date is max. - Select from temp table union with main table where date is max and is not in temp table. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep

Re: [SQL] How do I connect postgres table structures and view structures to an existing svn repository?

2007-08-01 Thread D'Arcy J.M. Cain
? -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 3: Have you

Re: [SQL] How do I connect postgres table structures and view structures to an existing svn repository?

2007-08-01 Thread D'Arcy J.M. Cain
need to check for irrelevant changes in the dump before calling svn. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] How do I connect postgres table structures and view structures to an existing svn repository?

2007-08-01 Thread D'Arcy J.M. Cain
that is changed ad hoc with no design work beforehand. If you work from the design side first you can create schema documents that feed your database creation and use svn to save those versions and document exactly why things changed. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three

Re: [SQL] import CSV file

2007-03-13 Thread D'Arcy J.M. Cain
-- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 4: Have you

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

2007-01-30 Thread D'Arcy J.M. Cain
J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 1: if posting/reading

Re: [SQL] Table relationships

2007-01-09 Thread D'Arcy J.M. Cain
to the head office. There are many possibilities. Which one is best will depend on analysing your particular business model. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082

Re: [SQL] Table relationships

2007-01-09 Thread D'Arcy J.M. Cain
On Tue, 9 Jan 2007 09:13:35 -0600 Aaron Bono [EMAIL PROTECTED] wrote: On 1/9/07, D'Arcy J.M. Cain darcy@druid.net wrote: company === address === detail This approach implies that the address defines the relationship between a company and the detail (the other departments/offices). I

Re: [SQL] PostgreSQL server terminated by signal 11

2006-07-27 Thread D'Arcy J.M. Cain
or slot-tts_tupleDescriptor. If the first shows a non NULL value and the second causes your crash that tells you that the value of slot is probably trashed before calling the function. Do this in conjunction with Tom Lanes suggestion of --enable-debug for more information. -- D'Arcy J.M. Cain darcy

Re: [SQL] Alternative to serial primary key

2006-07-07 Thread D'Arcy J.M. Cain
coming out of this with something interesting, even if it isn't what you went in looking for. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] Alternative to serial primary key

2006-07-06 Thread D'Arcy J.M. Cain
immediately raises the hairs on the back of my neck. If the primary key can ever change, you have a broken schema. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] Question about One to Many relationships

2006-03-24 Thread D'Arcy J.M. Cain
? Otherwise, I can't see anything wrong from a relational database POV. What are people saying is wrong about it? -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] Question about One to Many relationships

2006-03-24 Thread D'Arcy J.M. Cain
requirements. That may be more complicated, simpler or both than we know now. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] Another orderby problem

2006-01-14 Thread D'Arcy J.M. Cain
. if year 50: year += 2000 elif year 100: year += 1900 That will probably handle most cases for you. Alternatively, don't allow dates outside of your known domain. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] DATESTYLE and 0000-00-00

2005-10-06 Thread D'Arcy J.M. Cain
date? It is invalid. There was no year 0. Perhaps what you want is NULL or, possibly, EPOCH if you are looking for a sentinel value. -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
AND pg_index.indisprimary='t' AND pg_index.indkey[0]=pg_attribute.attnum -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
[7]=pg_attribute.attnum OR pg_index.indkey[8]=pg_attribute.attnum OR pg_index.indkey[9]=pg_attribute.attnum ) ORDER BY pg_namespace.nspname, pg_class.relname,pg_attribute.attname; -- D'Arcy J.M. Cain darcy@druid.net | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] sql can i substitute

2004-12-17 Thread D'Arcy J.M. Cain
| rotten SELECT fstate.fstate_name AS Fruit state FROM table, fstate WHERE table.fstate_id = fstate.fstate_id; Now you can easily add another state: INSERT INTO fstate VALUES (4, 'smelly'); -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] question about index

2004-12-16 Thread D'Arcy J.M. Cain
and usage but this may be a better solution for you. As usual, if not completely satisfied you get a full refund. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] parse error at or near ( -- Huh???

2004-12-13 Thread D'Arcy J.M. Cain
is a sample (Unix) command line that I commonly use to run statements from a file: psql table -f in.file -e out.file 21 Now I can search the file for ERROR and see exactly what preceded it. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] query using a date field that isn't set

2004-11-07 Thread D'Arcy J.M. Cain
with IS NULL and IS NOT NULL. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast

Re: [SQL] third edition of SQL FOR SMARTIES

2004-11-07 Thread D'Arcy J.M. Cain
a few things to contribute but it would help to see what's already there. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner

Re: [SQL] Anti log in PostgreSQL

2003-12-27 Thread D'Arcy J.M. Cain
. And make sure that you check your local rules. Mortgages are actually calculated differently in Canada and the US. -- D'Arcy J.M. Cain [EMAIL PROTECTED]|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] URGENT!!! changing Column size

2003-10-28 Thread D'Arcy J.M. Cain
On Tuesday 28 October 2003 08:28, Franco Bruno Borghesi wrote: Dopping the whole database just for a column change? I guess some people have really small databases that don't take 3 days to dump and reload. :-) -- D'Arcy J.M. Cain [EMAIL PROTECTED]|vex}.net | Democracy is three wolves

Re: [SQL] vacuum and serial primary keys

2003-02-01 Thread D'Arcy J.M. Cain
that changes your primary key without an explicit command to do so. In fact, sometimes I think that the database should enforce the rule that primary keys are immutable and not even allow it explicitely. Perhaps a configuration option. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy

Re: [SQL] Function for adding Money type

2003-01-26 Thread D'Arcy J.M. Cain
the number of decimal places on output but I am not sure if that would affect the primary benefit of using it, speed. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] Selecting a non-locked row.

2003-01-19 Thread D'Arcy J.M. Cain
they released it with an ABORT, the number simply became available again to the next process. I'm not sure how to do something like that without the ability to exclude locked records from the query or else with an atomic compare and set function. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy

Re: [SQL] cannot create function that uses variable table name

2003-01-17 Thread D'Arcy J.M. Cain
= 'account2' ORDER BY dsply_order; This should give you exactly the same result: SELECT * FROM files WHERE accountid = 'account2' ORDER BY fileid. It all depends on what problem exactly you are trying to solve of course. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-07 Thread D'Arcy J.M. Cain
couldn't find anything in the docs or web specifically about this. Does anyone have any ideas? Adding hackers as this may be an internal issue. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425

[SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread D'Arcy J.M. Cain
lock the entire certificate table? Is there something strange because of the IN clause or because it is going into a temporary table? This is a production server running 7.2.2 so perhaps it is fixed in 7.3. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http

Re: [SQL] Using Tables from another database.

2002-07-26 Thread D'Arcy J.M. Cain
. It's on the TODO list. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast

Re: [SQL] Out of free buffers... HELP!

2001-09-18 Thread D'Arcy J.M. Cain
but perhaps you need another table instead of/in addition to this one that just tracks the counts. You can use a trigger to increment it. If you only allow inserts this should be easy. Deletes are easy too. Updates are a little trickier. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three

Re: [SQL] Primary vs Unique Index

2001-08-21 Thread D'Arcy J.M. Cain
. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast)--- TIP 5: Have you

Re: [SQL] Get the tables names?

2001-07-22 Thread D'Arcy J.M. Cain
is to avoid getting the PostgreSQL internal tables in the output. Further, to only get tables and not views, indexes, sequences, etc you can do this. SELECT tablename FROM pg_tables WHERE relkind = 'r' AND tablename NOT LIKE '%pg_%'; -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy

Re: [SQL] How to encode and decode password in pgsql !!

2001-05-04 Thread D'Arcy J.M. Cain
/pgsql/contrib/chkpass/. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. ---(end of broadcast

Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread D'Arcy J.M. Cain
x WHERE i = 2; ?column? -- f (1 row) darcy=# SELECT i, raw(p) FROM x; i | raw ---+--- 1 | SoLA2YFpQYV/I 2 | Sg8CKkFqqTGec (2 rows) -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy

Re: [SQL] serial type; race conditions

2001-03-30 Thread D'Arcy J.M. Cain
er will be increased to 11. If your transaction is rolled back then you may have a hole if someone else used a number but it will be filled the next time that someone requests a number from that sequence. They aren't strictly speaking consecutive but they are complete. -- D'Arcy J.M. Cain d

Re: Fwd: Re: [SQL] sum(bool)?

2001-02-25 Thread D'Arcy J.M. Cain
CREATE FUNCTION bool2int(bool) RETURNS integer AS 'select (case when $1=true then 1 else 0 end)' LANGUAGE 'sql'; You can do: sum(bool2int(ab)) easy ??? ;-)) Almost as easy as "SELECT COUNT(*) FROM table WHERE a b" -- D'Arcy J.M. Cain darcy@{druid|vex}.net |

Re: [SQL] Create Primary Key?

2000-08-30 Thread D'Arcy J.M. Cain
the primary key and use it. Is there syntax to create a primary key after the table has been defined and populated? I think I could speed things up quite a bit by not having any indexes at all when I do my mass copies. Why not just use the copy function? That's what it's for. -- D'Arcy J.M. Cain

Re: [SQL] Select by priority again

2000-07-24 Thread D'Arcy J.M. Cain
PostgreSQL? I do this in a view and it works. SELECT CASE WHEN login IS NULL THEN uid::text ELSE login END AS login FROM account; -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212

Re: [SQL] Merging two columns into one

2000-06-23 Thread D'Arcy J.M. Cain
# one column and split out parts with various functions. Don't forget to have a place for country code and extension. -- D'Arcy J.M. Cain darcy@{druid|vex}.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP

Re: [SQL] Using substr with user defined types

2000-06-23 Thread D'Arcy J.M. Cain
operator stuff from the docs (I needed scalar??sel instead of int??sel) and now everything I had before plus the chkpass stuff works. I'll send the corrected chkpass stuff for contrib and work on that phone number item I mentioned in another message. -- D'Arcy J.M. Cain darcy@{druid|vex}.net |