?
Solved

How to fetch record 1 by 1 in a stored procedure ????

Posted on 2008-10-15
1
Medium Priority
?
548 Views
Last Modified: 2012-05-05
Hi,
    I am using MYSQL to write a stored procedure.
    i have a table (UserTable ) which contains UserID and UserName fields.
    I have another table (ShortCutInfo) which contains UserID and ShortCutURL fields.

   I want to write a stored procedure (moreover a conversion script) which is intented to change
   update or insert record in ShortCutInfo table depending on the value of UserID present in UserTable.

   If a UserID of table UserTable exists in ShortCutInfo table then update ShortCutURL field with "URLUpdated"

  If a UserID doesnot exists in ShortCutInfo table then Insert a new record with UserID (same as in UserTable) and ShortCutID as "URLInserted".

 Can anyone suggest me how to read and do operation in an Stored procedure ???????
0
Comment
Question by:Paramhans
1 Comment
 
LVL 26

Accepted Solution

by:
Tomas Helgi Johannsson earned 1500 total points
ID: 22728979
    Hi!

Take a look at the manual : http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html  :)

Also take a look at this example on how to create multistatement procedure:
http://www.java2s.com/Tutorial/MySQL/0201__Procedure-Function/CreatingaMultistatementStoredProcedure.htm
This will give you an idea on how to solve your problem.

Regards,
   Tomas Helgi
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question