pgsqlException - 'Parameter $1 missing' when I call script.execute
Posted: 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
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