Skip to Content
avatar image
Former Member

Why does xsjs not allow table names with lower case?

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 17, 2017 at 02:14 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.