473,406 Members | 2,713 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,406 software developers and data experts.

error in calling a stored procedure in php

i've a sql query as follows:

SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3 where
tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND tb2.col4 BETWEEN 4 AND 5
AND tb2.col5 BETWEEN 6 AND 7;

if I run the above query thru php it works, but if i try to call a
procedure for above query as shown below it thrws error
ERROR 1064 (42000): the right syntax to use near 'tb1.col2
<?
$wherestr = "tb2.col4 BETWEEN 4 AND 5 AND tb2.col5 BETWEEN 6 AND 7";
CALL proc4($wherestr);

?>
Procedure#=>

DELIMITER $$

DROP PROCEDURE IF EXISTS `midas`.`sp_dm_domain_keyword_mapping`$$
CREATE DEFINER=`oteuser`@`%` PROCEDURE `sp_dm_domain_keyword_mapping`(
whereval varchar(500))
BEGIN

set @whereval = whereval;
set @sql1 = CONCAT('SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3
where tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND ',@whereval);
PREPARE stmt FROM @sql1;

EXECUTE stmt using @whereval;
DEALLOCATE PREPARE stmt;
END$$

DELIMITER ;

what is the error in above code?

Oct 31 '06 #1
1 1459
Gayatri wrote:
i've a sql query as follows:

SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3 where
tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND tb2.col4 BETWEEN 4 AND 5
AND tb2.col5 BETWEEN 6 AND 7;

if I run the above query thru php it works, but if i try to call a
procedure for above query as shown below it thrws error
ERROR 1064 (42000): the right syntax to use near 'tb1.col2
<?
$wherestr = "tb2.col4 BETWEEN 4 AND 5 AND tb2.col5 BETWEEN 6 AND 7";
CALL proc4($wherestr);

?>
Procedure#=>

DELIMITER $$

DROP PROCEDURE IF EXISTS `midas`.`sp_dm_domain_keyword_mapping`$$
CREATE DEFINER=`oteuser`@`%` PROCEDURE `sp_dm_domain_keyword_mapping`(
whereval varchar(500))
BEGIN

set @whereval = whereval;
set @sql1 = CONCAT('SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3
where tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND ',@whereval);
PREPARE stmt FROM @sql1;

EXECUTE stmt using @whereval;
DEALLOCATE PREPARE stmt;
END$$

DELIMITER ;

what is the error in above code?
Since this is a sql problem, I'd recommend you ask in a SQL newsgroup -
or at least one related to your database.

You'll get better answers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 31 '06 #2

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

Similar topics

1
by: Chetan | last post by:
Hi We have Oracle 8.1.7.4 and using .net framework 1.1 with Microsoft client. While executting the stored procedure we are getting an error message. Here is our code. here is the code that...
1
by: Jen S | last post by:
I feel like I'm missing something obvious here, but I'm stumped... I have a stored procedure with code that looks like: INSERT INTO MyTableA ( ...fields... ) VALUES (...values...) IF...
7
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
0
by: vaishaliekhar | last post by:
Hello, I have created a stored procedure using SPUFI. The stored procedure is defined to execute an external Assembler routine. There was no error while creating the stored procedure. While...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
4
by: Jack | last post by:
Hi, I am trying to run an example code from a book. However I am getting the following error message: Number: -2147217900 Description: Syntax error or access violation Source: Microsoft OLE...
0
by: aravindalapat | last post by:
Hi All, I am facing an error when I try to invoke a remote nested stored proc. Please find the details below. 1) SP TEST1 is defined in DB2 instance DB2A. It is calling a stored procedure ...
9
by: Ratfish | last post by:
I'm getting a "2014:: Commands out of sync; you can't run this command now" error on a php page when I try to call a second stored procedure against a MySQL db. Does anyone know why I might be...
4
by: jdokos | last post by:
Hello All, I have a procedure that is getting -443 after upgrading to V9.5 FP1. The procedure was written to output only the SQLCODE. Here is the output that is returned: Value of output...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.