首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么xsjs不允许使用小写的表名?

为什么xsjs不允许使用小写的表名?
EN

Stack Overflow用户
提问于 2017-08-17 21:31:16
回答 1查看 64关注 0票数 0

我有以下代码。

代码语言:javascript
复制
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);
}

问题是,当我运行它时,它给我一个错误,说它找不到表"ZNAME“。由于某种原因,它将所有字符都改为大写。但是,我也是使用xsjs创建这个表,它可以使用find。我能够创建表,向其中添加数据,并从中读取数据。我唯一不能做的就是把它拿掉。有人能给我解释一下为什么会这样吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-18 08:32:11

您可以使用小写字母的对象名称,方法是将它们放在双引号("<object name here>")中。

因此,您的代码可以像这样更改

代码语言:javascript
复制
query = 'DROP TABLE MYSCHEMA."' + table + '"';

去工作。

您可以在HANA文档和开发人员指南中的许多代码示例中找到对此的解释。

还请确保您的代码不会受到SQL注入威胁的影响。您绝对需要确保您的table字符串只包含一个表名,而不包含其他一些SQL命令。more on that here

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45736515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档