Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting numeric data via SQL pass-through
Message
From
04/02/2002 21:36:13
 
 
To
04/02/2002 21:15:05
Arden Weiss
Liberty Computers Ltd.
Maryland, United States
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00615200
Message ID:
00615204
Views:
13
>Newbie lost in the syntax jungle again...
>
>The following INSERT statement works fine if all of the columns/fields are character. However, if the LIC_NUMBR field were a Smallint or TinyInt field type, what is the syntax to make this work? Note '&mLIC_NUMBR' is a VFP memory variable.
>
>lnResult = SQLEXEC(hConn, ;
> "INSERT INTO EXPORT " + ;
> "(APPL_TYPE, LK_NUMBER, LIC_NUMBR, COMPANY, " + ;
> " CONG_REV ) " + ;
> "VALUES ('&mAPPL_TYPE', '&mLK_NUMBER', '&mLIC_NUMBR', '&mCOMPANY', " + ;
> " '&mCONG_REV')" )
>
>Similar question -- what if it were either a "bit" field and a "datetime" field type.
>
>Thanks in advance again...


There are several ways. One of them would be to convert each variable to char and concatenate. Something like this:
lnResult = SQLEXEC(hConn,   ;
    "INSERT INTO EXPORT " + ;
    "(APPL_TYPE, LK_NUMBER,  LIC_NUMBR, COMPANY, " + ;
    " CONG_REV ) " + ;
    "VALUES (" + TRANSFORM(mAPPL_TYPE) + ", " + ;
    TRANSFORM(mLK_NUMBER) + ", " + TRANSFORM(mLIC_NUMBR) + ;
    ", " + TRANSFORM(mCOMPANY_ + ", " + ;
    TRANSFORM(mCONG_REV) + ")"
Instead of TRANSFORM() you could also use ALLTRIM(STR())
For datetime check the Help file for TTOC()

Not related, but beware of calling a table 'EXPORT'. Use of language reserved words in naming objects is a dangerous proposition that can get to debugging troubles.


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform