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

(simple) stored procedure question - 2nd set of eyes may be all thatsneeded

I have been busting my nut over this for pretty much most of the day and
it is driving me nuts. I posted this to an mySQL ng yesterday and I have
not had any response (I'm pulling my hair out here).

Its really a very simple stored procedure but I simply can't seem to get
it to work.

I have a simple table misc_data described as ff:

+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| uid | int(10) unsigned | NO | | | |
| mid | int(10) unsigned | NO | | | |
| expid | int(10) unsigned | NO | | | |
+-------+------------------+------+-----+---------+-------+
This is my stored proc:
Delimiter $
create procedure sp_addToMiscData(
IN UID varchar(64),
IN MID INT(10),
IN EID INT(10)
)
BEGIN
DECLARE tempid INT(10);

select mid INTO tempid from misc_data where uid=UID and mid=MID ;

IF (tempid IS NULL) THEN
insert into misc_data values(UID,MID,EID) ;
ELSE
delete from misc_data where uid=UID and mid=MID ;
insert into misc_data values(UID,MID,EID) ;
END IF;
END$

the idea is that there will be distinct entries for uid and mid columns,
so if we are adding data that has an existing record with the same value
in the mid column (for the user) we will simply overwrite that record,
otherwise, simply add the record. The stored proc looks ok to me, but
whenever I call it, it deletes EVERYTHING in the misc_data table and
simply enters one new record (the data beeing added). Help !!!
To delete a specified record, I also have this stored proc:

Delimiter $
create procedure sp_removeMiscData(
IN UID varchar(64),
IN MID INT
)
BEGIN
delete from misc_data m where m.uid=UID AND m.mid=MID;
END$
This stored proc when called simply deletes all records in the table,
yet still, when i run the delete statement at the command prompt, it
works correctly. wtf is going on?. Any suggestions will help. Hopefully,
it should not be difficult for any of the gurus out there, since these
are relatively (at least should be) simple stored procs.
Feb 10 '06 #1
1 1609
E.T. Grey wrote:
I have been busting my nut over this for pretty much most of the day and
it is driving me nuts. I posted this to an mySQL ng yesterday and I have
not had any response (I'm pulling my hair out here).

Its really a very simple stored procedure but I simply can't seem to get
it to work.

I have a simple table misc_data described as ff:

+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| uid | int(10) unsigned | NO | | | |
| mid | int(10) unsigned | NO | | | |
| expid | int(10) unsigned | NO | | | |
+-------+------------------+------+-----+---------+-------+
This is my stored proc:
Delimiter $
create procedure sp_addToMiscData(
IN UID varchar(64),
IN MID INT(10),
IN EID INT(10)
)
BEGIN
DECLARE tempid INT(10);

select mid INTO tempid from misc_data where uid=UID and mid=MID ;

IF (tempid IS NULL) THEN
insert into misc_data values(UID,MID,EID) ;
ELSE
delete from misc_data where uid=UID and mid=MID ;
insert into misc_data values(UID,MID,EID) ;
END IF;
END$

the idea is that there will be distinct entries for uid and mid columns,
so if we are adding data that has an existing record with the same value
in the mid column (for the user) we will simply overwrite that record,
otherwise, simply add the record. The stored proc looks ok to me, but
whenever I call it, it deletes EVERYTHING in the misc_data table and
simply enters one new record (the data beeing added). Help !!!
To delete a specified record, I also have this stored proc:

Delimiter $
create procedure sp_removeMiscData(
IN UID varchar(64),
IN MID INT
)
BEGIN
delete from misc_data m where m.uid=UID AND m.mid=MID;
END$
This stored proc when called simply deletes all records in the table,
yet still, when i run the delete statement at the command prompt, it
works correctly. wtf is going on?. Any suggestions will help. Hopefully,
it should not be difficult for any of the gurus out there, since these
are relatively (at least should be) simple stored procs.


Try comp.databases.mysql for MySQL questions. This group is for PHP
questions.

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

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

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
4
by: mingzhen | last post by:
Hi, I have a problem here when I code stored procedure to manipulate data in database. My idea is that if I can save all data I get in some arrays I should be able to manipulate the arrays...
5
by: Lili | last post by:
I'm having problems creating a simple stored procedure in DB2. Can someone help? Here is the screen dump when I tried to load the stored procedure. Thanks for any help. Create procedure...
3
by: Bilbo | last post by:
I have a a headscratcher here: I have a form that when submitted should do 2 things when a user enters data and then clicks the Add button. Here goes: 1. Call a stored procedure called...
3
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection...
9
by: Rickard | last post by:
Hi Can someone tell me if and how it's possible to let a user exit an execution of a Stored Procedure. As it is right now, the user makes some selections in a form, then clicks the search button....
1
by: peaceburn | last post by:
Hi, I'm gonna pull my hair in the coming days with these DB2 stored procedures. So the issue, let's assume a simple stored procedure like this : CREATE PROCEDURE MYSCHEMA.PROCEDURE1 ( )...
1
by: Ted | last post by:
In MS SQL I used the following to create a stored procedure. USE AdventureWorks; GO IF OBJECT_ID ( 'HumanResources.usp_My_Search', 'P' ) IS NOT NULL DROP PROCEDURE HumanResources.usp_My_Search;...
1
by: josequinonesii | last post by:
I'm attempting to create/update a stored procedure. it's within the navicat environment but after looking and reading various forums the environment that I'm using to create it doesn't seem to be an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.