I am using openrowset to interact with some fox pro tables.
I want to be able do error handling if the openrowset quiery fails.
When the quiery gets and error it terminates and does not seem to return and
error status.
Here is a code sample.
Update openrowset('MSDASQL',
'Driver={Microsoft Visual FoxPro
Driver};UID=;PWD=;SourceDB=\\dataserver\prod\apps\ tele\;SourceType=DBF;Exclusive=No;Background
Fetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes',
'select PROMO_CODE from prospect_conf
where area_code+home_phone in (select parea_code+phome_phon from
prospext_conf
where ctod(misc5) = date())')
set promo_code = LEft(promo_code,3)+'0'
Thanks in advance
Regarding Trapping the error from an OpenRowset failure.
I have had similar problems using OpenRowset with FoxPro tables, and found the workaround to be as follows.
1. Build the Openrowset query inside a stored procedure.
2. Call that procedure from inside a parameterised DTS package (Exec usp_Procname ?,?,?)
3. Call the DTS package from another stored procedure.
The DTS package will return a trapable error, so if you are trying to do some type of batch processing your process can continue on.
Admittedly it's a bit convoluted, but it works.
No comments:
Post a Comment