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
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
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
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
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
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
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
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)-
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
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
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
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
--
1 | 2 |-1
2 | 2 |-1
3 | 2 |-1
(3 rows)
How the heck can one insert and update generate three rows?
--
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
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
pg_dump.
-o Dump object identifiers (OIDs) for every table.
--
Tod McQuillin
uot;ERROR: Cannot cast type 'foo' to 'oid'"
You can't seem to cast an oid into a foo either.
--
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
18 matches
Mail list logo