Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting date into sql or firebird;What is .t. value in
Message
From
17/09/2005 08:20:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/09/2005 08:07:43
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01050571
Message ID:
01050573
Views:
10
>when inserting date or logical value using SQL Passthrough, these generate error:
>?sqlexec(nHandle,'INSERT INTO X (date) values ({01/01/2005})')
>?sqlexec(nHandle,'INSERT INTO X (Boolfield) values (.t.)')
>
>what are the equivalent date representation such as:
>VFP: {01/01/2005}
>MSSQL: '01/01/2005' ?
>FIREBIRD: ?
>or logical 'true' representation such as
>VFP: .t.
>MSSQL: ?
>FIREBIRD:?
>
>?sqlexec(nHandle,'SELECT * from X where boolfied=.t.') &&error
>?sqlexec(nHandle,'SELECT * from X where .f.') &&to just get the structure

You don't need to know how to handle them per backend. VFP does that for you. However for SQL server they're like:

VFP: {01/01/2005}
MSSQL: '2005/01/01 00:00:00' && ODBC canonical format-other formats possible

VFP: .t.
MSSQL: 1

Easy way to handle is to use parameters instead:
myDate = {^2005/01/01}
myBool = .t.
?sqlexec(nHandle,'INSERT INTO X (date) values (?m.myDate)')
?sqlexec(nHandle,'INSERT INTO X (Boolfield) values (?m.myBool)')
PS: I assume you're not using keywords as column names or using quoted identifiers.

Update: Missed select commands at the end:
m.myBool = .t.
?sqlexec(nHandle,'SELECT * from X where boolfied=?m.myBool','myCursor')
?sqlexec(nHandle,'SELECT * from X where 1=0') &&to just get the structure
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