Cannot retrieve column in SAP Hana Studio - hana

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.

Related

Syntactical error when reading data from BigQuery using R Error: Encountered " "FROM" "FROM "" at line 1, column 10. Was expecting: <EOF>

I have checked for answers however there are none available for "FROM" "FROM "" in particular. I am trying to pull data in from BigQuery using RStudio, which is running on a Virtual Machine via Google Compute Engine, packages readr and bigrquery are installed, and the session has been authenticated. the code is as follows
project <- "testconnectrtobigquery"
sql <- "SELECT * FROM 'testconnectrtobigquery.TestDataSetRtoBQ.TestTable' LIMIT 5"
query_exec(sql, project = project)
Here is the error
> source('~/.active-rstudio-document')
Error: Encountered " "FROM" "FROM "" at line 1, column 10.
Was expecting:
<EOF>
[invalidQuery]
Please could someone explain how to correct this issue?
Generally, relational databases running SQL use single quotes for literal, string values and not for identifiers like table and column names. Specifically, according to Google BigQuery docs, GBQ follows two conventions to escape special characters, spaces, and keywords:
For Standard SQL, quoted identifiers must be enclosed by backticks.
For Legacy SQL, names should be enclosed in square brackets.
Therefore, consider replacing single quotes with backticks or brackets depending on your SQL mode:
-- BigQuery Legacy SQL
SELECT * FROM `testconnectrtobigquery.TestDataSetRtoBQ.TestTable` LIMIT 5
-- BigQuery Standard SQL
SELECT * FROM [testconnectrtobigquery.TestDataSetRtoBQ.TestTable] LIMIT 5
However, you do not have any special characters or spaces, so do not need escaping.
SELECT * FROM testconnectrtobigquery.TestDataSetRtoBQ.TestTable LIMIT 5

Replace with single quote to double single quote not working in PostgreSQL 12

Replace with single quote to double single quote not working properly in PostgreSQL 12, it was working fine in PostgreSQL 11.
PostgreSQL 12
Query: SELECT REPLACE(patient.note,'''',''''''), * FROM patient
Output Text: Medicare Secondary Veteran�s Administration
PostgreSQL 11
Query: SELECT REPLACE(patient.note,'''',''''''), * FROM patient
Output Text: Medicare Secondary Veteran’s Administration
let me know if you have any solutions.
This has nothing to do with your replacement, because the character in question is not an apostrophe ' (U+0027), but a “right single quotation mark” character ’ (U+2019).
Probably the client encoding for your connection to PostgreSQL v12 isn't set correctly, so that the character is translated to something undesirable. There may also have been a mistake in transferring the character to v12.
To diagnose this, try
SELECT note::bytea FROM patient;
If this contains e28099, the data in your database are fine, and the problem is your client encoding. This assumes that the server encoding of the databases is UTF8.

How would I fix these "ORA-00933: SQL command not properly ended" "ORA-00923: FROM keyword not found where expected" errors?

This Statement:
SELECT id, units, cost FROM inventory_list WHERE cost <= 20;
Gives me:
ORA-00923: FROM keyword not found where expected
While this statement:
SELECT * FROM items WHERE ilt_id = 'il010230126' OR ilt_id = 'il010230128';
Gives me:
ORA-00933: SQL command not properly ended
Not sure about this and may be version dependent (below link is for oracle 10g... but you can see on this site
https://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm
That cost is an oracle reserved keyword, so it is not wise to use it as a column name.
If you have no control of the table I think you may be able to surround it in double quotes eg select "COST" to avoid oracle picking it up as a reserved word.
By default Oracle creates fields in uppercase so the field name will need to be in uppercase unless when the table was created it was forced into different case by surrounding it in Quotes.
Check that you don't have invisible characters in your file and that you're using the right encoding. I sometimes accidentally introduce them because I have a non english keyboard map and accidentally hit the wrong key combination.
Just type again one of your SQL statements and test them.

String with single quote in graphical calculation view HANA

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')

Forward slash (/) character in SAP Vora table columns

I've got data from a SAP BW InfoProvider written to HDFS. Now I'm trying to make that data available for reporting in Vora 1.3.
I'm trying to run a statement in Vora Tools SQL console, starting with:
CREATE TABLE F002_5_F (calyear string,
calmonth string,
/bic/zfiscweek string,
doc_currcy string,
co_area string,
/bic/zbillamt decimal(17,2),
......)
USING com.sap.spark.vora
OPTIONS (.....
And upon execution Vora reports a syntax error in lines for fields with names containing "/bic/" part.
As a workaround, I tried quoting field names, e.g. "/bic/zfiscweek". But then Vora reported a syntax error in the line "USING com.sap.spark.vora".
Any comment on how field names with "/" character should be treated in Vora modelling?
Quoted column names are not supported. You have to replace the slash "/" with another character so that the column name becomes a valid SQL identifier.
Try surrounding the column names with backticks.
CREATE TABLE SLASHTABLE (`/A1` double, `/A2` int, `/A3` string)
USING com.sap.spark.vora
OPTIONS (files "/user/vora/test.csv");
This also works in SELECT queries:
SELECT `/A1` from SLASHTABLE;