Re: Oracle Style packages on postgres

Thomas Hallgren <thhal@mailblocks.com>

From: Thomas Hallgren <thhal@mailblocks.com>
To: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, rmm@sqlisor.com, pgsql-hackers@postgresql.org
Date: 2005-05-10T14:34:23Z
Lists: pgsql-hackers
Bruce Momjian wrote:

>Thomas Hallgren wrote:
>  
>
>>Bruce Momjian wrote:
>>    
>>
>>>Josh Berkus wrote:
>>>
>>>      
>>>
>>>>I think that private variables and private functions need to be part of the 
>>>>definition.
>>>>        
>>>>
>>>OK, so it seems we need:
>>>
>>>	C static/private functions for schemas
>>>	C static/private variables for schemas
>>>
>>>Are private variables implemented via the temporary per-session schema?
>>>
>>>	nested schemas
>>>
>>>What does the standard say?
>>>
>>>      
>>>
>>The standard says that rather then using nested schemas or packages in 
>>conjunction with functions in order to group functions with data, use 
>>user defined types with attributes and methods. Methods can be STATIC, 
>>INSTANCE or CONSTRUCTOR.
>>    
>>
>
>So it sounds like you group the functions into user-defined types,
>rather than nested schemas.
>
Yes, you'd get <schema>.<type>.<method> as the fully qualified name.

>  So you assocate functions with a table?
>  
>
Not necessarily a table. A type is just a type. A type containing just 
static methods is not very different from an Oracle package. A table 
created from a type may of course have methods associated with it. That 
gets really interesting when you use INSTANCE methods. They act on a per 
row basis so that you can do things like:

SELECT x.someMethod() FROM someTable x;

rather than as today.

SELECT someFunction(x) FROM someTable x;

Regards,
Thomas Hallgren