MySQL Forums
Forum List  »  Newbie

Re: Dependent Insert
Posted by: Gavin Greenwalt
Date: July 29, 2008 10:52AM

No unique columns except for the GUID in my case I am breaking up Product SKUs
(SKU-Color-Instance). So I also don't care if I have 800 Genuses. If there's a misprint it probably wasn't mine.

So I have a Table of SKUIDs:

"UglySweater, PrettySweater,etc, etc" Which contains all of the SKU specific data such as price that is independent of color.

A table of colors:
"Blue, Green, Red" which are all linked to a SKUGUID.

As a result I can have multiple "Blue" Entries which when inspecting the last two columns [SKUGUID | Color] need to be unique but neither column by itself is unique. (Multiple colors to a SKUGUID and multiple SKUGUIDs to colors.)

What I need is an AND

IF does not exist in SKUTable (SKUName == "UglySweater") THEN INSERT "UglySweater" ELSE (@ID = SKUGUID WHERE SKUName == "UglySweater")
IF does not exist in VarietyTable (SKUGUID == ID && Variety == "Blue") THEN (INSERT "Blue") ELSE (@Variety = VarietyGUID)

That's the imaginary programing language logic I'm effectively using right now in my application. But it takes about .2 seconds per entry which takes a few minutes with several thousand records. I was hoping to get that lightning fast internal reaction time that comes along with a SQL request and not having to submit commands... read out the results... evaluate it then send off another SQL command.

I'm going to go out on a limb and guess that that is a "procedure". I'll go read up on those. Finding the right chapter is always the hardest. :D

Thanks Huu and Lee!

Are stored procedures portable to other databases or are they MySQL specific? I'm trying to avoid MySQL Specific actions since I'm probably going to have to port over all the commands to Microsoft SQL Server later in the year.

Edited 2 time(s). Last edit at 07/29/2008 10:57AM by Gavin Greenwalt.

Options: ReplyQuote

Written By
July 28, 2008 11:00PM
July 29, 2008 06:46AM
July 29, 2008 08:19AM
Re: Dependent Insert
July 29, 2008 10:52AM
July 29, 2008 11:22AM
July 29, 2008 11:42AM
July 29, 2008 02:07PM
July 29, 2008 05:02PM
July 30, 2008 06:57AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.