473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

composite types

I'd like to compute some "row like" results and return them from a
function (and pass the result to PHP[*]).

Well I've read about composite type but all the references I've seen
are about coding in C. That's not the way I'd like to follow by now.

I was expecting to declare composite types in plpsql or plain sql in a
similar way I'd do in C/C++ with struct/class.

I've found this
http://archives.postgresql.org/pgsql...3/msg01459.php
but I'd like to avoid to declare a table just for a temp.

pseudocode follow

declare struct pippo(
integer a;
varchar(8) b;
)

create or replace function functiontest( ) returns pippo
as '
declare
integer tempa;
varchar(8) tempb;

begin
/*
do stuff to fill tempa and tempb
*/
return (tempa,tempb)
end
' language plpgsql;
[*] I guess that to access the result of such a function
....
$SQLResult = pg_exec( $SQLConn, "SELECT functiontest( );" );
$SQLData = pg_fetch_row( $SQLResult, 0 );
should be enough...

thx

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
4 1785
Ivan Sergio Borgonovo wrote:
I've found this
http://archives.postgresql.org/pgsql...3/msg01459.php
but I'd like to avoid to declare a table just for a temp.

pseudocode follow

declare struct pippo(
integer a;
varchar(8) b;
)

create or replace function functiontest( ) returns pippo
as '
declare
integer tempa;
varchar(8) tempb;


I think you might want to look at SRFs (Set Returning Functions). Here
are a couple of links:

http://techdocs.postgresql.org/guide...rningFunctions
http://www.varlena.com/varlena/GeneralBits/26.html


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2
Ivan Sergio Borgonovo wrote:
I've found this
http://archives.postgresql.org/pgsql...3/msg01459.php
but I'd like to avoid to declare a table just for a temp.

pseudocode follow

declare struct pippo(
integer a;
varchar(8) b;
)

create or replace function functiontest( ) returns pippo
as '
declare
integer tempa;
varchar(8) tempb;


I think you might want to look at SRFs (Set Returning Functions). Here
are a couple of links:

http://techdocs.postgresql.org/guide...rningFunctions
http://www.varlena.com/varlena/GeneralBits/26.html


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3
On Tue, 20 Apr 2004 17:41:30 +0200
Ivan Sergio Borgonovo <ma**@webthatworks.it> wrote:
I'd like to compute some "row like" results and return them from a
function (and pass the result to PHP[*]).

Well I've read about composite type but all the references I've seen
are about coding in C. That's not the way I'd like to follow by now.

I was expecting to declare composite types in plpsql or plain sql in
a similar way I'd do in C/C++ with struct/class.


<shame>
http://pgsqld.active-venture.com/sql-createtype.html
This seems more like what I was looking for.
</shame>

I'll do some tests tomorrow and get back to the list if it isn't what
I was looking for.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #4
On Tue, 20 Apr 2004 17:41:30 +0200
Ivan Sergio Borgonovo <ma**@webthatworks.it> wrote:
I'd like to compute some "row like" results and return them from a
function (and pass the result to PHP[*]).

Well I've read about composite type but all the references I've seen
are about coding in C. That's not the way I'd like to follow by now.

I was expecting to declare composite types in plpsql or plain sql in
a similar way I'd do in C/C++ with struct/class.


<shame>
http://pgsqld.active-venture.com/sql-createtype.html
This seems more like what I was looking for.
</shame>

I'll do some tests tomorrow and get back to the list if it isn't what
I was looking for.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: AshifToday | last post by:
this was my and my frineds little project in earlier classes, the program seperates the composite and prime numbers in two sections of the screen ===================== /* This program has...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
4
by: Ismail Rajput | last post by:
Is there any option we can use Composite DataKeyField in the DataList and DataGrid?
0
by: Ivan Sergio Borgonovo | last post by:
I'd like to compute some "row like" results and return them from a function (and pass the result to PHP). Well I've read about composite type but all the references I've seen are about coding in...
1
by: lists | last post by:
When using the (tbl).field notation for selecting a specific field from a composite field then the query returning the field is executed once per field. An example is giving below. The runtime is...
0
by: ma740988 | last post by:
Given a composite type such that: struct tp2 { unsigned int val1; tp2 () : val1(0) {} };
2
by: pkpatil | last post by:
Hi, Can a private composite object in a class access private or protected members of base class? For e.g. class composite { void memberFunction(); };
14
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or...
1
by: ma740988 | last post by:
Consider the source snippet. # include <iostream> struct foo_struct { int odx ; int pdx ; foo_struct () : odx ( 0 ) , pdx ( 0 )
4
by: Wolfgang Keller | last post by:
Hello, so far it seems to me as if the only ORM module for Python which supports composite primary/foreign keys was SQLAlchemy. Which looks a little bit "overbloated" for my needs: I "just" need...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.