pgsqlException - 'Parameter $1 missing' when I call script.execute

pgsqlException - 'Parameter $1 missing' when I call script.execute

Postby kcrenshaw » Tue 11 Apr 2006 18:35

When I execute the following code, I get the error 'Parameter $1 is missing'. Could someone please help?

Dim conn As PgSqlConnection
Dim connStr As String
Dim cmdStr As String

connStr = "Server=localhost;Port=5432;User Id=postgres;Password=secret;Database=pgdata;"
conn = New PgSqlConnection(connStr)
cmdStr = "CREATE OR REPLACE FUNCTION SP_TEST2(TEXT, TEXT) RETURNS INTEGER AS AS $$ " & _
"DECLARE " & _
"cid ALIAS FOR $1; " & _
"rpid ALIAS FOR $2; " & _
"BEGIN " & _
"SELECT * FROM tasks WHERE createdby = cid AND responsibleperson = rpid; " & _
"RETURN 0; " & _
"END; " & _
"$$ LANGUAGE 'plpgsql';"
Try
If Not conn.State = ConnectionState.Open Then conn.Open()
Dim script As New PgSqlScript(cmdStr, conn)
script.Execute()

Catch ex As Exception
Throw ex
Finally
If Not conn Is Nothing Then
If Not conn.State = ConnectionState.Closed Then conn.Close()
End If
End Try

Thanks!

Kevin
kcrenshaw
 
Posts: 7
Joined: Wed 22 Mar 2006 23:47

Postby Alexey » Wed 12 Apr 2006 07:28

You have a syntax error: "AS AS"
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

The error is returned even without the syntax error.

Postby kcrenshaw » Wed 12 Apr 2006 11:43

Thanks for your reply. However, I ran the script without the syntax error and I still get the same result.
kcrenshaw
 
Posts: 7
Joined: Wed 22 Mar 2006 23:47

Postby Alexey » Wed 12 Apr 2006 11:51

Could you please provide us with the PostgreSQLDirect version (specify trial/std/pro as well) and your PostgreSQL Server version.
Try to execute your sql statement using any other client (e.g., pgAdmin).
Last edited by Alexey on Fri 14 Apr 2006 06:11, edited 1 time in total.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

DB Versin etc..

Postby kcrenshaw » Wed 12 Apr 2006 12:20

Thanks for you quick response.

I am using postgresql version 8.1 on Windows XP Professional with PostgresqlDirect version 2.20 Standard edition.

I am able to execute the statement using psql at the command prompt with no problems. It also works using pgAdmin.

Thanks for your help,

Kevin
kcrenshaw
 
Posts: 7
Joined: Wed 22 Mar 2006 23:47

Postby Alexey » Wed 12 Apr 2006 12:58

Send us small test project if possible to reproduce the problem; it is
desirable to use 'test' schema objects, otherwise include definition of
your own database objects. Do not use third party components.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Sample project

Postby kcrenshaw » Wed 12 Apr 2006 14:30

I have sent you a sample project to demonstrate the problem to info@crlab.com. Please let me know if you need anything else. Gmail would not allow me to send the project, so I had to send it from another account. The email has the subject 'Parameter $1 missing' when I call script.execute'.

Thanks,

Kevin
kcrenshaw
 
Posts: 7
Joined: Wed 22 Mar 2006 23:47

Postby Alexey » Thu 13 Apr 2006 07:00

We were unable to find any project attached. Respective message has been send to your e-mail. Please attach the project to the reply on that message.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for PostgreSQL