[SQL] FIND_IN_SET

2009-12-11 Thread Michael Eshom
I am on the marketing team for a popular forum system, and am also the 
primary PostgreSQL tester/bugfixer. Currently our forum system treats 
MySQL's FIND_IN_SET() as a boolean (eg whether or not the specified 
value was found in the given set), which is fine since MySQL will treat 
any integer greater than 0 as boolean true and 0 as boolean false. I 
have already managed to write a FIND_IN_SET() function for Postgres that 
behaves as boolean. However, we would like to be able to use the true 
functionality of this function (so it will return an integer instead of 
boolean).


This is where I've run into a problem. The mysqlcompat package has a 
FIND_IN_SET() in it, but it requires plpgsql, and I'd rather not require 
something that a regular user can't install themselves, regardless of 
how simple it is for the host to add it.


I did find another version of FIND_IN_SET() on a blog with several other 
MySQL-compatible functions, and while it uses regular SQL, it requires 
the generate_subscripts() function which isn't available in Postgres 8.1 
- the latest version officially supported by CentOS.


Is there a way to do this without requiring plpgsql or generate_subscripts?
--
Michael "Oldiesmann" Eshom
Christian Oldies Fan
Cincinnati, Ohio


[SQL] Adding NOT NULL columns in PostgreSQL 7.4?

2007-08-07 Thread Michael Eshom
I'm currently using PostgreSQL 7.4.17, and trying to add a NOT NULL 
column results in an error about "Adding NOT NULL columns is not 
implemented". The only reports of this error I can find online relate to 
PostgreSQL 7.2, and further state that it was supposed to be implemented 
in PostgreSQL 7.3, so I can't figure out why it's still saying it's not 
implemented.

--

Michael Eshom
Christian Oldies Fan
Cincinnati, Ohio



[SQL] Unable to create function which takes no arguments

2008-06-09 Thread Michael Eshom
I am a project manager for a popular forum system. We are adding support 
for PostgreSQL in the next version (which is currently in beta), and 
have added several PostgreSQL functions to emulate MySQL functions of 
the same name.


I am trying to create a "UNIX_TIMESTAMP()" function in PostgreSQL, which 
will return the current timestamp. However, whenever I try to add this 
function in phpPgAdmin, it says 'Syntax error at or near ")" at 
character 28'.


This is the SQL I'm using:

CREATE FUNCTION unix_timestamp() RETURNS integer AS '
SELECT current_timestamp()::int4 AS result;
' LANGUAGE SQL;


The documentation indicates that the arguments are optional, and even 
shows an example of a function with no arguments. How can I create this 
function?

--

Michael Eshom
Christian Oldies Fan
Cincinnati, Ohio