Runtime error when calling function from .NET ( Function returns record)

From: dparent <davidp(at)channeladvisor(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Runtime error when calling function from .NET ( Function returns record)
Date: 2007-01-15 14:11:02
Message-ID: 8372092.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I have a function which returns TYPE RECORD and receives a string. The passed
string is used to build a dynamic SQL statement and the passed string is the
SELECT LIST of the built dynamic SQL statement.

The call works fine from Postgres SQL (PL/PG SQL) but when I make the call
from .NET (Core labs data provider), I get a runtime error.

Any ideas on how to get this to work ? One solution we came up with is to
use a REFCURSOR or to return back a string to .NET and have .NET execute the
string (ie. select * from test2('feedid') as (name bigint);).

We were hoping for an easier &/or better solution.

Example function:
CREATE or REPLACE FUNCTION "public"."test2"(
IN "_sfieldlist" varchar)
RETURNS SETOF "pg_catalog"."record" AS
$BODY$
DECLARE
v_feed RECORD;
v_sfieldlist varchar(512);
BEGIN
v_sfieldlist := _sfieldlist;

FOR v_feed IN EXECUTE '
SELECT '||v_sfieldlist||'
FROM feed'
LOOP
RETURN NEXT v_feed;
END LOOP;
RETURN;
END;
$BODY$
LANGUAGE 'plpgsql' IMMUTABLE SECURITY DEFINER;

This works just ducky from PL/PG SQL when I run a select something like the
following:
select * from test2('feedid') as (name bigint);

However, when I make a straight call to this function from .NET we get a
runtime error (similar to the error you would get if you ran the following:
select * from test2('feedid')).
--
View this message in context: http://www.nabble.com/Runtime-error-when-calling-function-from-.NET-%28-Function-returns-record%29-tf3014812.html#a8372092
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aleksander Kmetec 2007-01-15 14:40:46 Re: index type for indexing long texts
Previous Message btober 2007-01-15 14:05:29 Re: Backup the part of postgres database