Brio returning data through stored procedures.

Brio returning data through stored procedures.

am 06.04.2007 01:05:53 von Doug Thom

This is a multi-part message in MIME format.

------_=_NextPart_001_01C777D6.F5B97538
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello, all,

=20

I am wondering if anybody knows how to return data to Brio through ODBC
from a function. If you are (or were) an Oracle user you may be familiar
with defining a ref cursor type and including that as an OUT parameter.
Brio then picks it up through ODBC and collects the results.

=20

When I tried this in many different ways in Postgres the best I could
get returned was either "" where x increments for the
number of times I tried it or what I passed in when I used the method
that allows me to have the calling procedure name the cursor. But no
data.

=20

If anybody has run into this challenge I would love to hear if you were
or were not successful. I'd really like to hear you were successful, of
course, but if there is no way to do it then there's no point me wasting
any more time with it.

=20

Thank you,

=20

-Doug


------_=_NextPart_001_01C777D6.F5B97538
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">


charset=3Dus-ascii">









style=3D'font-size:10.0pt;
font-family:Arial'>Hello, all,



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>I am wondering if anybody knows how to return data to =
Brio
through ODBC from a function. If you are (or were) an Oracle user you =
may be
familiar with defining a ref cursor type and including that as an OUT
parameter. Brio then picks it up through ODBC and collects the =
results.



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>When I tried this in many different ways in Postgres =
the
best I could get returned was either “<unnamed portal =
x>”
where x increments for the number of times I tried it or what I passed =
in when
I used the method that allows me to have the calling procedure name the =
cursor.
But no data.



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>If anybody has run into this challenge I would love =
to hear
if you were or were not successful. I’d really like to hear you =
were
successful, of course, but if there is no way to do it then =
there’s no
point me wasting any more time with it.



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>Thank you,



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>-Doug









------_=_NextPart_001_01C777D6.F5B97538--

Re: Brio returning data through stored procedures.

am 06.04.2007 02:16:27 von David Gardner

Never worked with Brio, but have you defined a data-type in pgsql that=20
your function would be returning? Something like:

CREATE TYPE "myType" AS
("name" text,
"start" timestamp without time zone,
"end" timestamp without time zone,
error text);
ALTER TYPE "myType" OWNER TO "me";

then the function definition would start off like:
CREATE OR REPLACE FUNCTION "getData"()
RETURNS SETOF "myType" AS
......

Doug Thom wrote:
>
> Hello, all,
>
> I am wondering if anybody knows how to return data to Brio through=20
> ODBC from a function. If you are (or were) an Oracle user you may be=20
> familiar with defining a ref cursor type and including that as an OUT=20
> parameter. Brio then picks it up through ODBC and collects the results.
>
> When I tried this in many different ways in Postgres the best I could=20
> get returned was either =93=94 where x increments for=
=20
> the number of times I tried it or what I passed in when I used the=20
> method that allows me to have the calling procedure name the cursor.=20
> But no data.
>
> If anybody has run into this challenge I would love to hear if you=20
> were or were not successful. I=92d really like to hear you were=20
> successful, of course, but if there is no way to do it then there=92s n=
o=20
> point me wasting any more time with it.
>
> Thank you,
>
> -Doug
>


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: Brio returning data through stored procedures.

am 06.04.2007 15:49:53 von Andreas

Hi Doug

I dont know Brio either but keep in mind that tables and views are
allready defined types which you could use here.

So if your procedure just selects a few rows from a view or table but
should return all collumns from the source you don't have to define a
return type.


David Gardner schrieb:
> Never worked with Brio, but have you defined a data-type in pgsql that
> your function would be returning? Something like:
>
> CREATE TYPE "myType" AS
> ("name" text,
> "start" timestamp without time zone,
> "end" timestamp without time zone,
> error text);
> ALTER TYPE "myType" OWNER TO "me";
>
> then the function definition would start off like:
> CREATE OR REPLACE FUNCTION "getData"()
> RETURNS SETOF "myType" AS
> .....


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Re: Brio returning data through stored procedures.

