Problem with my stored procedure

Results 1 to 2 of 2

Thread: Problem with my stored procedure

  1. #1
    Join Date
    Dec 1969

    Default Problem with my stored procedure

    Some pls help me. Am I missing something.<BR><BR>What this code is doing is, it is updating the records which is what I want it to do but it is not inserting new records like the last statement after the ELSE is stating.<BR><BR><BR><BR>CREATE Procedure stWSLI @WWTW_Ref_no varchar(50),@Area_served varchar(50), @Calculated_Date varchar(50), @Criteria_Type varchar(50)<BR>AS<BR><BR>DECLARE @Value numeric,<BR> @Criteria_ID int<BR>Set @Value = (SELECT Value FROM VwWSLI WHERE WWTW_REF_NO = @WWTW_REF_NO AND AREA_SERVED = @AREA_SERVED)<BR>Set @Criteria_ID = (SELECT Criteria_ID FROM Standards_Guidelines where Criteria_Type = @Criteria_Type)<BR><BR>IF EXISTS (SELECT Calculated_Date FROM CALCULATIONS)<BR><BR> BEGIN <BR> UPDATE Calculations<BR> SET <BR> WWTW_REF_NO = @WWTW_REF_NO,<BR> Calculated_Date = @Calculated_Date,<BR> Area_Served = @Area_Served, <BR> Criteria_ID = @Criteria_ID, <BR> Value = @Value<BR> WHERE WWTW_REF_NO = @WWTW_REF_NO<BR> END<BR><BR>ELSE <BR> INSERT INTO Calculations VALUES (@WWTW_Ref_No, @Area_Served, @Calculated_Date, @Criteria_ID, @Value)<BR><BR><BR>

  2. #2
    BAM Guest

    Default RE: Problem with my stored procedure

    List out the field names that will receive the data as well.<BR><BR>INSERT INTO Calculations (field1, field2, field3) VALUES (field1, field2, field3)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts