473,395 Members | 1,937 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,395 software developers and data experts.

Help with Stored Proc in mysql varchar variables

Hi,

Heres a little test sp, I can't get it to use the @H variable in the
select , what am i doing wrong?, been messing for days now :(

The row caount always comes back as 0 , but if I just change the line
"SELECT count(*) INTO s from test where url=@'H';" to use url='tony'
for example or any other value it works as expected.

drop procedure ts;
delimiter //

CREATE PROCEDURE ts (
IN H varchar(255),
IN CheckStatus INT,
OUT Result varchar(10)
)
BEGIN

DECLARE s int DEFAULT 0;

SELECT H as N;

SELECT s AS TONY;
SELECT count(*) INTO s from test where url=@'H';

SELECT s AS TONY;

IF s 1
THEN select "OK" into Result;
ELSE select "FAIL" into Result;
END IF;
END;
//

delimiter ;

call ts('tony','1',@Result);
select @Result;

Here are the results as you can see @H is set to 'tony' before the
select count(*) and s = 0 before and after

mysqldelimiter //
mysql>
mysqlCREATE PROCEDURE ts (
-IN H varchar(255),
-IN CheckStatus INT,
-OUT Result varchar(10)
-)
- BEGIN
->
-DECLARE s int DEFAULT 0;
->
-SELECT H as N;
->
-SELECT s AS TONY;
->
->
-SELECT count(*) INTO s from test where url=@'H';
->
->
-SELECT s AS TONY;
->
-IF s 1
-THEN select "OK" into Result;
-ELSE select "FAIL" into Result;
-END IF;
- END;
- //
Query OK, 0 rows affected (0.00 sec)

mysql>
mysqldelimiter ;
mysql>
mysqlcall ts('tony','1',@Result);
+------+
| N |
+------+
| tony |
+------+
1 row in set (0.00 sec)

+------+
| TONY |
+------+
| 0 |
+------+
1 row in set (0.00 sec)

+------+
| TONY |
+------+
| 0 |
+------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysqlselect @Result;
+---------+
| @Result |
+---------+
| FAIL |
+---------+
1 row in set (0.00 sec)

The test table is

+-------+
| url |
+-------+
| tony |
| moira |
+-------+

Please let me know what I'm doing wrong .. Many thanks

Aug 29 '06 #1
0 3570

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

Similar topics

3
by: bigDWK | last post by:
Hi- I'm having problems with the following stored procedure. Below first I have the stored proc, then I have the asp code that calls it. Randomly it won't insert the order into the database and a...
1
by: Bill S. | last post by:
Hi, I a stored procedure that inserts a record into a table as below. The insert works OK, but if the insert violates a unique indewx constraint on one of the columns, the proc terminates...
5
by: rhungund | last post by:
Hi All. My question is this. I have a complex stored procedure in SQL Server which works fine when I run it in Query Analyzer. However, when I call it within my ASP script, it returns nothing,...
2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
1
by: Jay | last post by:
I hope this is the correct place to post this. I'm using a stored procedure to simply look up and return a value from a database. The db key is an integer, everything else is varchar. The stored...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
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...
2
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
1
by: upstart | last post by:
Hi everyone…this is a tough one. You guys have been such a help before, hopefully you can point me in the right direction now. I have a Report I am working on that uses a stored procedure to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.