am 06.04.2007 17:04:12 von Doug Thom

Hello, David, Andreas,

Thank you for the suggestions. The challenge is that I need a ref cursor
because it is some arbitrary amount of data coming back from the server
in a cursor. Your suggestion shows a defined row but I do not know what
the row looks like so I cannot define a type beforehand.

However, your comments have me wondering if there is a different route I
can take. Is there anything that is a 'generic row of data'? I see the
type "record" and I'm going to give that a try.

Thanks again for the prompt response and ideas!

-Doug

-----Original Message-----
From: Andreas [mailto:maps.on@gmx.net]=20
Sent: Friday, April 06, 2007 9:50 AM
To: pgsql-odbc@postgresql.org
Cc: Doug Thom
Subject: Re: [ODBC] Brio returning data through stored procedures.

Hi Doug

I dont know Brio either but keep in mind that tables and views are=20
allready defined types which you could use here.

So if your procedure just selects a few rows from a view or table but=20
should return all collumns from the source you don't have to define a=20
return type.


David Gardner schrieb:
> Never worked with Brio, but have you defined a data-type in pgsql that

> your function would be returning? Something like:
>
> CREATE TYPE "myType" AS
> ("name" text,
> "start" timestamp without time zone,
> "end" timestamp without time zone,
> error text);
> ALTER TYPE "myType" OWNER TO "me";
>
> then the function definition would start off like:
> CREATE OR REPLACE FUNCTION "getData"()
> RETURNS SETOF "myType" AS
> .....=20



---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Re: Brio returning data through stored procedures.

am 06.04.2007 18:16:01 von David Gardner

Hmm are you doing something like:
IF something THEN
SELECT * FROM tblOne;
ELSE
SELECT * FROM tblTwo;

Not sure what a refcursor is, but it is mentioned in the docs:
http://www.postgresql.org/docs/8.1/interactive/plpgsql-curso rs.html


Doug Thom wrote:
> Hello, David, Andreas,
>
> Thank you for the suggestions. The challenge is that I need a ref cursor
> because it is some arbitrary amount of data coming back from the server
> in a cursor. Your suggestion shows a defined row but I do not know what
> the row looks like so I cannot define a type beforehand.
>
> However, your comments have me wondering if there is a different route I
> can take. Is there anything that is a 'generic row of data'? I see the
> type "record" and I'm going to give that a try.
>
> Thanks again for the prompt response and ideas!
>
> -Doug
>
> -----Original Message-----
> From: Andreas [mailto:maps.on@gmx.net]
> Sent: Friday, April 06, 2007 9:50 AM
> To: pgsql-odbc@postgresql.org
> Cc: Doug Thom
> Subject: Re: [ODBC] Brio returning data through stored procedures.
>
> Hi Doug
>
> I dont know Brio either but keep in mind that tables and views are
> allready defined types which you could use here.
>
> So if your procedure just selects a few rows from a view or table but
> should return all collumns from the source you don't have to define a
> return type.
>
>
> David Gardner schrieb:
>> Never worked with Brio, but have you defined a data-type in pgsql that
>
>> your function would be returning? Something like:
>>
>> CREATE TYPE "myType" AS
>> ("name" text,
>> "start" timestamp without time zone,
>> "end" timestamp without time zone,
>> error text);
>> ALTER TYPE "myType" OWNER TO "me";
>>
>> then the function definition would start off like:
>> CREATE OR REPLACE FUNCTION "getData"()
>> RETURNS SETOF "myType" AS
>> .....
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>


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

Re: Brio returning data through stored procedures.

am 06.04.2007 18:31:40 von Doug Thom

I saw it in the docs which I thought was encouraging but I can't see to
get it to do what I want.

