String functions in Sybase ASE - sap-ase

I want to retrieve "name" from "My_name_is_ABC", how to do it in Sybase-ASE ?
I tried finding on internet but inbuild functions i saw are not supported in ase.
Atleast i need to know how to do find index of a string.

Sybase ASE does have inbuilt string functions as Documented Here. You can use SUBSTRING and CHARINDEX function to get your desired result like below
select substring("My_name_is_ABC",charindex("_", "My_name_is_ABC")+1,4)
Syntax for Substring function : substring(expression, start, length )

select substr('My_name_is_ABC',locate('My_name_is_ABC','name'),4) from dummy

Related

Unaccent() function alternative in TEIID

We have a need for accent ignoring search in our application for Europian audience.
Does TEIID offer an alternative to the function mentioned here?
TEIID doesn't recognize this function:
TEIID30068 The function 'unaccent(text)' is an unknown form. Check that the function name and number of arguments is correct.
For example, when I search for the surname Malicky, I want to find the record Maličký as well.
I tried to use collate as well, but TEIID doesn't seem to be supporting that either.
You can write a custom function and implement code in Java for this function http://teiid.github.io/teiid-documents/16.0.x/content/dev/User_Defined_Functions.html
if you are using Teiid Spring Boot, the procedure is little differnt https://github.com/teiid/teiid-spring-boot/tree/master/samples/udf

Want to find all results containing specific pattern in Azure Search explorer

I want to find all records containing the pattern "170629-2" in Azure Search explorer, did try with
query string : customOfferId eq "170629-2*"
which only give one result back, which is the exactly match of "170629-2", but i do not get the records which have the patterns of "170629-20", "170629-21" or "170629-201".
Two things.
1-You can't use standard analyzer as it will break your "words" in two parts:
e.g. 170629-20 will be breaked as 170629 and another entry as 20.
2-You can use regex and specify the pattern you want:
170629-2+.*
https://learn.microsoft.com/en-us/azure/search/query-lucene-syntax#bkmk_regex
PS: use &queryType=full to allow regex

How to count occurrences of a character in a string in Presto?

I am trying to find the number of frequency of a character in a string in Presto.
like 129.11.20.0 and I wan to find number of dot . in this string.
just wondering if any function available
I was looking for the same in AWS athena, which is a managed presto service. It doesn't support regexp_count, so I used the following expression instead:
SELECT CARDINALITY(REGEXP_EXTRACT_ALL('1.1.1.1', '\.'))
You can use regexp_count function.

Substr - Instr Function Error in Power BI

I used the SEARCH function in Power BI but finds the location of the character I want to find incorrect.
The screenshot will tell you better.
Actually, I want to extract source system (android - ios etc). Essentially I can do with SQL using instr - substr but I want to use DAX Language.
Please help.
I tried to reproduce this. I had to change the semicolon to a comma to separate the arguments.
You can use MID to return substrings, which takes the start position and length as arguments.
=var str_start = search("Twitter for",[source])
var str_end = search("</a>",[source])
return mid([source],str_start, str_end-str_start)

Elastic search : Searching for integers with wildcards

I am currently using the tire client for elastic search. Lets say I have a field which is indexed as a field of type long in my elastic search mapping.
I am trying to achieve something like this:
search.query {|query| query.string "30*", :fields => ['id']}
Here 'id' is the long field about which I was talking about. But since I specify the fields in the query, the wildcard doesn't work and I end up getting the exact match as the only result.
But doing the same thing works with the _all search as the field type doesn't matter. I want this wildcard search to work while also searching for the search key in that particular field. Is there any way to do this without changing my mapping?
I see next solutions:
use multifield and make this also of a string type (but requires mapping change)
use range and translate this into something like:
(from 30 to 39) or (from 300 to 309) or (from 3000 to 3099)
or (from 30000 to 30999) or ... (to max value)
use http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html and check this using scripting
Thanks to #alex on that scripting tip. Finally I found something which worked. Phew!
So I ended up doing this(briefly):
search.query do |query|
query.filtered do |f|
f.filter :script, {
:script => "doc['id'].value.toString() ~= '^30[0-9]*$'"
}
end
end
Hope it helps.

Resources