Feature #4984
Composite Type Argument as table
Status:
In Progress
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Description
creating composite type argument named table:
CREATE TABLE employee (name text, basesalary integer, bonus integer);
CREATE TABLE employee_ext (name text, basesalary integer, bonus integer, other text);
CREATE FUNCTION empcomp(table) RETURNS integer AS $$ return $argsr0['basesalary'] + $argsr0['bonus']; $$ LANGUAGE 'plphp';
SELECT name, empcomp(table) FROM employee;
SELECT name, empcomp(table) FROM employee_ext;
eg. type table is table taken from FROM (so once time will be employee, second time employee_ext)
now i must have x functions to do same thing with different argument
Updated by Álvaro Herrera about 19 years ago
- Status changed from New to In Progress
Interesting. Please note that you can do part of it using RECORD as the input type:
CREATE FUNCTION empcomp(RECORD) RETURNS ...
However it doesn't actually help you because the input record is a parenthized string with all fields separated by commas and you'd have to parse it. (Try doing a
zval_debug_dump($args);to see it.)
I'll take a look at what's needed to make it work as expected. Don't hold your breath though.