DELIMITER $$
DROP PROCEDURE IF EXISTS `sp_purchase_details_save` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_purchase_details_save`(
OUT Param_Return integer,
INOUT Param_Id integer,
IN Param_PurchaseId integer,
IN Param_MediaId integer,
IN Param_Qty smallint,
IN Param_Amount double,
IN Param_MRP double,
IN Param_Discount double,
IN Param_ValidFrom DATETIME,
IN Param_ValidUpto DATETIME,
IN Param_SubscriptionTypeId integer,
IN Param_AddedBy INTEGER
)
BEGIN
IF EXISTS(SELECT Id FROM purchase_details WHERE Id != Param_Id and PurchaseId like Param_PurchaseId) THEN
SET Param_Return = 0;
ELSE
IF (Param_Id > 0) THEN
UPDATE purchase_details
SET PurchaseId=Param_PurchaseId, MediaId=Param_MediaId, Qty=Param_Qty, Amount=Param_Amount, MRP=Param_MRP, Discount=Param_Discount, ValidFrom=Param_ValidFrom, ValidUpto=Param_ValidUpto, SubscriptionTypeId=Param_SubscriptionTypeId, UpdatedBy=Param_AddedBy, UpdatedDate = NOW()
WHERE Id = Param_Id;
SET Param_Return = 2;
ELSE
INSERT INTO purchase_details (PurchaseId, MediaId, Qty, Amount, MRP, Discount, ValidFrom, ValidUpto, SubscriptionTypeId, AddedBy, AddedDate)
VALUES (Param_PurchaseId, Param_MediaId, Param_Qty, Param_Amount, Param_MRP, Param_Discount, Param_ValidFrom, Param_ValidUpto, Param_SubscriptionTypeId, Param_AddedBy, NOW());
SET Param_Return = LAST_INSERT_ID();
END IF;
END IF;
END $$
DELIMITER ;
<<<<<<<<<<<<<<<<<<<<<ß--------------------------à>>>>>>>>>>>>>>>>>>>
DELIMITER $$
DROP PROCEDURE IF EXISTS `lms_db`.`sp_test` $$
CREATE PROCEDURE `lms_db`.`sp_test` ()
BEGIN
DECLARE PARAM1 int;
DECLARE PARAM2 int;
DECLARE PARAM3 date;
DECLARE PARAM4 date;
SET PARAM2 = 0;
SET PARAM3 = now();
SET PARAM4 = adddate(now(),400);
CALL sp_purchase_details_save(PARAM1,PARAM2,12,1,1,100,100,0,PARAM3,PARAM4,1,1);
SELECT PARAM1, PARAM2;
END $$
DELIMITER ;
<<<<<<<<<<<<<<<<<<<ß--------------------------------------------à>>>>>>>>>>>>>>>>>
Call sp_test
This is my first time i visit here. I found such a substantial number of interesting stuff in your blog especially its examination. Really its inconceivable article. Keep it up. Call Center Management
ReplyDelete