473,386 Members | 1,758 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,386 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 1786
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.