cancel
Showing results for 
Search instead for 
Did you mean: 

Why does xsjs not allow table names with lower case?

Former Member
0 Kudos

so I have the following code to remove a table from HANA using XSJS.

var table "ZNAme";

var connection = $.db.getConnection();
var query;

try{
    query = 'DROP TABLE MYSCHEMA.' + table;
    var drop = connection.prepareStatement(query);
    drop.execute();

   }catch(e){
       $.response.setBody(e.message);
}

The problem is that when I run it it gives me an error saying it can't find the table "ZNAME". For some reason it changes all the chars to upper case. However I'm creating this table also using xsjs and it works fine. I'm able to create the table, add data to it and read the data from it. The only thing I can't do is remove it. It only works if all chars are in upper case. Can someone explain to me why this is going on?

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor

In case the table name is not enclosed in double quotes the name is uppercased. You have to enclose it with double quotes:

...
query = 'DROP TABLE MYSCHEMA."' + table + '"';
...

Regards,
Florian

PS:
You said that you have used an XSJS service to create the table. Did you enclose the table name there? If not you should have seen the same behavior that the name is uppercased.

Former Member
0 Kudos

Good catch. I am using quotes in my other queries. This solved the issue. Thanks.

lbreddemann
Active Contributor

Yeah, you asked that question on SO too.

The answer is, of course, the same and so is the warning:

Your code (as you posted it) is just an example of "SQL injection here, please" code. Be sure to fix that before running that anywhere.

Answers (0)