We have a metadata engine that we wrote. It is a layer above our
warehouse. A feature of it is that it writes queries for our users, ETL,
etc.

We have a procedure that constructs the (sometimes quite complex) query
and opens it as a cursor and returns it to Brio. Brio, through ODBC,
then pulls all the results out of the cursor and we're done.

So I would be doing something like:

--Do the thing that builds the query.
Select query
Into query-string
From table-that-has-query;

Open cursor for query-string;

Return cursor;
--End pseudo code

In Oracle this is done with a ref cursor but maybe not in PG. I note
there is a function type called 'sql' rather than 'plpgsql' and I'm
trying that out.

If this triggers any other thoughts from anyone please share.

Thanks again for the help.

-Doug

-----Original Message-----
From: David Gardner [mailto:david.gardner@yucaipaco.com]=20
Sent: Friday, April 06, 2007 12:16 PM
To: Doug Thom; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Brio returning data through stored procedures.

Hmm are you doing something like:
IF something THEN
SELECT * FROM tblOne;
ELSE
SELECT * FROM tblTwo;

Not sure what a refcursor is, but it is mentioned in the docs:
http://www.postgresql.org/docs/8.1/interactive/plpgsql-curso rs.html


Doug Thom wrote:
> Hello, David, Andreas,
>=20
> Thank you for the suggestions. The challenge is that I need a ref
cursor
> because it is some arbitrary amount of data coming back from the
server
> in a cursor. Your suggestion shows a defined row but I do not know
what
> the row looks like so I cannot define a type beforehand.
>=20
> However, your comments have me wondering if there is a different route
I
> can take. Is there anything that is a 'generic row of data'? I see the
> type "record" and I'm going to give that a try.
>=20
> Thanks again for the prompt response and ideas!
>=20
> -Doug
>=20
> -----Original Message-----
> From: Andreas [mailto:maps.on@gmx.net]=20
> Sent: Friday, April 06, 2007 9:50 AM
> To: pgsql-odbc@postgresql.org
> Cc: Doug Thom
> Subject: Re: [ODBC] Brio returning data through stored procedures.
>=20
> Hi Doug
>=20
> I dont know Brio either but keep in mind that tables and views are=20
> allready defined types which you could use here.
>=20
> So if your procedure just selects a few rows from a view or table but=20
> should return all collumns from the source you don't have to define a=20
> return type.
>=20
>=20
> David Gardner schrieb:
>> Never worked with Brio, but have you defined a data-type in pgsql
that
>=20
>> your function would be returning? Something like:
>>
>> CREATE TYPE "myType" AS
>> ("name" text,
>> "start" timestamp without time zone,
>> "end" timestamp without time zone,
>> error text);
>> ALTER TYPE "myType" OWNER TO "me";
>>
>> then the function definition would start off like:
>> CREATE OR REPLACE FUNCTION "getData"()
>> RETURNS SETOF "myType" AS
>> .....=20
>=20
>=20
>=20
> ---------------------------(end of
broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>=20
> http://www.postgresql.org/about/donate
>=20



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

Re: Brio returning data through stored procedures.

am 06.04.2007 18:42:12 von David Gardner

Hmm, thats way beyond my usage of pgsql, and possibly better answered on
the pgsql-general mailing list.

Doug Thom wrote:
> I saw it in the docs which I thought was encouraging but I can't see to
> get it to do what I want.
>
> We have a metadata engine that we wrote. It is a layer above our
> warehouse. A feature of it is that it writes queries for our users, ETL,
> etc.
>
> We have a procedure that constructs the (sometimes quite complex) query
> and opens it as a cursor and returns it to Brio. Brio, through ODBC,
> then pulls all the results out of the cursor and we're done.
>
> So I would be doing something like:
>
> --Do the thing that builds the query.
> Select query
> Into query-string
> From table-that-has-query;
>
> Open cursor for query-string;
>
> Return cursor;
> --End pseudo code
>
> In Oracle this is done with a ref cursor but maybe not in PG. I note
> there is a function type called 'sql' rather than 'plpgsql' and I'm
> trying that out.
>
> If this triggers any other thoughts from anyone please share.
>
> Thanks again for the help.
>
> -Doug
>
> -----Original Message-----
> From: David Gardner [mailto:david.gardner@yucaipaco.com]
> Sent: Friday, April 06, 2007 12:16 PM
> To: Doug Thom; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] Brio returning data through stored procedures.
>
> Hmm are you doing something like:
> IF something THEN
> SELECT * FROM tblOne;
> ELSE
> SELECT * FROM tblTwo;
>
> Not sure what a refcursor is, but it is mentioned in the docs:
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-curso rs.html
>
>
> Doug Thom wrote:
>> Hello, David, Andreas,
>>
>> Thank you for the suggestions. The challenge is that I need a ref
> cursor
>> because it is some arbitrary amount of data coming back from the
> server
>> in a cursor. Your suggestion shows a defined row but I do not know
> what
>> the row looks like so I cannot define a type beforehand.
>>
>> However, your comments have me wondering if there is a different route
> I
>> can take. Is there anything that is a 'generic row of data'? I see the
>> type "record" and I'm going to give that a try.
>>
>> Thanks again for the prompt response and ideas!
>>
>> -Doug
>>
>> -----Original Message-----
>> From: Andreas [mailto:maps.on@gmx.net]
>> Sent: Friday, April 06, 2007 9:50 AM
>> To: pgsql-odbc@postgresql.org
>> Cc: Doug Thom
>> Subject: Re: [ODBC] Brio returning data through stored procedures.
>>
>> Hi Doug
>>
>> I dont know Brio either but keep in mind that tables and views are
>> allready defined types which you could use here.
>>
>> So if your procedure just selects a few rows from a view or table but
>> should return all collumns from the source you don't have to define a
>> return type.
>>
>>
>> David Gardner schrieb:
>>> Never worked with Brio, but have you defined a data-type in pgsql
> that
>>> your function would be returning? Something like:
>>>
>>> CREATE TYPE "myType" AS
>>> ("name" text,
>>> "start" timestamp without time zone,
>>> "end" timestamp without time zone,
>>> error text);
>>> ALTER TYPE "myType" OWNER TO "me";
>>>
>>> then the function definition would start off like:
>>> CREATE OR REPLACE FUNCTION "getData"()
>>> RETURNS SETOF "myType" AS
>>> .....
>>
>>
>> ---------------------------(end of
> broadcast)---------------------------
>> TIP 7: You can help support the PostgreSQL project by donating at
>>
>> http://www.postgresql.org/about/donate
>>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Re: Brio returning data through stored procedures.

am 06.04.2007 19:27:25 von Tom Lane

"Doug Thom" writes:
> So I would be doing something like:

> --Do the thing that builds the query.
> Select query
> Into query-string
> From table-that-has-query;

> Open cursor for query-string;

> Return cursor;
> --End pseudo code

I think you're looking for OPEN cursor FOR EXECUTE in plpgsql.
See the "cursor operations" part of the plpgsql manual.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Re: Brio returning data through stored procedures.

am 06.04.2007 19:28:38 von Doug Thom

Ah, sorry, right. I did that. Real code was correct, pseudo code was
bad. :)

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
Sent: Friday, April 06, 2007 1:27 PM
To: Doug Thom
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Brio returning data through stored procedures.=20

"Doug Thom" writes:
> So I would be doing something like:

> --Do the thing that builds the query.
> Select query
> Into query-string
> From table-that-has-query;

> Open cursor for query-string;

> Return cursor;
> --End pseudo code

I think you're looking for OPEN cursor FOR EXECUTE in plpgsql.
See the "cursor operations" part of the plpgsql manual.

regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate