I have written a function in postgresql with one inpute parameter. I want to invoke this function from .Net windows Form but an error occures like this:
Error: 42601: Syntaxerror at »’TestUGI’«
this is my code:
Npgsql.NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;Database=DB3;User Id=postgres;Password=123456;");
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand("'TestUGI'",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@tablename", "'csnnutzer'");
cmd.ExecuteNonQuery();
Please show the function. That would help a lot. If, for instance the function returns a record, then should you make a different kind of call.
Error 42883 states that the function is undefined. That has a straightforward reason. If you show the code, we can help you to find out. The parameter unknown is not the problem. When I read that, I know that there is text or varchar without a specified length.
Is the capitalization correct? The functions ‘testUGI’ and ‘TestUgi’ are different.
When the function does not return a record, then should you just make a query. It is not like a stored procedure in MySQL, which has a syntax on its own (call etc.). In postgresql is the call to a function a select statement.
Some examples:
The first function can return a simple datatype like integer or varchar.
The second statement when there is a row of table returned.
The last one when you return a record.