Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm new to cusors,Error 'Missing Keyword near SELECT'

Status
Not open for further replies.

Big1934

Programmer
Jul 1, 2009
33
US
firstly I know cursors are bad, but my new boss told me use one, this is why i am new to them!hmmm Forced into Evil haha!

ERROR Msg. 'Missing keyword near select' -I asume its the second select, tried with a semi colon after the from , i tried to use a table Alias and not to use one, still same message about 'Missing keyword near select'

-------------------------------------------
DECLARE Crs_DelosCatSkinner CURSOR
FOR
SELECT
--how to handle in cursor-- '????' AS Program_ID,
A.CertificateNrClean AS Policy_Number,
--how to handle in cursor-- CONVERT(varchar(10),A.TermBegin,101) AS Policy_Effective_Date,
A.CertificateNrClean AS Risk_ID_Location_ID,
--AS CoveCode,
--AS Limit,
--how to handle in cursor--'' AS Deductable,
--how to handle in cursor--'' AS Covered_Cause_Of_Loss,
--how to handle in cursor--'80' AS [Co-Insurance_Factor],
A.ProgramCode, A.CovI, A.PremiumI, A.CovII, A.PremiumII, A.CovIV, A.CovOptOtherStructures, A.CovIII_LU,
A.CovOptLossOfUse,A.CovEPersonalLiability, A.CovOptPersonalLiability, A.CovFMedPay, A.CovOptMedPay,
A.CovReplacementCostStructures, A.CovOptReplacementCostStructures, A.CovReplacementCostContents,
A.CovOptReplacementCostContents, A.CovPersonalInjury, A.CovOptPersonalInjury, A.CovAnimalLiability,
A.CovOptAnimalLiability, A.CovOrdinanceLaw, A.CovOptOrdinanceLaw, A.CovOptWaterBackUp,
A.CovLossAssessment_NonHO6, A.CovOptLossAssessment, A.CovWaterDamage, A.CovOptWaterDamage

FROM APLICATION AS A
FOR SELECT --<OPEN Crs_DelosCatSkinner
OPEN Crs_DelosCatSkinner-- the servercentral did not include this,i think se equivoquO ->OPEN Crs_DelosCatSkinner
DECLARE
@CertificateNrCleanForPolicy_Number VARCHAR(14) ,
@CertificateNrCleanForRisk_ID_Location_ID VARCHAR(14),
@ProgramCode VARCHAR(2), @CovI MONEY, @PremiumI MONEY, @CovII MONEY, @PremiumII MONEY, @CovIV MONEY, @CovOptOtherStructures MONEY, @CovIII_LU MONEY,
@CovOptLossOfUse MONEY,@CovEPersonalLiability MONEY, @CovOptPersonalLiability MONEY, @CovFMedPay MONEY, @CovOptMedPay MONEY,
@CovReplacementCostStructures INT, @CovOptReplacementCostStructures MONEY, @CovReplacementCostContents BIT,
@CovOptReplacementCostContents MONEY, @CovPersonalInjury BIT, @CovOptPersonalInjury MONEY, @CovAnimalLiability INT,
@CovOptAnimalLiability MONEY, @CovOrdinanceLaw DECIMAL(9,6), @CovOptOrdinanceLaw MONEY,@CovWaterBackUp INT,@CovOptWaterBackUp MONEY,
@CovLossAssessment_NonHO6 MONEY, @CovOptLossAssessment MONEY, @CovWaterDamage MONEY, @CovOptWaterDamage MONEY

FETCH NEXT FROM Crs_DelosCatSkinner INTO
@CertificateNrCleanForPolicy_Number,
@CertificateNrCleanForRisk_ID_Location_ID,
@ProgramCode, @CovI, @PremiumI, @CovII, @PremiumII, @CovIV, @CovOptOtherStructures, @CovIII_LU,
@CovOptLossOfUse,@CovEPersonalLiability, @CovOptPersonalLiability, @CovFMedPay, @CovOptMedPay,
@CovReplacementCostStructures, @CovOptReplacementCostStructures, @CovReplacementCostContents,
@CovOptReplacementCostContents, @CovPersonalInjury, @CovOptPersonalInjury, @CovAnimalLiability,
@CovOptAnimalLiability, @CovOrdinanceLaw, @CovOptOrdinanceLaw, @CovOptWaterBackUp,
@CovLossAssessment_NonHO6, @CovOptLossAssessment, @CovWaterDamage, @CovOptWaterDamage

WHILE FETCH_STATUS = 0 BEGIN
SELECT--CT
@CertificateNrCleanForPolicy_Number,
@CertificateNrCleanForRisk_ID_Location_ID,
@ProgramCode, @CovI, @PremiumI, @CovII, @PremiumII, @CovIV, @CovOptOtherStructures, @CovIII_LU,
@CovOptLossOfUse, @CovEPersonalLiability, @CovOptPersonalLiability, @CovFMedPay, @CovOptMedPay,
@CovReplacementCostStructures, @CovOptReplacementCostStructures, @CovReplacementCostContents,
@CovOptReplacementCostContents, @CovPersonalInjury, @CovOptPersonalInjury, @CovAnimalLiability,
@CovOptAnimalLiability, @CovOrdinanceLaw, @CovOptOrdinanceLaw, @CovOptWaterBackUp,
@CovLossAssessment_NonHO6, @CovOptLossAssessment, @CovWaterDamage, @CovOptWaterDamage

FROM vwApplication AS A
 
You have FOR SELECT twice in your first cursor declaration.

Anyway, what is the whole code of the SP - perhaps there is no need to use a cursor in your case. If boss is suggesting to use them, it doesn't necessarily mean that his advice is correct.
 
thanks, Its in place of Update becuase I do not want this CRS to update. so when i removed it, it then errored me on the OPEN CRS,the i commented out the OPEN CRS line below and it errored me on the DECLARE below the OPEN. should i put FOR UPDATE in there and
and dictate what the cursor actually does(selects) after the WHILE?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top