473,714 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(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_addToMiscDat a(
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_removeMiscDa ta(
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 1642
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_addToMiscDat a(
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_removeMiscDa ta(
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*******@attgl obal.net
=============== ===
Feb 10 '06 #2

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

Similar topics

31
14331
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? Basically: "Press any key to continue..." I beleive that I am looking for is something along the lines of a....
4
8789
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 directly. But I do not know how to declare arrays in SQL server stored procedure and do not know other ways to do the same thing. Please help me out. Thanks in advance. -mingzhen
5
6053
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 update_salary (in emp_number char(6), in rate integer) language sql begin update employee
3
1770
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 AddCompany to insert the company name from the Company Name textbox into the COMPANY table and return the @@IDENTITY of the company name just input into the database back to a label on the form. THIS IS WORKING.
3
13984
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 connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
9
1065
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. Now a stored procedure is executed, in a separate thread. This execution time can sometimes last for more than 1 minute (sometimes even more) since there are nearly 2.000.000 records in DB (SQL Srvr) and the in parameters to SProc can vary a lot. Is it...
1
7525
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 ( ) DYNAMIC RESULT SETS 1 ------------------------------------------------------------------------
1
1827
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; GO CREATE PROCEDURE HumanResources.usp_My_Search @searchstring varchar(40) AS
1
5600
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 issue. is there anything you can see that I'm not? i'm guessing it's something small my eyes have continued to overlook CREATE PROCEDURE `communityFloorplans`(in generalCommunity varchar(55), in priceRange varchar(10), in minBed varchar(2),...
0
8796
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8704
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9170
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9009
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7946
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2105
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.