Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Stripping apostrophes from a variable and storing back to a variable

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Stripping apostrophes from a variable and storing back to a variable
 Login/Join
 
Member
posted
I am reading a table and putting the data into variables. I then need to strip the apostrophes from the variable because it will be used in a sql statement later and the apostrophes are erroring in the select statement. Here is my code. Any suggustions would be appreciated. I am running the type commands to help trouble shoot the results.

Thanks


-RUN
-READ FAS_PICK_RESULT &TDEPT_CD.10. &TFUND_CD.A10. &TTITLE.A82.
-TYPE '&TDEPT_CD'
-TYPE '&TFUND_CD'
-TYPE '&TTITLE'
-SET &TTITLE1 = STRIP(&TTITLE, 82, '-', 'A82');
-TYPE &TTITLE1

This message has been edited. Last edited by: Kerry,
 
Posts: 7 | Location: Frankfort, KY | Registered: June 25, 2007Report This Post
Member
posted Hide Post
The example list here shows a - in the strip statement. I was testing the - but used '''' when trapping for the apostrophes.
 
Posts: 7 | Location: Frankfort, KY | Registered: June 25, 2007Report This Post
Guru
posted Hide Post
Try using the CTRAN function

decode_desc/A256V=CTRAN(256, BP8DESCRIPTION, 34, 39, decode_desc);


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Expert
posted Hide Post
Mike
here's a snippet of code that will help you understand R2's answer.
you want to extract the byte value for the apostrophe (39), and replace it using the CTRAN function for something else, in this case a quote mark (byte value 34)
DEFINE FILE CAR
atsign/I4  WITH CAR = BYTVAL('@', 'I4');
EACUTE/I4 WITH CAR=BYTVAL('é','I4');
ZERO/I4 WITH CAR=BYTVAL('0','I4');
AMPERSAND/I4 WITH CAR=BYTVAL('&','I4');
DASH/I4      WITH CAR=BYTVAL('-','I4');
APOSTROPHE/I4      WITH CAR=BYTVAL('''','I4');
QUOTE/I4     WITH CAR=BYTVAL('"','I4');
COMMA/I4     WITH CAR=BYTVAL(',','I4');
PERIOD/I4    WITH CAR=BYTVAL('.','I4');
SLASH/I4     WITH CAR=BYTVAL('/','I4');
BKSLASH/I4     WITH CAR=BYTVAL('\','I4');
BLANK/I4     WITH CAR=BYTVAL(' ','I4');
PLUS/I4      WITH CAR=BYTVAL('+','I4');
UNDER/I4     WITH CAR=BYTVAL('_','I4');
LEFTBRKT/I4  WITH CAR=BYTVAL('<','I4');
RIGHTBRKT/I4  WITH CAR=BYTVAL('>','I4');
LEFTBRACE/I4 WITH CAR=BYTVAL('[','I4');
RIGHTBRACE/I4 WITH CAR=BYTVAL(']','I4');
POUND/I4     WITH CAR=BYTVAL('#','I4');
LEFTPAR/I4 WITH CAR=BYTVAL('(','I4');
RIGHTPAR/I4 WITH CAR=BYTVAL(')','I4');
DOLLAR/I4 WITH CAR=BYTVAL('$','I4');
PIPE/I4 WITH CAR=BYTVAL('|','I4');
ASTERISK/I4 WITH CAR = BYTVAL('*','I4');
UNDERSCORE/I4  WITH CAR = BYTVAL('_','I4');
EQUAL/I4 WITH CAR = BYTVAL('=','I4');
END
-RUN
TABLE FILE CAR
HEADING
"ASCII bytvals for ctran function"
 PRINT atsign AMPERSAND DASH   APOS  COMMA    QUOTE  PERIOD PIPE
OVER   SLASH  BLANK     PLUS  UNDER LEFTBRKT RIGHTBRKT POUND
OVER  LEFTPAR RIGHTPAR LEFTBRACE RIGHTBRACE NUMZERO EQUAL DOLLAR
OVER ASTERISK UNDERSCORE ZERO EACUTE BKSLASH
 
 IF RECORDLIMIT IS 1

END

Lookup the HEXBYT function and perhaps the BITVAL as well, and add them to your repertoire.
Hope this helps.
s




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Mike,

The trick is to replace the quote by something that looks like a quote. What I usually do is use the CTRAN function. In your example:
  
-RUN
-READ FAS_PICK_RESULT &TDEPT_CD.10. &TFUND_CD.A10. &TTITLE.A82.
-TYPE &TDEPT_CD
-TYPE &TFUND_CD
-TYPE &TTITLE
-SET &TTITLE1 = CTRAN(82, &TTITLE, 39, 146, 'A82');
-TYPE &TTITLE1

39 is the decimal value of quote: '
146 is the decimal value of right-quote: ’


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Master
posted Hide Post
Another option is to use the STRREP function to replace a single apostophe with two. For us, the most common situation is using sql to update names. For example, take the last name of O'Neil. If I use STRREP to make the string O''Neil, then the SQL works just fine and I preserve the apostrophe.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Stripping apostrophes from a variable and storing back to a variable

Copyright © 1996-2020 Information Builders