473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem in calling prepare statement from STORED PROCEDURE

Hi:

I prepare the statement for execution as follows:

PREPARE query(text) as SELECT count(*) FROM transform_customer_billing where inv_no = $1;

The problem is Iam not able to execute this prepare statement from the stored procedure defined. I added the statement to call the prepare statement is: EXECUTE query('100023'). The ERROR it prints : Function query(text) doesnot exist.

Please suggest the solution for this problem.

Thanks in advance.

Rajat

Nov 23 '05 #1
2 6480


Hi,

Inside a stored procedure EXECUTE runs a dynamic query,
DOCS SAY:

Oftentimes you will want to generate dynamic commands inside your
PL/pgSQL functions, that is, commands that will involve different tables
or different data types each time they are executed. PL/pgSQL's normal
attempts to cache plans for commands will not work in such scenarios. To
handle this sort of problem, the EXECUTE statement is provided:

EXECUTE command-string;

where command-string is an expression yielding a string (of type text)
containing the command to be executed. This string is fed literally to
the SQL engine.
Really not sure how to execute a named plan inside plpgsql.

Regds
mallah.

Rajat Katyal wrote:
Hi:

I prepare the statement for execution as follows:

*PREPARE query(text) as SELECT count(*) FROM
transform_customer_billing where inv_no = $1;*
**
The problem is Iam not able to execute this prepare statement from
the stored procedure defined. I added the statement to call the
prepare statement is: *EXECUTE query('100023'). *The ERROR it prints :
*Function query(text) does not exist.*

Please suggest the solution for this problem.

Thanks in advance.

Rajat


Nov 23 '05 #2
"Rajat Katyal" <ra****@intelesoftech.com> writes:
I prepare the statement for execution as follows:
PREPARE query(text) as SELECT count(*) FROM transform_customer_billing wher=
e inv_no =3D $1;
The problem is Iam not able to execute this prepare statement from the stor=
ed procedure defined.


EXECUTE means something different in plpgsql than it does in plain SQL,
and you do not need PREPARE at all in plpgsql. plpgsql's automatic
caching of plans gives you the effect of PREPARE on every statement
without your having to ask for it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Golawala, Moiz M (GE Infrastructure) | last post by:
Hi All, I am having problem returning values from a Stored Procedure that creates a dynamic table (table variable) inserts values during a procedure and then I select from that dynamic table to...
0
by: stephane.traumat | last post by:
Hello, I already succeed to call a stored procedure in Oracle but only simple ones with one output value and several inputs. I don't any idea left so any help would be great :) Thanks But on...
1
by: Purple-Man | last post by:
wanted to use sp_OACreate, sp_OAMethod and sp_OADestroy to execute a DTS package from a stored procedure. I had the dba (using the sa account) create a wrapper stored procedure as recommended in...
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
5
by: David Davis | last post by:
I have the following stored procedure in an sql database ------------------------------------ CREATE PROCEDURE zspQuoteSummary @dStart DateTime, @dEnd DateTime AS SELECT qtmast.fstatus,...
0
by: istruttorenuoto | last post by:
hi! I have some problems to call a stored procedure from an Unix Script. Here's the script stty istrip stty erase ^H export ORACLE_BASE=/product/oracle export...
1
by: Yogesh Pandit | last post by:
Hi, I have 2 stored procedures A and B. A makes a call to B and B returns a cursor to A. Stored Procedure B executes fine individually. However, when I execute A, I get the following error: ...
1
by: Akino877 | last post by:
Hello, I have a small Perl program : #!/usr/bin/perl -w use DBI; use Mysql; $host = ""; $database = ""; $user = "root";
0
by: piperdawn | last post by:
Hi Guys, We have a requirement wherein when the value in the column of a particular DB2 table changes to a certain value, a job must be triggered which will execute a program and generate a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.