- Tue May 16, 2017 11:37 pm
#790840
Hi,
I created a trigger to execute stored procedure (update).
$query = "execute SP_UpdateBazaarSeq '$Store','$ReqDate'";
$result = executeQuery($query, $db);
Thank you.
I created a trigger to execute stored procedure (update).
$query = "execute SP_UpdateBazaarSeq '$Store','$ReqDate'";
$result = executeQuery($query, $db);
Code: Select all
When I debug, I got error : mssql_free_result() expects parameter 1 to be resource, boolean given. How to solved this error.--Stored Procedure
IF EXISTS (SELECT store_code FROM [MDS]..ms_Bazaar_Seq
WHERE store_code = @store_code and year = @year )
BEGIN
SET @Exists = 1
CREATE TABLE [MDS]..temp_ms_Bazaar_Seq1(
[store_code] [char](3) NOT NULL,
[year] [char](4) NOT NULL,
[sequence] [int]NOT NULL
)
INSERT INTO [MDS]..temp_ms_Bazaar_Seq1
SELECT TOP 1 store_code, year, sequence from [MDS]..ms_Bazaar_Seq where store_code = @store_code and year = @year order by sequence DESC
UPDATE [MDS]..ms_Bazaar_Seq
SET sequence = b.sequence + 1
FROM [MDS]..ms_Bazaar_Seq a INNER JOIN [MDS]..temp_ms_Bazaar_Seq1 b
ON a.store_code = b.store_code and a.year = b.year
WHERE a.store_code = @store_code
AND a.year = @year
DROP TABLE [MDS]..temp_ms_Bazaar_Seq1
END
ELSE
BEGIN
SET @Exists = 0
END
RETURN @Exists
Thank you.