Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with CREATE VIEW
Message
De
16/05/2003 04:06:46
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
15/05/2003 10:18:13
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00788612
Message ID:
00789125
Vues:
31
HI Cetin,

I hope we talk about the same stuff.
I'm not sure that I can point out where my problem is because it is a little bit strange way of using views.

I don't do
>
>Create Database myTest
>for ix = 1 to 100
>  If Indbc('v1',"VIEW")
>    drop view v1
>  endif
>  create sql view v1 as ;
>    select * from (lccustomer) ;
>    where cust_id = ?lcCustID
>endfor
each time I need to change me view definition. As you say it would bloat the view and it would be worth nothing for me, because I need to USE one view and bound it to control's ControlSource property. Later I do REQUERY the view to get actual records from the underlaying structure.

If I redefine the view using CREATE VIEW I need to USE the redefined view. This will cause unbound the connection to the objects.

BTW: You don't need to drop a view, you may simple CREATE SQL VIEW again - it deletes the old definition by itself.

What I do is to manipulate the macroexpansion inside the view. The trick is that something like &?lcMacro will expand not in the moment of creating the view. It will expand at USE or REQUERY.
I do
*with version < 8.00
lcMacro = ''
  create sql view v1 as ;
    select * from (lccustomer) ;
    &?lcMacro


*notice the macroexpansion &?lcWhere

USE V1 
*this gives all Data in (lccustomer)

?CURSORGETPROP("SQL",ALIAS())
*you will see the unexpanded <i>&?lcMacro</i> in the SQL string

lcMacro = "where cust_id = lcCustID"
lcCustID = 'SomeString'
Requery()
*this gives all Records with cust_id = lcCustID

lcMacro = ''
Requery()
*this again gives all Records, but without to run a where clause in the requery
*imagin I do 
TEXT TO lcMacro
 WHERE cust_ID IN
 (SELECT Customer
 FROM otherTable;
 WHERE SomeStatement)
ENDTEXT

lcMacro = STRTRAN(STRTRAN(lcMacro,CHR(13),' '),CHR(10),'')
REQUERY()
*this will produce a differnt result, but it keeps the same View and holds all controlsources open.
>OTOH a cursoradapter might simply change the SelectCmd and CursorFill.

The problem on that again is that a Call of CursorFill result in a new cursor (even if it is the same ALIAS()) and that will lost the connection to bound controls.
I cannot manipulate the "cSelectCmd" parameter in BeforeCursorRefresh (ask me for that parameter is good for).
All what I can do is to add a Macro to the SelectCmd (direkt the property or in BeforeCursoFill) like
THIS.SelectCMD = THIS.SelectCMD+'&'+'lcMacro'
*notice the use '&'+'lcMacro', this is different to '&lcMacro' if lcMacro exists
This again will use in a macroexpansion that run in CursorFill and in Cursorrefresh()

But as I wrote in my last message, for that I need to redsign, and I would avoid it.

What I need is to keep the &?lcMacro stuff running.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform