SCM

[#1006158] out parameters in pg functions

View Trackers | Bugs | Download .csv | Monitor

Date:
2007-06-10 22:55
Priority:
3
State:
Open
Submitted by:
Dalibor Bednar (dalxxx)
Assigned to:
Nobody (None)
Npgsql Version:
1.0
Category:
Group:
Resolution:
None
Summary:
out parameters in pg functions

Detailed description
Hi,

I have a simple function

CREATE OR REPLACE FUNCTION more_params(OUT a integer, OUT b) AS
$BODY$DECLARE
BEGIN
a := 3;
b := true;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE;

But when I want call this fucntion it doesn't work well.

command = new NpgsqlCommand("more_params(:a,:b)", conn);
command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add(new NpgsqlParameter("a", DbType.Int32));
command.Parameters[0].Direction = ParameterDirection.Output;
command.Parameters.Add(new NpgsqlParameter("b", DbType.Boolean));
command.Parameters[1].Direction = ParameterDirection.Output;

Object result = command.ExecuteScalar();

It return ERROR: 42601: syntax error at or near ","

When I try to find a problem I see a npsql log and find this line:
10.6.2007 23:59:14 2952 Debug String written: select * from more_params(,).

Error raise when you use more out parameters together or in bad order with other input parameters.
Npsql remove the out parameters from raw string but leave there commas and that is the problem.

WORKAROUND:
Don't use comma to separate out parameters. ;-)
for example: "more_params(:a :b)"

Dalibor
PS: Sorry if problem is really posted, but in huge count of insensate bugs I don't like find him.

Followup

Message
Date: 2008-08-16 02:26
Sender: Francisco Figueiredo jr.


Hi, Dalibor,

This is a problem with Npgsql which shouldn't allow this type of construction when calling functions. It should only allow the name of the stored procedure in commandtext. I will check if this restriction works for all the cases.

The correct way of making your call would be to have only the name of the function in the command text.

I hope it helps.

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge