Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2008-10-15
1
525 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 25

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
updating table data with inner join 9 45
mcrypt_create_iv() is deprecated 4 279
SubQuery link 4 35
Combining Queries 7 27
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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