We have HANA database with SPS 12 version.
We have graphical calculation view where we have created calculated column with 'if..else' logic. Below is the if else logic used -
if("COL1"='A'B','X','Y')
I am getting below error-
Invalid ExpressionSAP DBTech JDBC: [2048]: column store error: failed to set expression: [6968] Evaluator: syntax error in expression string; expected TK_RPAREN, parsing "if("COL1"='A'[here]B','X','Y')"
I have to check if COL1 has value A'B. I am not able to understand how we should handle single quote in Graphical Calculation view.
Best Regards
You can escape a single quote (') by using two single quotes (''). Note that this is not the double quote character ("):
if("COL1"='A''B','X','Y')
Change language from Column Engine to SQL
and Expression is:
if("COL1"='A''B','X','Y')
Related
I am importing a .csv file using HANA studio, this is what my table looks like:
This is what my query looks like:
select outage_start from "PIHPJ"."ji_major_storm"
and this is the error message:
SAP DBTech JDBC: [260]: invalid column name: OUTAGE_START: line 1 col 8 (at pos 7)
If I change to upper case:
select OUTAGE_START from "PIHPJ"."ji_major_storm"
I still get this error message:
SAP DBTech JDBC: [260]: invalid column name: OUTAGE_START: line 1 col 8 (at pos 7)
What’s going on??? What am I doing wrong?
That's a common challenge and there are plenty of questions and answers for it.
In short: if an object has been named with double quotation marks (" ") then the name is not converted to upper case.
To address such objects (tables, columns, views, etc.) it is necessary to use double quotation marks again.
If, for example, the column was named "outage_start", you will have to use the quotation marks and the lower case every time you use this column.
So this:
select "outage_start" from "PIHPJ"."ji_major_storm"
might work in your case.
I have BigQuery with column name order.
In this case when I try to select this column I have the error: Syntax error: Unexpected keyword ORDER.
If it some way around this error, the way where BigQuery takes it as the name of the column and not a function.
From (Oops! used a reserved word to name a column) use either backticks (``) for standard sql or square brackets ([]) for legacy sql to escape the name.
I am trying to use nested sql in postgresql tPostgresqlRow_1.
But I receive an error.
The following sql runs okay if I run it in PgAdmin.
But in Talend I receive an error.
I am getting the max date from one table and updating the column in another table.
update "STG_magento_de"."configuration_table"
set created_at=(select MAX(created_at) from "STG_magento_de"."sales_flat_order_test")
where table_name='sales_flat_order_test'
The tPostgresqlRow component expects a Java string containing the SQL statement.
The most likely problem is that you have unescaped quotes in the statement. That works fine in pgAdmin because it is valid. To pass the same statement from Talend, you'll have to escape all the quotes in the statement itself. Alternatively, you could try removing the double quotes from the SQL statement.
Remember to enclose the whole thing in quotes, so that it is a proper Java string.
create or replace function eliminarComillas (text) returns text AS $$
select replace(replace(replace($1,'**\"**','"'),'‘','‘'),'’','’');
$$ language sql;"
Following sql with escape quotes worked.
"update \"STG_magento_de\".\"configuration_table\"
set created_at=(select MAX(created_at) from \"STG_magento_de\".\"sales_flat_order_test\")
where table_name='sales_flat_order_test'"
Hi I try to use SQLite Parameterized query
but in the column name is a DOT (.)
INSERT INTO Data (`test.1`, `test.2`, `test.3`) VALUES (#test.1, #test.3,#test.3)
Returns
"SQL logic error or missing database near ".": syntax error"
INSERT INTO Data (`test.1`, `test.2`, `test.3`) VALUES ([#test.1], [#test.3],[#test.3])
Returns
"SQL logic error or missing database
no such column: #test.1"
how can i escape the dot and still use the names as parameters!?
The "proper" escape character in SQLite is double quotes:
INSERT INTO Data("test.1", "test.2", "Test.3")
VALUES ([#test1], [#test3], [#test3])
Leave the . out of the parameter name -- presumably, you have control over that.
SQLite explicitly supports the backtick for compatibility with MySQL and the square braces for compatibility with MS Access and SQL Server. (As you can see in the documentation.)
When I insert single quote in search box and press search button it gives error like:
[Microsoft][SQL Server Native Client
10.0][SQL Server]Unclosed quotation mark after the character string ' '.
You should be using parameterized queries instead of constructing your SQL by concatenation.
This will avoid SQL Injection attacks as well as resolve any single quote issues.
The quick fix it to escape the ' by doubling it (''), but this would just be a temporary workaround and your code will still be vulnerable.
Parameterize your SQL queries. There are more serious issues than this called SQL Injection.
You need to escape single quotes, like \' as you're using single quotes to surround where-statements, like where i = 'foo', then you need to write where i = '\'' to match a single quote, or lie where i = 'it\'s a good day today'