Hi all.
I've searched for postgresql and read the manual till I'm crosseyed... and no joy..
Basically... can you create variable SQL functions?
In my php I want to call some sql functions.
I can do that by:
$sSQL = "retire('filename', 'idname', idvalue);";
ExecuteQuery($sSQL);
where filename and idname are text / varchar and idvalue is int4.
My problem is in the defintion.
Is it possible to create SQL/ postgresql functions that use variables?
ie
CREATE FUNCTION retire(text, text, int4) RETURNS int4 AS'
BEGIN
UPDATE $1 set "Retired" = 'true' where $2 = $3;
SELECT (something for return value);
END;'
LANGUAGE 'SQL';
(or 'plpgsql')
This comes back with:
parse error at or near "true"
I've created functions before... but they only seem to work if I define the filename and idname.
ie
CREATE FUNCTION retire(int4) RETURNS int4 AS'
BEGIN
UPDATE "FileName" set "Retired" = 'true' where "IDName" = $1;
SELECT (something for return value);
END;'
LANGUAGE 'SQL' (or 'plpgsql');
But I want to call the same function for different files!!
any ideas or pointers??
Thanks
Beth