List:General Discussion« Previous MessageNext Message »
From:Jacques Marneweck Date:September 19 2006 12:50pm
Subject:Stored Procedure issues
View as plain text  
Hi,

I have a bit of a weird question.  A couple of rows in a table I'm 
importing with data has WWWWWW_D_D_D style row content which is 
different from the usual WWWWWW_DD format data which many millions of 
rows contain.  During the process of normalising the data is there any 
way to distinguish during a stored procedure which format is being used 
prior to deciding how to store the extra D_D_D differently to the DD one?

DROP FUNCTION IF EXISTS addpackage;
DELIMITER $$
CREATE FUNCTION `addpackage` (application VARCHAR(10)) RETURNS int(11)
    DETERMINISTIC
BEGIN
  DECLARE number_id INT;
  DECLARE number_check VARCHAR(2);
  DECLARE duplicate_key CONDITION FOR SQLSTATE '23000';
  DECLARE CONTINUE HANDLER FOR duplicate_key SET @duplicate = 1;
  SET @duplicate = 0;

  SELECT SUBSTRING(application from 8 for 2) INTO number_check;

  IF number_check = '' THEN
    RETURN '-1';
  END IF;

  INSERT INTO packages (package_id, client_id, package_name) VALUES 
(SUBSTRING(application from 8 for 2), 0, '');
  SELECT package_id INTO number_id FROM packages WHERE 
package_id=SUBSTRING(application from 8 for 2);
  RETURN number_id;
END $$
DELIMITER ;

Regards
--jm

-- 
Jacques Marneweck
http://www.powertrip.co.za/
http://www.powertrip.co.za/blog/

#include <std/disclaimer.h>

Thread
Stored Procedure issuesJacques Marneweck19 Sep