- Log in to post comments
User bio
404 bio not found
Member since Dec 1, 2022
Posts:
Anderson has not published any posts yet.
Replies:
Certifications & Credly badges:
Anderson has no Certifications & Credly badges yet.
Followers:
Anderson has no followers yet.
Following:
Anderson has not followed anybody yet.
Text in English and Brazilian Portuguese / Texto em inglês e português brasileiro
English
Hello guys.
Years passed, and coincidentally a colleague of mine had the same question, and he found this post. It was funny that he came up to me and asked me if I was the author of the post and how I got around the problem.
I found it interesting to review the post and add a real example
The problem There is a text field that stores codes, my colleague wants to filter only records that have codes like this: '5000027-25.2022.8.25.0075'
For this he intended a regex like this: '\d{7}-\d{2}.\d{4}.8.25.\d{4}'
The question is how to do something like this in a sql query in Caché:
The solution The solution was to translate the regex to the %PATTER operator format
WTF ? How the hell did
'\d{7}\-\d{2}\.\d{4}\.8\.25\.\d{4}'become'7N1"-"2N1"."4N1".8.25."4N'?So you can understand, I've broken down the pattern, and put the translation details in the table below
\d{7}7N\-1"-"\d{2}2N\.1"."\d{4}4N\.8\.25\.1".8.25."\d{4}4NNote that the logic is simple, but unfortunately the syntax, where all the pattern operators are concatenated, is horrible :(
[%PATTERN (SQL)] (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_pattern)
I hope I helped someone with this post ;)
Brazillian Portuguese
Olá pessoal.
Anos se passaram, e coincidentemente um colega meu teve a mesma dúvida, e ele achou este post. Foi engraçado ele vir até mim e me perguntar se eu era o autor do post e como eu contornei o problema.
Achei interessante rever o post e adicionar um exemplo real
O problema Há um campo do tipo texto que armazena códigos, o meu colega quer filtrar apenas os registros que possuam códigos como este: '5000027-25.2022.8.25.0075'
Para isso ele pretendia um regex como esse: '\d{7}-\d{2}.\d{4}.8.25.\d{4}'
A questão é como fazer algo assim em uma query sql no Caché:
A solução A solução foi traduzir o regex para no formato do operador %PATTER
WTF ? Como diabos isso
'\d{7}\-\d{2}\.\d{4}\.8\.25\.\d{4}'virou isto'7N1"-"2N1"."4N1".8.25."4N'?Para poderem entender, eu destrinchei o padrão, e coloquei os detalhes da tradução na tabela abaixo
\d{7}7N\-1"-"\d{2}2N\.1"."\d{4}4N\.8\.25\.1".8.25."\d{4}4NObservem que a lógica é simples, mas infelizmente a sintaxe, onde todos os operadores do padrão ficam concatenados, é horrível :(
[%PATTERN (SQL)] (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_pattern)
Espero ter ajudado alguém com este post ;)