Re: How to make @id or $id as parameter name in plpgsql, isit available?

From: "Arnold(dot)Zhu" <joint(at)shaucon(dot)com>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to make @id or $id as parameter name in plpgsql, isit available?
Date: 2000-11-26 07:55:31
Message-ID: 20041126075157.400F9714@shaucon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

following is only program fragment, original program structure is from sample
named Duwamish in ms vs.net 2002.

/////////////////////////////////
private const String ID_PARM = "@id";
private const String NAME_PARM = "@name";

public UserData GetUserById(int id)
{
if ( dataAdapter == null )
{
throw new System.ObjectDisposedException( GetType().FullName );
}

UserData userData = new UserData();

dataAdapter.SelectCommand = GetUserByIdCommand();
dataAdapter.SelectCommand.Parameters[ID_PARM].Value = id;
dataAdapter.Fill(data);

return userData;
}

private SelectCommand GetUserByIdCommand()
{
if ( getUserCommand == null)
{
selectUserByIdCommand = new SelectCommand("user_select_by_id", Configuration.ConnectDB());
selectUserByIdCommand.CommandType = CommandType.StoredProcedure;

ParameterCollection params = selectUserByIdCommand.Parameters;
params.Add(new Parameter(ID_PARM, DbType.Int32));
}
return selectUserByIdCommand;
}
/////////////////////////////////

---------------------------------
CREATE TABLE users (
id serial NOT NULL,
name character varying(32) NOT NULL
);
---------------------------------
CREATE TYPE user_set AS (
id integer,
name character varying(32)
);
---------------------------------
CREATE FUNCTION user_select_by_id("@id" int4)
RETURNS SETOF user_set
AS '
declare rec record;

begin

for rec in
select * from users where id = "@id"
loop
return next rec;
end loop;
return;

end; '
LANGUAGE plpgsql;
---------------------------------

Thanks & Regards!

Arnold.Zhu
2004-11-26

Browse pgsql-hackers by date

  From Date Subject
Next Message Mitch Vincent 2000-11-26 08:02:59 Re: Re: [NOVICE] Re: re : PHP and persistent connections
Previous Message Alain Toussaint 2000-11-26 07:50:36 Re: Re: [NOVICE] Re: re : PHP and persistent connections