[Mono-list] Npgsql.dll

Carl Olsen carl at carl-olsen.com
Sat Jun 18 18:22:23 EDT 2005


I have it working now.

	CREATE TYPE senators AS
		(s_fname varchar,
		S_lname varchar,
		s_email varchar,
		s_party char);

	CREATE OR REPLACE FUNCTION getsenators()
		RETURNS SETOF senators AS
		'
		DECLARE
			r senators%rowtype;
		BEGIN
			FOR r IN SELECT
s_fname,s_lname,s_email,s_party FROM
senate_members LOOP
				RETURN NEXT r;
			END LOOP;
			RETURN;
		END
		'
	LANGUAGE 'plpgsql' VOLATILE;


Here's my parameterized function:

	CREATE OR REPLACE FUNCTION getsenators(text)
		RETURNS SETOF senators AS
		'
		DECLARE
			input ALIAS FOR $1;
			r senators%rowtype;
		BEGIN
			FOR r IN SELECT s_fname,s_lname,s_email FROM
senate_members WHERE s_party=input LOOP
				RETURN NEXT r;
			END LOOP;
			RETURN;
		END
		'
	LANGUAGE 'plpgsql' VOLATILE;

When I type SELECT * FROM getsenators('D') I get the correct set of records.

I'm not even sure why it wasn't working before or what I did to fix it, but
I now have working examples I can copy and use as templates.

I suppose the last thing I could to do is try using "char" instead of "text"
for the input parameter type, although I'm not sure if that is going to make
it work any better.

Carl
http://www.carl-olsen.com/




More information about the Mono-list mailing list