Re: [SQL] Casting integer to boolean

2002-08-16 Thread Tod McQuillin
On Fri, 16 Aug 2002, Bhuvan A wrote: > How do i cast an integer value to boolean? You can always do something like this: select not count(*) = 0 from my_table; Basically, for any integer i, convert to boolean with: not i = 0 -- Tod McQuillin ---(end of broadc

Re: [SQL] is there a way to get hh:mm:ss given seconds

2002-07-09 Thread Tod McQuillin
On Mon, 8 Jul 2002, Narendra A wrote: > Is there a way in sql such that if I give seconds it should me return me > hours:mins:seconds > > Eg. Seconds hh:mm:ss > 422 1:01:02 foo=# select '422 seconds'::interval; interval -- 00:07:02

Re: [SQL] Intentional, or bug?

2001-09-16 Thread Tod McQuillin
here a and b are both NULL, you must specify it precisely: where a = b or (a is null and b is null) > So, is it an intentinal way of functioning, or it is bug somewhere? This is how it is supposed to work. -- Tod McQuillin ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Eh?

2001-08-13 Thread Tod McQuillin
ements, 11 > subselects, 35 JOINS, and calls on 3 custom formatting functions ... This makes me wonder... in the case of a stored complex view, would it be helpful to ask PostgreSQL to spend extra time in query optimisation and then cache the result? Or does it do this alre

Re: [SQL] Select distinct and order by.

2001-07-17 Thread Tod McQuillin
it was a mistake to rely on it because the answer is undefined. -- Tod McQuillin ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Stored Procedures?

2001-05-24 Thread Tod McQuillin
x27;t need to return a value just pick a random small result type (like bool, or int) return NULL, and ignore the return value. Usually I return a value even from procedural functions though just to indicate if things went ok or not. -- Tod McQuillin ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl

Re: [SQL] how to check presence of a function and set permissions?

2001-05-21 Thread Tod McQuillin
eries in plpgsql since v7.1 -- EXECUTE 'SELECT * FROM ' || table_name || ' WHERE whatever'; However, I do not see it in the documentation, so now I'm not 100% certain. -- Tod McQuillin ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] nobody user can't nextval('phone_id_seq')

2001-04-14 Thread Tod McQuillin
key | integer | not null default nextval('foo_key_seq'::text) name | varchar(40) | not null test=# GRANT ALL ON foo_key_seq TO nobody; CHANGE -- Tod McQuillin ---(end of broadcast)-

Re: [SQL] syntax prob

2001-02-24 Thread Tod McQuillin
et c=d"; $sql = "update t " . implode(", ", $updates) . " where ..."; The join() and implode() functions make sure no comma is used if the updates array has fewer than two elements. Otherwise they stick commas between each one, just like sql wants. -- Tod McQuillin

Re: [SQL] sum(bool)?

2001-02-23 Thread Tod McQuillin
On Fri, 23 Feb 2001, Olaf Zanger wrote: > i'd like to add up the "true" values of a comparison like > > sum(a>b) > > it just doesn't work like this Try sum(case when a>b then 1 else 0 end) -- Tod McQuillin

Re: [SQL] Bug? Me or PostgreSQL.

2001-02-18 Thread Tod McQuillin
est language for picking random members of a set. You're better off picking a random number in a procedural language and passing that number as a constant to an embedded SQL query. -- Tod McQuillin

Re: [SQL] Bug with rules in 7.0.3?

2001-02-03 Thread Tod McQuillin
EATE RULE example_5 AS ON INSERT TO emp WHERE new.salary > 5000 DO UPDATE emp SET salary = 5000 WHERE emp.oid = new.oid; -- Tod McQuillin

[SQL] Bug with rules in 7.0.3?

2001-02-03 Thread Tod McQuillin
-- 1 | 2 |-1 2 | 2 |-1 3 | 2 |-1 (3 rows) How the heck can one insert and update generate three rows? -- Tod McQuillin

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-04 Thread Tod McQuillin
with the philosophy of a relational database?" ... My answer is yes! After all, isn't it just the same as "select a, count(a) from x group by a" turned sideways? If you can think of how to do this "the hard way" (i.e. without subselects or temp tables etc.) please share. -- Tod McQuillin

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-03 Thread Tod McQuillin
join the actual discussion about documentation > of PostgreSQL but I never before have seen such a construct in SQL! Subqueries are covered in Bruce Momjian's book: http://www.postgresql.org/docs/aw_pgsql_book/node93.html I don't think the PostgreSQL User's Manual mentions sub-selects. -- Tod McQuillin

Re: [SQL] OID Perfomance - another question

2000-10-03 Thread Tod McQuillin
pg_dump. -o Dump object identifiers (OIDs) for every table. -- Tod McQuillin

Re: [SQL] table as field type??

2000-10-03 Thread Tod McQuillin
uot;ERROR: Cannot cast type 'foo' to 'oid'" You can't seem to cast an oid into a foo either. -- Tod McQuillin

RE: [SQL] Object features of pg

2000-10-03 Thread Tod McQuillin
27;s better to use referential integrity checks if you want to ensure type checking like this (it will also ensure that the value pointed to actually exists in the referenced table). (see http://www.postgresql.org/docs/aw_pgsql_book/node153.html under PRIMARY KEY for details). -- Tod McQuillin