Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record not selected by a SQL query
Message
From
07/11/2018 06:25:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01662848
Message ID:
01663175
Views:
66
A few points here (already have been said mostly):

Do not rely on functions like recno() and deleted() when there are more than one table in the query.
For "not deleted", you can use SET DELETED ON.
For recno(), use it on a single table and then use the resultant cursor (might be a subquery) (BTW Recno() is a value that is calculated from record's position and record size - plus header size -, it doesn't exist as a value).

And last, do not create such an SQL string as such cSelect = " ... " and then run with &. Instead use & only on the parts that is needed (that is maybe one of the very few places where & have a use case). In your sample SQL (considering recno() and deleted() corrected) there is no need for &.


>Hi there,
>
>in myprogram I build this query:
>
>
>select kartei.* , RECNO() as satznr, kunden.vorname, kunden.name1, kunden.name2,
> kunden.name3, kunden.strasse, kunden.plz, kunden.ort from kartei  inner join kunden 
>on kartei.kundennr == kunden.kundennr where kartei.vormerker = .T. 
>and (kartei.nummer == this.cIsbn) and not DELETED() into cursor myvormerker 
>READWRITE order by best_dat DESC
>
>
>by assigning it to a var like
>
>cSelect = "Select...."
>
>And run it
>
>&cSelect
>
>Unfortunately this works only if I have more than one record fulfilling the conditions.
> If there is only one record matching it, _tally returns 0
>If I run the query in the command window, it works.
>Hay anybody some help für me?
>
>Best regards
>
>Thomas
Ç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
Next
Reply
Map
View

Click here to load this message in the networking platform