My Oracle Support Banner

How to Set Search Expr to Query String with Quote(') in escript? (Doc ID 543203.1)

Last updated on MARCH 17, 2020

Applies to:

Siebel Tools - Version SIA [18353] and later
z*OBSOLETE: Microsoft Windows 2000


User needs to query contact BC using eScript with search criteria as:
Last Name: O'LastName
First Name: FirstName
Work Phone #: 9999999999
The character quote (') in last name is causing the problem in query.

The search expression is set as :

strsrchExpr = "[Last Name] = '" +val2.replace(/[']/g, "''")+ "' AND [First Name]= '" +val1.replace(/[']/g, "''")+ "' AND [Work Phone #]= '" +val3+ "'";

[User has already defined val1=FirstName,val2=O'LastName,val3=9999999999]
The string 'strsrchExpr is formed as below:

[Last Name]= 'O''LastName' AND [First Name]= 'FirstName' AND [Work Phone #]= '9999999999'

Though this does not give any syntax error, this does not return the record in query.

Then the following was we tried:

var strsrchExpr = "[Last Name] = '" +"\""+val2.replace(/[']/g, "''")+"\""+ "' AND [First Name]= '" +val1.replace(/[']/g, "''")+ "' AND [Work Phone #]= '" +val12+ "'";

This again doesn't give syntax error but string formed as below does not return the record either.

[Last Name] = '"O''LastName"' AND [First Name]= 'FirstName' AND [Work Phone #]= '9999999999'

How can the search expr be set to to query string with quote(') in it, in eScript?


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.