Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updatable Cursors:
Message
De
17/05/2001 16:41:06
 
 
À
17/05/2001 16:27:08
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00508483
Message ID:
00508511
Vues:
21
>>>More anomalies?
>>>
>>>Is there any way to get the results of a SQL statment into an updatable cursor? We've noticed that if you use SELECT ..... INTO CURSOR, the resultant cursor is read only and can't be updated with INSERT or UPDATE statements.
>>>
>>>Cursors created with CREATE CURSOR behave just like tables and can be UPDATED, ALTERED, or INSERTED.
>>>
>>>The problem I'm trying to get beyond is the whole issue of temporary files when creating elaborate queries. Ideally, I'd like to use cursors instead of creating tables for queries requiring multiple intermediate steps.
>>>
>>>--- L
>>Assume the cursor that is the result of your query is named "query". You can write to this cursor by issuing the following command:
>>
>>USE AGAIN DBF('query') ALIAS whatever
>
>Use caution with this method. If your SELECT was fully optimized it might not have created a real cursor, but a filter on the original table. This method will create an editable alias of the original table. I wrote a little program I have used for years that makes a cursor from a SQL Select editable.
>
>Syntax MkEditbl([cExp])
>cExp = The alias of the Read-Only cursor.
>-If you don't pass it an alias, it will attempt to use the current work area.
>-It will not work on a DBF, only a cursor.
>-It returns .T. if successful.
>
>
>*:     Program:	MkEditbl
>*:		David Fluker February 1995
>*:
>*: Description:	Converts read only cursor into an editable cursor
>*:
>*: Parameter:	cAlias - Alias of Read-Only cursor
>*:*************************************************************
>PARAMETER cAlias
>PRIVATE TempArea, CurAlias
>
>*: Check parameter
>
>*: If no cAlias passed, use current workarea
>IF TYPE('cAlias') != 'C'	
>   cAlias = SELECT()	
>ENDIF
>
>*: If an empty alias was passed, use the current workarea
>IF EMPTY('cAlias') 					
>   cAlias = SELECT()				
>ENDIF
>	
>DO CASE
>   CASE NOT USED(cAlias)	
>   *: Alias is not in use - Quit.
>      RETURN .F.
>
>   CASE '.DBF' $ dbf(ALIAS(cAlias))
>   *: Not a real cursor, but a filter - Quit.
>      RETURN .F.
>ENDCASE
>		
>*: Variables
>
>TempArea = SELECT(1)	  && Empty cAlias for temporary use
>CurAlias = ALIAS(cAlias)  && Alias of cAlias
>
>USE dbf(cAlias) AGAIN IN (TempArea)
>USE dbf(TempArea) AGAIN ALIAS (CurAlias) IN (cAlias)
>USE IN (TempArea)
>
>
You make a great point. In order to make sure the DBF() of the cursor is not the underlying table one can always use the NOFILTER keyword in the query.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform