Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building an SQL string
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00584086
Message ID:
00584091
Views:
22
>Hi All,
>
>I'm buiding an SQL string to execute as a macro or an EVALUATE(). Every data type I've tested thus far works except for DATE.
>
>lcSQL = 'UPDATE ' + cMyTable + ' SET ' + cMyDateField + ' = ' + dSomeDate + 'WHERE ' + MyKeyField + ' = ' + uKeyField
>
>&lcSQL
>
>Converting dSomeDate to a Character causes a data mismatch error.
>
>Any ideas on how to accomplish this?
>
>TIA
>Robert
>

See, if this method would help:
********************************************************************
*  Description.......: btcc_Container.BTC_ValStr: method to convert value into literal string representation
*  Calling Samples...:
*  Parameter List....: value_arg, tlShowCrit
*  Created by........: MDA
*  Modified by.......: Nadya Nosonovsky 10/04/2001 02:03:31 PM
********************************************************************
* * Added this stub method for support of type-specific subclasses.
* This function returns a literal value suitable for inclusion in search criterion.
* Type-specific subclasses should override this method as necessary.
lparameters value_arg, tlShowCrit     && takes 2 arguments (last one is optional argument)
* value_arg:               value of textbox control to be converted into literal.
local lcRetVal, lcType
* return value converted a literal
lcType= vartype(m.value_arg)
do case
case m.lcType ='C'
     if left(alltrim(m.value_arg),1)='"' && First character is already "
          lcRetVal= alltrim(m.value_arg)
     else
          lcRetVal= '"' + alltrim(m.value_arg) + '"'     && default treats values as character strings
     endif

case m.lcType = "D"
     local dTosVal
* check for empty date special case - doesn't like strict date syntax
     if empty(m.value_arg)
          lcRetVal ='{}'                         && most concise notation for empty date
     else
* return value converted a literal, using strict date format to avoid annoying errors
          dTosVal = dtos(m.value_arg)          && character-string date in a yyyymmdd format
          lcRetVal = '{^' + substr(m.dTosVal, 1, 4) ;
               + '-' + substr(m.dTosVal, 5, 2) ;
               + '-' + substr(m.dTosVal, 7, 2) ;
               + '}'     && default treats values as character strings
     endif
otherwise
     if m.tlShowCrit && Price, Mortgage, etc.
          lcRetVal=alltrim(transform(m.value_arg,"@$ 999,999,999,999"))
     else
          lcRetVal=transform(m.value_arg)
     endif
endcase
return m.lcRetVal
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform