Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Code to MySQL
Message
From
03/10/2006 17:37:45
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01158996
Message ID:
01159146
Views:
33
>>>
>>>//AND TTOD(rdt) >= ldDateLow ;
>>>
>>>//AND TTOD(rdt) <= ldDateHigh ;
>>
>>// instead ot ttod you'd simply have to have '<<ldDateLow>>' compared with the
>>// rdt field, probably with a ... and rdt between '...' and '...'
>
>I was wondering about that, Dragan; however, in the DatePicker
>code where he's setting this particular criteria, he's using TTOD on
>a DateTime() return value, striping out the timestamp, even though
>the actual comparison in the above code is a datetime field in the record.
>(Shrug.)

The reason is that with datetime intervals, you want to include the whole start and end days - meaning 0:00 on the first date, 23:59:59 on the second. It's actually easy to do in VFP:

ltDateLow=dtot(ttod(ltDateLow)) && i.e. just strip off the time and add blank back
ltDateHigh=dtot(ttod(ltDateLow)+1)-1 && i.e. one second before the next day

and then you can stay with datetimes.

>>The "into cursor" part is unnecessary, unless you want to use it for another select
>>while you're connected.
>
>As you've probably guessed, I'm more than likely just going to do this:
>
>mysql_connect();
>
>mysql_exec(The Select Statement);

The SqlExec() call, which is somewhere in the heart of the mysql_exec() call has an alias parameter - which is the alias of the VFP cursor into which it will return the results. So you need no "INTO ..." in the statement you send.

>mysql_close();
>
>and then get the heck out of Dodge :^). That is, reports aren't printed very
>often, so no need to stay connected to the databases.

>Basically, here's the pseudo code:
>
>
>lcCompany = SelectCompany(user selected company);
>lcStartDate = DatePicker(StartDate);
>lcEndDate = DatePicker(EndDate);
>CompanyRecords = QueryMySQL(lcStartDate,lcEndDate,lcCompany);
>error = PrintReport(CompanyRecords);
>
>IF (error)
> die(Get the heck out and tell user about it);
>ELSE
>  return (to main page as a happy camper);
>
And the companyrecords would be something telling you that you got some records in the cursor returned from the server. Maybe the alias of it, or "" if none returned.

>>There should be something telling MySQL to direct the result set into a temporary table.
>
>Yeah. I need to find out how to do this on the MySQL site or in one of my books.

Then no - you don't need that. You'd need it only in the case you sent multiple commands in the same string, and the second one needed to do something with the results of the first. If you're just pulling records off the server, you'll get them returned in a VFP cursor, which is a known domestic animal.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform