Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why does this query work, but as view does not
Message
From
14/03/2007 12:33:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01203343
Message ID:
01203514
Views:
16
>Thanks for the suggestions so far... but they do not help.
>
>Wrote 2 programs and compared results:
>1st program is basically the code below with ldDateReqd, and lnLocation defined prior to running query - it returns data
>2nd program is below
>
>SET STRICTDATE TO 0
>CLOSE TABLES all
>USE dispatch NODATA
>ldDateReqd=DATE(2007,3,14)
>lnLocation=1
>=REQUERY()
>BROWSE
>
>
>This returns no data at all.
>
>Now If I run the 1st program and do not close the tables, the data set is returned.
>
>In this query there are 5 views: Prodqty,sizeqty,rdytoship,shipped and the result dispatch. The rest are tables.
>
>If there are no tables open, i.e. run the above code without the close tables all, each of the views are empty... this is why I get no data returned to dispatch.
>
>However if I run the original code as a query, i.e.
>ldDateReqd=DATE(2007,3,14)
>lnLocation=1
>SELECT VAL(Customer.Code) as ValCode,Invhead.*, Ordhead.location, Ordhead.entered, ;
>Ordhead.priorityorder,Ordhead.customerpo,Ordhead.daterequired, ;
>Ordhead.comm1, Ordhead.comm2, Ordhead.comm3, Ordhead.terms, Customer.name, ;
>Customer.code, Customer.creditlmt, Customer.einnumber, ;
>Customer.specialdisc, Customer.dollarsuse, Ordhead.customerid, ;
>Customer.Country as CustCountry, ;
>ProdQty.TotOrdered,ProdQty.TotAllocated,ProdQty.TotShipped,.F. as Ok, ;
>RdyToShip.RdyToShip,Shipped.Shipped, ProdQty.SpecialOrd, ;
>ALLTRIM(STR(OrdHead.OrderId))+IIF(OrdHead.SBO,"B"," ") as DispOrdNo,Customer.OnHold ;
>FROM frantisi!ordhead ;
>INNER JOIN frantisi!invhead ON Ordhead.orderid = Invhead.orderid ;
>INNER JOIN frantisi!shipped ON Ordhead.orderid = Shipped.orderid ;
>INNER JOIN frantisi!rdytoship ON Invhead.invoiceno = Rdytoship.invoiceno ;
>INNER JOIN frantisi!customer ON Customer.customerid = Ordhead.customerid ;
>INNER JOIN frantisi!prodqty ON Ordhead.orderid = Prodqty.orderid ;
> WHERE ( Ordhead.daterequired < = ( ?ldDateReqd ) ;
> AND Ordhead.location = ( ?lnLocation ) ) ;
> AND ( EMPTY(dispatchdate) ;
> AND NOT (EMPTY(Invhead.picked) ) ) ;
>ORDER BY Ordhead.priorityorder desc, 1,Invhead.InvoiceNo ;
>INTO CURSOR DISPATCH
>
>The dispatch cursor has data and so do the aforementioned views.
>
>Why does one work and not the other - is the nodata clause on dispatch cause nodata to be returned by underlying views in the dispatch def'n? If so, what is a work around?
>
>Thanks so far,
>Mike

Mike,
You have references to views. Requery them first. Also qualify your first view with its databasename.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform