Avaloq script and escaping characters - avaloq-script

How does one escape characters in string literals in Avaloq scripts? I have been unable to find a definitive answer.
I am trying to include the new line character along with a quote in translation in the AMI

Escaping characters is the same as pl/sql, using '' (double single quotes)
And to access the return character, use util.rtn
Like this: '''it''s time''' || util.rtn || 'right?';

Related

ADF pipeline, web activity has dynamic content where double quote character is replaced

I'm looking to run an web activity as part of an ADF pipeline.
When developing the parameters in Postman, the API call includes the 'cols' parameter e.g.
baseurl/api/v2/object/?cols=["id","First_name","last_name"]
however when the pipeline is run in debug mode ADF puts a \ character before each ". ie.
baseurl/api/v2/object/?cols=[\"id\",\"First_name\",\"last_name\"]
Is there something i'm doing wrong? and is there a simple way to prevent the \ character being inserted?
Thanks
--edit-- tried the following
replacing " with the following combinations
'" (single quote, double quote)
'' (single quote, single quote)
\" (backslash, double quote)
"" (double quote, double quote) = result \"\"
replace(variable, '££', '"') create variable and wrap it with replace cannot remember exact replace format but still resulted in \"
json('"field", "field2"') = result json('\"field\", \"field2\"')
Update:
We've sent a issue to MS Q&A here. Hope this is helpful for you.
Wherever there are double quotes, there are backslashes.
If your string type is a json string type like ({"id": "id_no","First_name":"name_string"}), then we can remove the backslash via #json(JSON_String) function,because it will convert string type to json type and also remove escape characters. Otherwise, we cannot remove the backslash if it is a string type.

CSV specification - double quotes at the start and end of fields

Question (because I can't work it out), should ""hello world"" be a valid field value in a CSV file according to the specification?
i.e should:
1,""hello world"",9.5
be a valid CSV record?
(If so, then the Perl CSV-XS parser I'm using is mildly broken, but if not, then $line =~ s/\342\200\234/""/g; is a really bad idea ;) )
The weird thing is is that this code has been running without issue for years, but we've only just hit a record that started with both a left double quote and contained no comma (the above is from a CSV pre-parser).
The canonical format definition of CSV is https://www.rfc-editor.org/rfc/rfc4180.txt. It says:
Each field may or may not be enclosed in double quotes (however
some programs, such as Microsoft Excel, do not use double quotes
at all). If fields are not enclosed with double quotes, then
double quotes may not appear inside the fields. For example:
"aaa","bbb","ccc" CRLF
zzz,yyy,xxx
Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:
"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx
If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:
"aaa","b""bb","ccc"
Last rule means your line should have been:
1,"""hello world""",9.5
But not all parsers/generators follow this standard perfectly, so you might need for interoperability reasons to relax some rules. It all depends on how much you control the CSV format writing and CSV format parsing parts.
That depends on the escape character you use. If your escape character is '"' (double quote) then your line should look like
1,"""hello world""",9.5
If your escape character is '\' (backslash) then your line should look like
1,"\"hello world\"",9.5
Check your parser/environment defaults or explicitly configure your parser with the escape character you need e.g. to use backslash do:
my $csv = Text::CSV_XS->new ({ quote_char => '"', escape_char => "\\" });

Why does my LIKE statement fail with '\\_' for matching?

I have a database entry that has entries that look like this:
id | name | code_set_id
I have this particular entry that I need to find:
674272310 | raphodo/qrc_resources.py | 782732
In my rails app (2.3.8), I have a statement that evaluates to this:
SELECT * from fyles WHERE code_set_id = 782732 AND name LIKE 'raphodo/qrc\\_resources.py%';
From reading up on escaping, the above query is correct. This is supposed to correctly double escape the underscore. However this query does not find the record in the database. These queries will:
SELECT * from fyles WHERE code_set_id = 782732 AND name LIKE 'raphodo/qrc\_resources.py%';
SELECT * from fyles WHERE code_set_id = 782732 AND name LIKE 'raphodo/qrc_resources.py%';
Am I missing something here? Why is the first SQL statement not finding the correct entry?
A single backslash in the RHS of a LIKE escapes the following character:
9.7.1. LIKE
[...]
To match a literal underscore or percent sign without matching other characters, the respective character in pattern must be preceded by the escape character. The default escape character is the backslash but a different one can be selected by using the ESCAPE clause. To match the escape character itself, write two escape characters.
So this is a literal underscore in a LIKE pattern:
\_
and this is a single backslash followed by an "any character" pattern:
\\_
You want LIKE to see this:
raphodo/qrc\_resources.py%
PostgreSQL used to interpret C-stye backslash escapes in strings by default but no longer, now you have to use E'...' to use backslash escapes in string literals (unless you've changed the configuration options). The String Constants with C-style Escapes section of the manual covers this but the simple version is that these two:
name LIKE E'raphodo/qrc\\_resources.py%'
name LIKE 'raphodo/qrc\_resources.py%'
do the same thing as of PostgreSQL 9.1.
Presumably your Rails 2.3.8 app (or whatever is preparing your LIKE patterns) is assuming an older version of PostgreSQL than the one you're actually using. You'll need to adjust things to not double your backslashes (or prefix the pattern string literals with Es).

Datastage-What is the escape character for # in execute command activity?

What is the escape character for # in execute command activity? Well i was trying to replace one string in file with "#",but datastage treating # as job parameter and expecting the value to be assigned in datastage parameters.For that we need escape character for "#". I tried using \ and / as escape characters but none of them solved my problem. Thank You.
Just wanted to add that the actual answer to this question is:
\043
The expression mentioned previously (!/^\043/) is related to the first link #Damienknight posted.
Use awk to replace the # sign, and you can use the octal character code for # in the regular expression:
!/^\043/
There is a thread in DSXchange that discusses this.
Here is a guide on escape sequences in AWK expressions.
A table with ascii codes, including a column for octal values.

Can I use a single quote in a PowerShell 'string'?

I want to include an apostrophe in my string. Is it possible to do without using double quotes?
'This is a quote. Can`'t I just include a single quote in it?'
'This is another quote that doesn\'t work'
'Escape a single quote '' using a double single quote'
See the help for the quoting rules.
You can check out the help in the powershell command line by typing:
Get-Help about_Quoting_Rules
It explains that backticks are interpreted literally in single-quoted strings.
Because the contents of single-quoted strings are interpreted literally, you cannot use the backtick character to force a literal character interpretation in a single-quoted string.