I programatically create a view from a parametised query.
Once I have pulled the data from this and appended it to a local table drop the view.
However they are not being detroyed - when the program finishes you can select and brow the views created.
DO WHILE .NOT. EOF()
StartDate = ALLTRIM(THISFORM.Text2.TEXT)
EndDate = ALLTRIM(THISFORM.Text3.TEXT)
MSID = msid.msid
Viewname = MSID
CREATE SQL VIEW &Viewname REMOTE;
CONNECTION ConnectionSPS SHARE ;
AS SELECT Sts_metered_kwh.ST_MTS_ID...
...Sts_metered_kwh.kwh_total ;
FROM SPS.Sts_metered_kwh Sts_metered_kwh;
WHERE ;
Sts_metered_kwh.GMT_DATE >= TO_DATE('&StartDate','dd/mm/yyyy');
AND Sts_metered_kwh.GMT_DATE <= TO_DATE('&EndDate','dd/mm/yyyy');
AND Sts_metered_kwh.ST_MTS_ID = '&MSID'
SELECT * FROM &Viewname INTO table mydata
SELECT importsts
APPEND FROM mydata
DROP VIEW &Viewname
SELECT msid
SKIP 1
ENDDO
What can I do to clear the cursor? I only found out when I tried to process a couple of hundred records in the DO WHILE and got a maximum numbers of cursors exceeded error.
Thanks in advance.
Martin
If only everything in life was as reliable as VFP