为什么 xsjs 不允许 table 小写的名称?
Why does xsjs not allow table names with lower case?
我有以下代码。
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 upper case. Can someone explain to me why this is going on?
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);
}
问题是当我 运行 它给我一个错误,说它找不到 table "ZNAME"。由于某种原因,它将所有字符更改为大写。但是我也在使用 xsjs 创建这个 table 并且它可以找到。我能够创建 table,向其中添加数据并从中读取数据。我唯一不能做的就是删除它。有人可以向我解释为什么会这样吗?
您可以使用带小写字母的对象名称,方法是将它们放在双引号中 ("<object name here>"
)。
所以,你的代码可以这样改
query = 'DROP TABLE MYSCHEMA."' + table + '"';
上班。
您会在 HANA 文档和整个开发人员指南中的许多代码示例中找到对此的解释。
另请确保您的代码不受 SQL 注入威胁的影响。您绝对需要确保您的 table
字符串只包含一个 table 名称,而不包含其他一些 SQL 命令。
more on that here
我有以下代码。
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 upper case. Can someone explain to me why this is going on?
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);
}
问题是当我 运行 它给我一个错误,说它找不到 table "ZNAME"。由于某种原因,它将所有字符更改为大写。但是我也在使用 xsjs 创建这个 table 并且它可以找到。我能够创建 table,向其中添加数据并从中读取数据。我唯一不能做的就是删除它。有人可以向我解释为什么会这样吗?
您可以使用带小写字母的对象名称,方法是将它们放在双引号中 ("<object name here>"
)。
所以,你的代码可以这样改
query = 'DROP TABLE MYSCHEMA."' + table + '"';
上班。
您会在 HANA 文档和整个开发人员指南中的许多代码示例中找到对此的解释。
另请确保您的代码不受 SQL 注入威胁的影响。您绝对需要确保您的 table
字符串只包含一个 table 名称,而不包含其他一些 SQL 命令。
more on that here