pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Urgent, bool-to-int patch possible?
3+ messages / 2 participants
[nested] [flat]

* Urgent, bool-to-int patch possible?
@ 1999-04-14 18:47 Matthew Hagerty <matthew@venux.net>
  1999-04-15 13:11 ` Re: [INTERFACES] Urgent, bool-to-int patch possible? José Soares <jose@sferacarta.com>
  1999-04-15 13:19 ` Re: [INTERFACES] Urgent, bool-to-int patch possible? José Soares <jose@sferacarta.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Matthew Hagerty @ 1999-04-14 18:47 UTC (permalink / raw)
  To: pgsql-interfaces

Greetings,

What would be the chances of getting a patch for 6.4.2 to do bool-to-int
conversion?  I need to do a query similar to this:


SELECT * FROM mytable ORDER BY 
int(col1 > 3) + int(col2 < 4) + ... other conditions;

(courtesy of Tom Lane)

Would it be that hard to make a patch to do the conversion?  I would try it
myself but I have no idea where to start looking, and I need this sooner
than I could probably figure it out.

I'm not making demands or stomping my feet, I love postgres and I
understand that it is free software, but if one of you feels really nice... :)

Thanks,
Matthew



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [INTERFACES] Urgent, bool-to-int patch possible?
  1999-04-14 18:47 Urgent, bool-to-int patch possible? Matthew Hagerty <matthew@venux.net>
@ 1999-04-15 13:11 ` José Soares <jose@sferacarta.com>
  1 sibling, 0 replies; 3+ messages in thread

From: José Soares @ 1999-04-15 13:11 UTC (permalink / raw)
  To: Matthew Hagerty <matthew@venux.net>; +Cc: pgsql-interfaces



Matthew Hagerty ha scritto:

> Greetings,
>
> What would be the chances of getting a patch for 6.4.2 to do bool-to-int
> conversion?  I need to do a query similar to this:
>
> SELECT * FROM mytable ORDER BY
> int(col1 > 3) + int(col2 < 4) + ... other conditions;
>
> (courtesy of Tom Lane)
>
> Would it be that hard to make a patch to do the conversion?  I would try it
> myself but I have no idea where to start looking, and I need this sooner
> than I could probably figure it out.
>
> I'm not making demands or stomping my feet, I love postgres and I
> understand that it is free software, but if one of you feels really nice... :)
>
> Thanks,
> Matthew

This function converts a bool to a smallint...

create function int2(bool) returns int2 as
'begin
        IF $1 THEN
            RETURN 1;
        ELSE
            RETURN 0;
        END IF;
 end;'   language 'plpgsql';

example:
     SELECT * FROM mytable ORDER BY
    int2(col1 > 3) + int2(col2 < 4) + ... other conditions;

-----
José





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [INTERFACES] Urgent, bool-to-int patch possible?
  1999-04-14 18:47 Urgent, bool-to-int patch possible? Matthew Hagerty <matthew@venux.net>
@ 1999-04-15 13:19 ` José Soares <jose@sferacarta.com>
  1 sibling, 0 replies; 3+ messages in thread

From: José Soares @ 1999-04-15 13:19 UTC (permalink / raw)
  To: Matthew Hagerty <matthew@venux.net>; +Cc: pgsql-interfaces

create function int(bool) returns int as
'
begin
        IF $1 THEN
            RETURN 1;
        ELSE
            RETURN 0;
        END IF;
 end;
' language 'plpgsql';


Matthew Hagerty ha scritto:

> Greetings,
>
> What would be the chances of getting a patch for 6.4.2 to do bool-to-int
> conversion?  I need to do a query similar to this:
>
> SELECT * FROM mytable ORDER BY
> int(col1 > 3) + int(col2 < 4) + ... other conditions;
>
> (courtesy of Tom Lane)
>
> Would it be that hard to make a patch to do the conversion?  I would try it
> myself but I have no idea where to start looking, and I need this sooner
> than I could probably figure it out.
>
> I'm not making demands or stomping my feet, I love postgres and I
> understand that it is free software, but if one of you feels really nice... :)
>
> Thanks,
> Matthew




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1999-04-15 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-14 18:47 Urgent, bool-to-int patch possible? Matthew Hagerty <matthew@venux.net>
1999-04-15 13:11 ` José Soares <jose@sferacarta.com>
1999-04-15 13:19 ` José Soares <jose@sferacarta.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox