Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to ALIAS a CA the same as its VFP table?
Message
From
05/12/2006 11:38:49
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01174105
Message ID:
01174961
Views:
7
>>>>>>>There is almost nothing that can't be done with VFP :-)
>>>>>>>But when you on the way to convert your application from VFP NATIVE database to some other back end, I don't think that opening the table before invoke CA CursorFill() method is the way to go. This is just my opinion of course.
>>>>>>>
>>>>>>
>>>>>>Any particular reasons?
>>>>>>
>>>>>>Thanks,
>>>>>>Aleksey.
>>>>>
>>>>>Yes,
>>>>>If I want to move to SQL Server, but have no time to convert all my forms I will prefer to use ADO recordset or ODBC one (not for VFP 9 tables) when I build CA, just to make sure that I won't miss something.If I must use the table before CursorFill() method what will happens with my form where I have a 20-30 tables opened? Also when I finish convert I must go through all my form and remove all code where I open my tables. This can be done in CA class, but after finishing conversion I mus remove that code from my class.
>>>>>
>>>>
>>>>What is the answer to the question: "If I must use the table before CursorFill() method what will happens with my form where I have a 20-30 tables opened?" What exactly will happen?
>>>>
>>>>Thanks,
>>>>Aleksey.
>>>
>>>In BeforeOpenTables of the form I must have:
>>>
>>>USE MyNatoveVFPTable1 ALIAS SomeAliasThatCAWillExpect1 IN 0
>>>USE MyNatoveVFPTable2 ALIAS SomeAliasThatCAWillExpect2 IN 0
>>>USE MyNatoveVFPTable3 ALIAS SomeAliasThatCAWillExpect3 IN 0
>>>....
>>>USE MyNatoveVFPTable20 ALIAS SomeAliasThatCAWillExpect20 IN 0
>>>
>>>
>>>
>>>Of course all this could be done in CA class, but what if I have some CA that get data from many tables and uses many joins?
>>>Are you sure that using USE .... ALIAS and after that base CA to that Alias is easier way?
>>
>>Borislav,
>>uses a SELECT with files sourceTable or DBC!tableName (NATIVE = DBF backend),
>>if it has need VFP open the table:
>>
>>CLEAR
>>SET MULTILOCKS ON
>>
>>CREATE TABLE testCAAlias (f1 I, f2 I)
>>INSERT INTO testCAAlias values(1,1)
>>INSERT INTO testCAAlias values(2,2)
>>
>>USE
>>
>>*USE testCAAlias ALIAS SomeOtherAlias IN 0
>>
>>LOCAL oCA as CursorAdapter
>>oCA=CREATEOBJECT("CursorAdapter")
>>
>>oCA.DataSourceType="NATIVE"
>>oCA.SelectCmd="select * from testCAAlias"
>>oCA.Tables="testCAAlias"
>>oCA.KeyFieldList="f1"
>>oCA.UpdatableFieldList="f1,f2"
>>oCA.UpdateNameList="f1 testCAAlias.f1, f2 testCAAlias.f2"
>>oCA.BufferModeOverride= 5
>>
>>oCA.Alias = "testCAAlias_"
>>
>>?oCA.CursorFill()
>>*SELECT testCAAlias
>>
>>INSERT INTO testCAAlias_ VALUES (3,3)
>>DELETE FROM testCAAlias_ WHERE f1=2
>>UPDATE testCAAlias_ SET f2 =11 WHERE f1=1
>>
>>SELECT testCAAlias
>>?ALIAS()
>>LIST
>>
>>SELECT testCAAlias_
>>?ALIAS()
>>LIST
>>
>>?TABLEUPDATE(.T.)
>>
>>SELECT testCAAlias
>>?ALIAS()
>>LIST
>>
>>CLOSE TABLES all
>>USE testCAAlias
>>LIST
>>
>
>Thank you Fabio, but the question was how to create a CA that have alias as native table, so no changes to to be made in forms or any other part of the application.


The question is incorrect for me.
Use of Alias into the "SELECT..FROM Alias" is not a NATIVE ( storage ) datasource, but a access to runtime application data, then :
- it don't require a conversion to others backend,
- the cursor must exist.

If you want to use a true table with an alias, then you have to define the DBF filename somewhere, and 3 data levels are necessary:

CA.Alias,CA.tables,TablesFilename

CA baseclass support 2 levels only CA.Alias,CA.tables, then you have to define a CA subclass
with this enhancement. It is simple
( put TablesFilename into the Datasource properties ...)
a trace:
dataSource = "MyNatoveVFPTable1 SomeAliasThatCAWillExpect1,MyNatoveVFPTable2 ..."

procedure dataSource_Assign(ds)

CEx.CursorFill
IF this.d..type=="NATIVE"
  FOR k=1 to ALINES(ta,this.datasource,",")
     USE GETWORDNUM(ta[m.k],1) AGAIN IN 0 ALIAS GETWORDNUM(ta[m.k],2)
  NEXT
ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform