Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - BLUES
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00146533
Message ID:
00146760
Views:
27
Marc,
Can you try this: (I don't know if I figured out your relationship right)
SELECT virtual.*, iif(V_Weight=0,0,v_Value/v_weight) as price;
 FROM  Stock INNER JOIN Virtual;
    INNER JOIN Sale ;
   ON  Stock.stk_Parcel = Virtual.V_Stock ;
   ON  Stock.docnr = Sale.docnr;
 WHERE V_Box= cKey;
  AND V_Status= hStk_Sale;
  into cursor glSold
and yes, make sure that all tables are open before sql statement executes. (just in case)

Srecko

>Sreco,
>
>You are right, it somehow has to do with joining, but basically my sql was alright since it works in the command window, yielding the expected results.
>
>FYI, Fields of Virtual start with V_, Stock with stk_ and sale with sal_.
>
>I broke the sql down into 2 and now it works fine.
>
>My impression is that VFP has trouble with the division when the field is not in the first join, which makes sense. But why it works in the command window and not from my program is anybody's guess. Another VFP "feature" if you ask me :).
>
>Thank you for taking the trouble.
>
>Marc
>
>
>
>>>Hi,
>>>
>>>Has anybody seen something like this?
>>>
>>>
>>>select virtual.*, iif(V_Weight=0,0,v_Value/v_weight) as price;
>>>   from Virtual,Stock,Sale;
>>>   where stk_Parcel=V_Stock;
>>>   and sal_Docnr= stk_docnr;
>>>   and V_Box= cKey;
>>>   and V_Status= hStk_Sale;
>>>   into cursor glSold
>>>
>>>
>>>This works 1) when I open the files and executed it in the command window. 2) from the program if I leave out the iif statement, and 3) it worked yesterday :).
>>>
>>>It does not work from the program if I leave out the as price clause or change price into something else. And not only that it does not work, the sql makes vfp go south.
>>>
>>>The same happens with a similar sql but with other files.
>>>
>>>I'm running 5 with sp3 installed.
>>>
>>>TIA,
>>>
>>>Marc
>>
>>Hi,
>>I don't see how this tree tables are related (Virtual, Stock, Sale). You should make some relations. (WHERE or JOIN)
>>
>>Srecko
Previous
Reply
Map
View

Click here to load this message in the networking platform