Solved

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

Posted on 2008-10-15
1
522 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 24

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now