Friday, March 9, 2012

Moving Source

Hi,

At a high level, this is what I need to do in a stored procedure:

CREATE VIEW TEMP_VIEW AS
SELECT * FROM SOURCE_XLS...Sheet1$

-the reason for creating the view is that the number of columns in Sheet1$ is not static.
By creating the view, I then can determine with sysobject/syscolumns how many columns I have to process for each row.

DECLARE my_cursor CURSOR
FOR SELECT * FROM TEMP_VIEW

OPEN my_cursor
DECLARE ? ?
FETCH NEXT FROM my_cursor INTO ??
WHILE <etc>
DO STUFF WITH EACH COLUMN IN THAT ROW (as noted above, this will never be a static list of columns)
END
CLOSE my_cursor
DEALLOCATE my_cursor

so, Im obviously stuck on what Im going to fetch my_cursor into. Am I limited to scalar types?

and, inside the WHILE loop, can I refer to the columns by their index (i.e. which column number they are in the result set as opposed to the name)

or is it back to the drawing board for a completely different approach.

Thanks for any input.

Cheers,
David.came up with a better approach...ignore the above.|||Very good!

-PatP

No comments:

Post a Comment