2

I am importing a .csv file using HANA studio, this is what my table looks like:

Preview Of Imported Table

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?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user69355
  • 99
  • 7

1 Answers1

3

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.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29
  • Thank you @Lars Br., renaming the column RENAME COLUMN "PIHPJ"."ji_major_storm"."outage_start" TO OUTAGE_START also seems to help. Do we know why SAP does this? – user69355 Nov 27 '19 at 15:36
  • Of course we know why SAP does this: it's part of SQL standard and implemented in other RDBMS like Oracle for decades. The main reason is to avoid identifiers that are the same as reserved words (e.g. a table called `sELect` should be avoided). – Lars Br. Nov 28 '19 at 03:32
  • And of course that has been documented for SAP HANA... https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.04/en-US/209f5020751910148fd8fe88aa4d79d9.html#loio209f5020751910148fd8fe88aa4d79d9___bsql_introduction_1sql_introduction_identifiers – Lars Br. Nov 28 '19 at 03:33