More problems with revExecuteSQL

Trevor DeVore lists at mangomultimedia.com
Thu Nov 1 10:07:28 EDT 2007


Dave,

Variable substitution doesn't escape characters for in version of Rev  
prior to 2.9. Just run all values you want to insert into the  
database through a function such as the following. Note that the  
PostGreSQL switch statement is based on what I read in the docs. I  
haven't used PostGreSQL myself so I haven't tested it.

-- 
Trevor DeVore
Blue Mango Learning Systems
www.bluemangolearning.com    -    www.screensteps.com



on _escapeStringByRef pDBType, @pString
     switch word 1 of pDBType
         case "valentina"
             replace numtochar(92) with numtochar(92) & numtochar(92)  
in pString --> \ to \\
                     replace numtochar(39) with numtochar(39) &  
numtochar(39) in pString --> ' to ''
             break

         case "mysql"
             replace numtochar(92) with numtochar(92) & numtochar(92)  
in pString --> \ to \\
                     replace numtochar(39) with numtochar(92) &  
numtochar(39) in pString --> ' to \'
             replace numtochar(34) with numtochar(92) & numtochar(34)  
in pString --> " to \"
             replace numtochar(0) with numtochar(92) & numtochar(48)  
in pString --> NULL to \0
             replace numtochar(26) with numtochar(92) & numtochar(90)  
in pString --> Control-Z to \Z
             replace numtochar(10) with numtochar(92) & numtochar 
(110) in pString --> newline to \n
             replace numtochar(13) with numtochar(92) & numtochar 
(114) in pString --> carriage return to \r
             replace numtochar(9) with numtochar(92) & numtochar(116)  
in pString --> tab to \t
             replace numtochar(8) with numtochar(92) & numtochar(98)  
in pString --> backspace to \b
             break
         case "postgresql"
             replace numtochar(92) with numtochar(92) & numtochar(92)  
in pString --> \ to \\
                     replace numtochar(39) with numtochar(39) &  
numtochar(39) in pString --> ' to ''
             replace numtochar(12) with numtochar(92) & numtochar 
(102) in pString --> formfeed to \f
             replace numtochar(10) with numtochar(92) & numtochar 
(110) in pString --> newline to \n
             replace numtochar(13) with numtochar(92) & numtochar 
(114) in pString --> carriage return to \r
             replace numtochar(9) with numtochar(92) & numtochar(116)  
in pString --> tab to \t
             replace numtochar(8) with numtochar(92) & numtochar(98)  
in pString --> backspace to \b
             break
         case "sqlite"
         default
             replace numtochar(39) with numtochar(39) & numtochar(39)  
in pString --> ' to ''
             break
     end SWITCH
end _escapeStringByRef




More information about the use-livecode mailing list