Skip site navigation (1) Skip section navigation (2)

Prepare / Execute Method Error

From: Brad Budge <flexpadawan(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Prepare / Execute Method Error
Date: 2009-04-28 06:07:07
Message-ID: f3db158e0904272307i37538c72radcb335ce41c71a1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
I'm having problems passing in variables into my execute statement.  Any
ideas?

*
*

**

*Table:*
CREATE TABLE cat.case
(
vari         character varying(50),                    --Contains Value
‘BDD1’
ht            numeric(4,1)                                      --Contains
Value 30.0
)


*Statements:*
PREPARE insert_plan (character varying, numeric) AS
SELECT vari FROM cat.case WHERE vari = $1 AND ht = $2;

EXECUTE insert_plan(*vari_string*, *case[1]*);  *--Fails with Errors
vari_string*          = 'BDD1'               --character varying
*case[1]*                 = 30.0                    --numeric(4,1)[]

*Errors:*
NOTICE: vari_string: BDD1 NOTICE: ht: 30.0
ERROR: function insert_plan(character varying, numeric) does not exist
LINE 1: SELECT insert_plan( $1 , $2 [ $3 ])
HINT: No function matches the given name and argument types. You might need
to add explicit type casts.
QUERY: SELECT insert_plan( $1 , $2 [ $3 ])


*Hard Coded – It will work! It just doesn’t like using variables inside???*
EXECUTE insert_plan('BDD1', 30.0);



*Another Variation of the Execution Statement and still failed.*
EXECUTE insert_plan(vari_string:: character varying(50), case[1]::
numeric(4,1));

pgsql-general by date

Next:From: Thomas KellererDate: 2009-04-28 06:17:08
Subject: Re: Sequence Incrementing by 2 insted of 1
Previous:From: DavidDate: 2009-04-28 05:48:00
Subject: Sequence Incrementing by 2 insted of 1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group