Thread: PostGres ODBC -- Multiple ordinal parameters ?
$DB1ConnString = "Driver={PostgreSQL ANSI};Server=192.168.0.1;Database=dbname;"
$DB1Conn = New-Object System.Data.Odbc.OdbcConnection
$DB1Conn.ConnectionString = $DB1ConnString
$DBCmd = $DB1Conn.CreateCommand()
$DBCmd.Parameters.Add("@Param", [System.Data.SqlDbType]'VarChar')
$DBCmd.Parameters["@Param"].Value = "fieldval"
$DBCmd.CommandText = "select count(*) from tablename where fieldname=`$1"
$DBCmd.Connection.Open()
$DB1Results = $DBCmd.ExecuteReader()
while ($DB1Results.Read()){
write-host $DB1Results.GetString(0);
}
$DBCmd.Connection.Close()
"ERROR [42P02] Parameter $1 does not exist"
I was able to get around the issue in our environment by downgrading the ODBC drivers, but I wanted to pass this along in case this was an undocumented bug.
Thank you for your time, and please feel free to let me know if there's anything else I can help with for my part.
Respectfully,
Joseph M. Pence
Joe Pence wrote: > I'm not sure if this is expected behavior or a bug, but I had noticed that > there's an issue in pulling prepared queries with multiple ordinal > parameters. The ODBC specification requires parameter markers to be question marks. I do not know if ordinal parameter markers (a non-standard PG extension) are supposed to be supported in the ODBC driver. Regards, Clemens