Re: [SQL] Convert numeric to money

2005-07-25 Thread Mauricio Fernandez
inspect your cast functions with: create view showcasts as select t.typname as source, t1.typname as target, p.proname as function, (select case when c.castcontext = 'e' then 'Must use Explicit Cast' else ( select case when c.castcontext = 'i' then 'Implicit cast f

[SQL] int to date

2005-07-25 Thread Daniel Drotos
Hi, I have a string containing hexa dump of an 4 bytes integer, like '6AF4805C'. Is it possible to convert it somehow to date type in plpgsql (v8.0.0-rc1)? Doc says that date is represented as 4 bytes internaly. How can I get internal representation of a date type field? So I would be able

Re: [SQL] int to date

2005-07-25 Thread Bruno Wolff III
On Mon, Jul 25, 2005 at 10:54:42 +0200, Daniel Drotos <[EMAIL PROTECTED]> wrote: > Hi, > > I have a string containing hexa dump of an 4 bytes integer, like > '6AF4805C'. Is it possible to convert it somehow to date type in > plpgsql (v8.0.0-rc1)? Doc says that date is represented as 4 bytes >

[SQL] update vs unique index

2005-07-25 Thread jacekp
Consider such table: CREATE TABLE test (idx integer); populated by following statements: INSERT INTO test VALUES (1); INSERT INTO test VALUES (2); INSERT INTO test VALUES (3); since idx schould be unique, we need an index CREATE UNIQUE INDEX i_test ON test(idx); Following SQL command fails:

Re: [SQL] update vs unique index

2005-07-25 Thread Alvaro Herrera
On Mon, Jul 25, 2005 at 05:58:43AM -0700, [EMAIL PROTECTED] wrote: > I can imagine why it fails. Update operates on first row, making 2 out > of 1 and that collides with second row (which has 2 as its value > already). However, when you look at the update efect as a whole > uniqueness is preserved

[SQL] Closes Match

2005-07-25 Thread Christian Rusa
Hi there, I want to match a string against the database and get the closest (shorter) match. I was asking myself if its possible to realise this in SQL. So if the string is: abcdefg And in the database are entries like: a ab abc I just want to get back 'abc'. I looked around in the internet

Re: [SQL] Closes Match

2005-07-25 Thread Bruno Wolff III
On Mon, Jul 25, 2005 at 19:31:11 +0200, Christian Rusa <[EMAIL PROTECTED]> wrote: > Hi there, > > I want to match a string against the database and get the closest > (shorter) match. > I was asking myself if its possible to realise this in SQL. > > So if the string is: > abcdefg > > And in th

Re: [SQL] Closes Match

2005-07-25 Thread Jonathan Lam
unsubscribe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bruno Wolff III Sent: Monday, July 25, 2005 10:50 AM To: Christian Rusa Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Closes Match On Mon, Jul 25, 2005 at 19:31:11 +0200, Christian Rusa <[EMAI