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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Help!!!!

Status
Not open for further replies.

4040er

IS-IT--Management
Apr 28, 2000
6
0
0
US
Sorry about the long code, it's is given me error in line 245 incorrect syntax near 'null<br><br>it was working until i added this part<br>select @DuesCategoryID=DuesCategoryID from DuesCategory where DuesCategoryName=@catcde<br>WHILE (@@FETCH_STATUS &lt;&gt;-1)<br>BEGIN<br>select @DuesCategoryID= case @catcde when @DuesCategoryName1 then 'Per Diem'<br>when @DuesCategoryName2 then 'Retired.'<br>when @DuesCategoryName3 then 'On Leave.'<br>when @DuesCategoryName4 then 'No Dues.'<br>when @DuesCategoryName5 then 'Agency Fee Payer.'<br>when @DuesCategoryName6 then 'Student.'<br>when @DuesCategoryName7 then 'Full Dues.'<br>when @DuesCategoryName8 then '3/4 Dues.'<br>when @DuesCategoryName9 then '1/2 Dues.'<br>when @DuesCategoryName10 then '1/4 Dues.'<br>when @DuesCategoryName11 then '1/8 Dues.'<br>when ' ' then null<br>end <br><br>This is the whole code<br><br>CREATE Procedure _RunIndividual_5 @tablename varchar(100) as<br>Exec ('declare cur_individual cursor for<br>SELECT last, first, mi, address1, address2, city, state, zip, <br>bdate, sex, soc, mstat, depnum, hometel, status, sefdte, catcde,<br>cefdate, poscd, poedte, rfdlt, duespthru, paydeduc, classcode, <br>location, deptcode, tenuresub, ocertsub, bassalary, salarystep, <br>salarycol, startdate, initdate, seniordate, worktel, votecope, votedate,<br>voteded, polparty, polactiv, precinct, condst, sendst, asmdst, rschd, <br>loccode, extra1, extra2, extra3, extra4, extra5, extra6, extra7,<br>extra8, extra9, extra10, access, pctype, os, pclocation, internet,<br>email, show, county, localname, localnum, bargin, offtitle2, offtitle,<br>regvoter, reshigh, reselem, resunit, rescollege, employer, empnum, workfax,<br>offtitle3, work_phone, const_code, class_titl, faxnumber, constit<br>FROM Conversion.dbo.'+ @tablename+' order by last,first')<br><br>----Declare variables<br>declare @last nvarchar (50) ,<br>@first nvarchar (50) ,<br>@mi nvarchar (50) ,<br>@address1 nvarchar (50) ,<br>@address2 nvarchar (50) ,<br>@city nvarchar (50) ,<br>@state nvarchar (50) ,<br>@zip nvarchar (255) ,<br>@bdate nvarchar (255) ,<br>@sex nvarchar (255) ,<br>@soc nvarchar (255) ,<br>@mstat nvarchar (255) ,<br>@depnum float ,<br>@hometel nvarchar (255) ,<br>@status nvarchar (255) ,<br>@sefdte nvarchar (255) ,<br>@catcde nvarchar (255) ,<br>@cefdate nvarchar (255) ,<br>@poscd nvarchar (50) ,<br>@poedte nvarchar (255) ,<br>@rfdlt nvarchar (255) ,<br>@duespthru nvarchar (255) ,<br>@paydeduc nvarchar (255) ,<br>@classcode nvarchar (50) ,<br>@location nvarchar (255) ,<br>@deptcode nvarchar (255) ,<br>@tenuresub nvarchar (255) ,<br>@ocertsub nvarchar (255) ,<br>@bassalary float ,<br>@salarystep float ,<br>@salarycol nvarchar (255) ,<br>@startdate nvarchar (255) ,<br>@initdate nvarchar (255) ,<br>@seniordate nvarchar (255) ,<br>@worktel nvarchar (255) ,<br>@votecope float ,<br>@votedate nvarchar (255) ,<br>@voteded nvarchar (255) ,<br>@polparty nvarchar (255) ,<br>@polactiv nvarchar (255) ,<br>@precinct nvarchar (255) ,<br>@condst nvarchar (255) ,<br>@sendst nvarchar (255) ,<br>@asmdst nvarchar (255) ,<br>@rschd nvarchar (255) ,<br>@loccode int ,<br>@extra1 nvarchar (255) ,<br>@extra2 nvarchar (255) ,<br>@extra3 nvarchar (255) ,<br>@extra4 nvarchar (255) ,<br>@extra5 nvarchar (255) ,<br>@extra6 nvarchar (255) ,<br>@extra7 nvarchar (255) ,<br>@extra8 nvarchar (255) ,<br>@extra9 nvarchar (255) ,<br>@extra10 nvarchar (255) ,<br>@access bit ,<br>@pctype nvarchar (255) ,<br>@os nvarchar (255) ,<br>@pclocation nvarchar (255) ,<br>@internet nvarchar (255) ,<br>@email nvarchar (255) ,<br>@show bit ,<br>@county nvarchar (255) ,<br>@localname nvarchar (255) ,<br>@localnum nvarchar (255) ,<br>@bargin nvarchar (255) ,<br>@offtitle2 nvarchar (255) ,<br>@offtitle nvarchar (255) ,<br>@regvoter nvarchar (255) ,<br>@reshigh nvarchar (255) ,<br>@reselem nvarchar (255) ,<br>@resunit nvarchar (255) ,<br>@rescollege nvarchar (255) ,<br>@employer nvarchar (255) ,<br>@empnum nvarchar (255) ,<br>@workfax nvarchar (255) ,<br>@offtitle3 nvarchar (255) ,<br>@work_phone nvarchar (255) ,<br>@const_code nvarchar (255) ,<br>@class_titl nvarchar (255) ,<br>@faxnumber nvarchar (255) ,<br>@constit nvarchar (255) ,<br>@DuesCategoryName nvarchar (255) ,<br>@DuesCategoryName1 nvarchar (255) ,<br>@DuesCategoryName2 nvarchar (255) ,<br>@DuesCategoryName3 nvarchar(255) ,<br>@DuesCategoryName4 nvarchar(255) ,<br>@DuesCategoryName5 nvarchar(255) ,<br>@DuesCategoryName6 nvarchar(255) ,<br>@DuesCategoryName7 nvarchar(255) ,<br>@DuesCategoryName8 nvarchar(255) ,<br>@DuesCategoryName9 nvarchar(255) ,<br>@DuesCategoryName10 nvarchar(255) ,<br>@DuesCategoryName11 nvarchar(255) ,<br>--- other variables<br>@prefix varchar(5),@prefixid uniqueidentifier,@worksiteid uniqueidentifier,<br>@chapterid uniqueidentifier,@PaymentMethodName varchar(50),@PaymentMethodID uniqueidentifier,<br>@DuesCategoryID uniqueidentifier,@DuesCategoryLocalID uniqueidentifier,<br>@DeactivateReasonID uniqueidentifier,@DeactivateReasonLocalID uniqueidentifier,<br>@JobClassID uniqueidentifier,@LocalJobClassID uniqueidentifier,<br>@MaritalStatusID uniqueidentifier,@MemberStatusID uniqueidentifier,<br>@SubjectID uniqueidentifier,@PoliticalPartyID uniqueidentifier,<br>@EmployerID uniqueidentifier, @LocalUnionID uniqueidentifier,@LocalUnionNbr char(5),<br>@addressID uniqueidentifier,@StateTerritoryId uniqueidentifier,<br>@CountryId uniqueidentifier,@PoliticallyActiveTF bit,@IndividualId uniqueidentifier<br><br><br>begin<br>open cur_individual<br>fetch from cur_individual into @last,@first, @mi,@address1,@address2,@city,@state,<br>@zip,@bdate,@sex,@soc,@mstat,@depnum,@hometel , @status , @sefdte ,<br>@catcde , @cefdate , @poscd , @poedte ,<br>@rfdlt , @duespthru , @paydeduc , <br>@classcode ,@location ,@deptcode ,<br>@tenuresub ,@ocertsub ,@bassalary ,@salarystep ,<br>@salarycol ,@startdate ,@initdate ,<br>@seniordate ,@worktel ,@votecope ,@votedate ,<br>@voteded ,@polparty ,@polactiv ,<br>@precinct ,@condst ,@sendst ,<br>@asmdst ,@rschd ,@loccode ,@extra1 ,<br>@extra2 ,@extra3 ,@extra4 ,@extra5 ,<br>@extra6 ,@extra7 ,@extra8 ,@extra9 ,<br>@extra10 ,@access ,@pctype ,@os ,<br>@pclocation ,@internet ,@email ,<br>@show ,@county ,@localname ,@localnum ,<br>@bargin ,@offtitle2 ,@offtitle ,<br>@regvoter ,@reshigh ,@reselem ,<br>@resunit ,@rescollege ,@employer ,<br>@empnum ,@workfax ,@offtitle3 ,<br>@work_phone ,@const_code ,@class_titl ,<br>@faxnumber ,@constit <br>WHILE (@@FETCH_STATUS &lt;&gt;-1)<br>BEGIN<br>select @prefix= case @sex when 'Male' then 'Mr.'<br>when 'Female' then 'Ms.'<br>when ' ' then null<br>end<br>select @prefixid=prefixid from prefix where prefixname=@prefix<br>select @worksiteid=worksiteid,@EmployerID=EmployerID from worksite where worksitenumber=@loccode<br>select @chapterid=chapterid from chapter where localunionid in (select localunionid from localunion)<br>select @PaymentMethodName= case @paydeduc when 'YES' then 'Payroll Deduction'<br>end <br>Select @PaymentMethodID=PaymentMethodID from PaymentMethod where PaymentMethodName=@PaymentMethodName<br><br>select @DuesCategoryID=DuesCategoryID from DuesCategory where DuesCategoryName=@catcde<br>WHILE (@@FETCH_STATUS &lt;&gt;-1)<br>BEGIN<br>select @DuesCategoryID= case @catcde when @DuesCategoryName1 then 'Per Diem'<br>when @DuesCategoryName2 then 'Retired.'<br>when @DuesCategoryName3 then 'On Leave.'<br>when @DuesCategoryName4 then 'No Dues.'<br>when @DuesCategoryName5 then 'Agency Fee Payer.'<br>when @DuesCategoryName6 then 'Student.'<br>when @DuesCategoryName7 then 'Full Dues.'<br>when @DuesCategoryName8 then '3/4 Dues.'<br>when @DuesCategoryName9 then '1/2 Dues.'<br>when @DuesCategoryName10 then '1/4 Dues.'<br>when @DuesCategoryName11 then '1/8 Dues.'<br>when ' ' then null<br>end <br>select @DeactivateReasonID=DeactivateReasonID,@DeactivateReasonLocalID= DeactivateReasonLocalID<br>from DeactivateReasonLocal<br>where DeactivateReasonLocalName=@rfdlt<br>select @MaritalStatusID=MaritalStatusID from MaritalStatus where MaritalStatusName=@mstat<br>select @MemberStatusID=MemberStatusID from MemberStatus where MemberStatusName=@Status<br>select @SubjectID=SubjectID from Subject where SubjectName=@tenuresub<br>select @PoliticalPartyID=PoliticalPartyID from PoliticalParty where PoliticalPartyName=@polparty<br>select @LocalUnionID=LocalUnionID,@LocalUnionNbr=LocalUnionNbr from Localunion<br>select @StateTerritoryId=StateTerritoryId,@CountryId=CountryId from Address where StateCode=@State<br>Insert into Address values (newid(),@Address1,@Address2,@City,null,@State,@zip,<br>null,null,'USA',@StateTerritoryId,@CountryId,NULL,0,@county,NULL,0,default,default,<br>default,default,default,@LocalUnionNbr,@LocalUnionId)<br>Select @AddressId=AddressId from Address where uid=@@Identity<br>select @LocalJobClassId=LocalJobClassId from LocalJobClass where LocalJobClassCode=@classcode<br><br>---- Inserting Individual rows<br><br>insert into individual values (<br>newid(), @soc, null, @last,@First, @mi,null,CONVERT(DATETIME,@bdate),@PrefixId,@sex,<br>null, 1, @MaritalStatusId,null,null,0,null,null,null, null,@WorksiteId,null,<br>@JobClassId,@LocalJobClassId, CONVERT(DATETIME,@STARTDATE), null, null, CONVERT(DATETIME,@seniordate), null, @location,@deptcode,<br>null,null, 0, @condst, @regvoter, null, @sendst, @rschd,@asmdst, @PolActiv,@PoliticalPartyId,<br>@precinct,null, null, 0, @SubjectId, null,default, 0,null, @Hometel,null, @Worktel,null,<br>@MemberStatusId, null,null, @Email,null,@ChapterId,@DuesCategoryId, <br>null, @AddressId, CONVERT(DATETIME,@CEFDATE),0 , NULL,@PaymentMethodId,@DUESPTHRU,<br>NULL,CONVERT(DATETIME,@InitDate), @DuesCategoryLocalId,null,@DeactivateReasonId, <br>null, null, @LocalUnionNbr, null, null, @LocalUnionId, null, null, 0, null,<br>null, @WorkFax, null, null, null, null, @DeactivateReasonLocalId, null, <br>null, null, null, null,null,null,null,null,null,null,null,null,null,null,<br>null,null,null,null, null,null,null,null,null,null,default,default,default,default,<br>default,@EmployerId, null, null, null,null,null,null,null,null,default,default,<br>default,default,default,default,default,default)<br><br>select @IndividualId=IndividualId from Individual where LastName=@Last and FirstName=@first and<br>MiddleName=@mi and ssn=@soc and dob=@bdate and Gender=@sex<br>insert into COPE values (newid(),null,@IndividualId,null,@votecope,convert(datetime,@votedate),<br>default,default,default,default,default,@LocalUnionNbr,@LocalUnionId)<br><br>Select @prefixId=null<br><br>fetch from cur_individual into @last,@first, @mi,@address1,@address2,@city,@state,<br>@zip,@bdate,@sex,@soc,@mstat,@depnum,@hometel , @status , @sefdte ,<br>@catcde , @cefdate , @poscd , @poedte ,<br>@rfdlt , @duespthru , @paydeduc , <br>@classcode ,@location ,@deptcode ,<br>@tenuresub ,@ocertsub ,@bassalary ,@salarystep ,<br>@salarycol ,@startdate ,@initdate ,<br>@seniordate ,@worktel ,@votecope ,@votedate ,<br>@voteded ,@polparty ,@polactiv ,<br>@precinct ,@condst ,@sendst ,<br>@asmdst ,@rschd ,@loccode ,@extra1 ,<br>@extra2 ,@extra3 ,@extra4 ,@extra5 ,<br>@extra6 ,@extra7 ,@extra8 ,@extra9 ,<br>@extra10 ,@access ,@pctype ,@os ,<br>@pclocation ,@internet ,@email ,<br>@show ,@county ,@localname ,@localnum ,<br>@bargin ,@offtitle2 ,@offtitle ,<br>@regvoter ,@reshigh ,@reselem ,<br>@resunit ,@rescollege ,@employer ,<br>@empnum ,@workfax ,@offtitle3 ,<br>@work_phone ,@const_code ,@class_titl ,<br>@faxnumber ,@constit <br>END<br>CLOSE CUR_individual<br>DEALLOCATE CUR_individual<br>END<br><br>update individual set homeaddressid=addressid where addressid is not null -- set default address as home
 
This is indeed very long code!!!<br>It seems that you have a couple of cursors running in the SP. Don't you have to deallocate each cursor before you begin a new cursor. Its hard to tell because there is just SO much code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top