Splunk Search

Converting Numerical value(s) to Character(s) or String(s) - Oracle SQL to Splunk Languages - Part1

syusjk6
Engager

Hi, I am looking for Splunk search languages that might be corresponding to the following SQL: CHAR(13)

Are there any possible ways to get it done?
BTW, CHAR(13) converts 13 to the character corresponding to number 13.
(Oh, correct me if I understood the description of CHAR(13) right.)

Tags (2)
0 Karma

Kate_Lawrence-G
Contributor

If I understand your question correctly you are looking for a character value for the number that is inside the CHAR parentheses?

To do that you would need to use the rex I mentioned earlier to get it as a field and then use a lookup table to find the resulting translation. Splunk doesn't have a function for pulling this information directly.

So something like this should work:

lookup.csv 
number, ascii 
13, "carriage return"

sourcetype=mydata | rex "SQL: CHAR(?<char>\d)" | fields char | lookup chart AS number OUTPUT ascii AS "character"

This will take the numeric values you see and translate them to the ascii values you are looking for.

You will have to create the lookup table, but that is just a csv that follows the pattern that laid out.

0 Karma

syusjk6
Engager

I put some sample oracle sql on another titled by "Oracle SQL to Splunk Languages - Part 1" with respect to this question. Please refer to it.

0 Karma

syusjk6
Engager

@ richgalloway: I got it wrong. Not char(13) but chr(13)...

0 Karma

Kate_Lawrence-G
Contributor

I think you want something like this:

sourcetype=mydata | rex "SQL: CHAR(?<char>\d)" | stats values(char)
0 Karma

yannK
Splunk Employee
Splunk Employee

Hi Sysujk6,

Title updated.
If the answer from Ayn solved your problem, do you mind checking the accept button ?

0 Karma

syusjk6
Engager

Thanks. Would you refer to my question put on another title, "Oracle SQL to Splunk Languages - Part1" ?

0 Karma

yannK
Splunk Employee
Splunk Employee

and a conversion can be done with the rex command
example to convert every a to b.
mysearch | rex mode=sed "s/a/b/g"

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Would you please explain what you want to do with char(13)? Have you tried "\r"?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...