• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Handling a single quote in a SQL clause for use with vvOut_execSQLtoJSON

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling a single quote in a SQL clause for use with vvOut_execSQLtoJSON

    When building the where clause for an SQL statement to use with vvOut_execSQLtoJSON()

    What “advanced technique” might anyone recommend wherein a value contains a single quote?

    For example: the value of lastName = HEBERT’S

    and the sql_where is built as:

    sql_where = ‘ where lastName like ‘
    + sq
    + %trim(lastName)
    + ‘%’
    + sq;

    This causes an error to be returned.
    VV00007 - SQL statement prep failure (SQLSTT=42601) - SQL0104 - Token % was not valid. Valid tokens:

    because it looks like this when sent to the function:

    like 'HEBERT'S%'

    So what's the magic trick to allow the single quote in the like value?

  • #2
    You need to escape the single quotes inside lastName. So try this:

    Code:
    sql_where = ' where lastName like '
                  + sq
                  + %trim(%scanRpl(sq : sq+sq : lastName))
                  + '%'
                  + sq;

    Comment

    Working...
    X