Project

General

Profile

Feature #4984

Composite Type Argument as table

Added by bford - over 18 years ago. Updated almost 13 years ago.

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

#1

Updated by Álvaro Herrera about 18 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 - about 18 years ago

great thank you

#3

Updated by Álvaro Herrera about 14 years ago

  • Assignee deleted (Álvaro Herrera)
#4

Updated by Álvaro Herrera almost 13 years ago

  • Priority changed from Low to Normal

Also available in: Atom PDF