Feature #4984

Composite Type Argument as table

Added by bford - 12/15/2005 (about 16 years) ago. Updated 05/21/2011 (over 10 years) ago.

Status:In ProgressStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
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

History

#1 Updated by Álvaro Herrera 12/19/2005 (about 16 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.

#2 Updated by bford - 12/20/2005 (about 16 years) ago

great thank you

#3 Updated by Álvaro Herrera 03/12/2010 (almost 12 years) ago

  • Assignee deleted (Álvaro Herrera)

#4 Updated by Álvaro Herrera 05/21/2011 (over 10 years) ago

  • Priority changed from Low to Normal

Also available in: Atom PDF