October 7, 2009 at 11:47 am
I'm getting this strange error in SQL Server. We are migrate data from one database to another and we are calling SPL's from SSIS packages. I've been recieving an error in the SSIs package so I ran the procedure from with SQL Server and recieved the following error
Cursorfetch: The number of variables declared in the INTO list must match that of selected columns
This is the portion of code, the DRNO and ProvID are declared earlier in the SPL
BEGIN
DECLARE @LocationID int
DECLARE db_cursor CURSOR STATIC LOCAL FOR
SELECT DISTINCT [location_id] FROM [emr].[HPSITE].[LOCATION] l
WHERE
EXISTS (SELECT 1 FROM [DMZ].[conv].cac_chrt_header cch WITH (NOLOCK)
WHERE cch.drno = @DRNO
AND cch.faccode = l.[PMS_LOCATIONID])
or EXISTS (SELECT 1 FROM [DMZ].[Medications].PatientMedications pm WITH (NOLOCK)
WHERE pm.drno = @DRNO
AND pm.faccode = l.[PMS_LOCATIONID])
or EXISTS (SELECT 1 FROM [DMZ].[Immunizations].PatientImmunizations pimm WITH (NOLOCK)
WHERE pimm.drno2 = @DRNO
AND pimm.faccode = l.[PMS_LOCATIONID])
or EXISTS (SELECT 1 FROM [DMZ].[conv].cac_laborders cl WITH (NOLOCK)
WHERE cl.drordering = @DRNO
AND cl.fachome = l.[PMS_LOCATIONID])
OPEN db_cursor
FETCH db_cursor INTO @LocationID
WHILE @@FETCH_STATUS = 0
BEGIN
exec EMR.HPSITE.CAREGIVER_SaveLocation
@aCaregiverId=@ProvID,
@aLocationId=@LocationID,
@aDefaultFlag=0,
@aAuthorId=1
FETCH db_cursor INTO @LocationID
END
CLOSE db_cursor
DEALLOCATE db_cursor
END
This runs fine if I run it from outside the SPL.
Thanks
Joe
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply