2013-07-27 33 views
0

我正在使用nodejs 0.10.12和最新版本的node-postgres模块。 我尝试用准备好的发言,我有一些像准备好的语句nodejs不工作(使用node-postgres)

var query = client.query( {text:"insert into controller(c_name) values($1)", values:[ja]}); 
//ja is a var that contains user input came from the client side 

query.on("error", function (error) { 
console.log(error)}); 

query.on("end", function (result) { 
console.log(result), client.end()}); 

而且我得到以下

{[error: permission denied for relation controller] 
length: 116, 
name: 'error', 
severity: 'ERROR', 
code: '42501', 
detail: undefined, 
hint: undefined, 
position: undefined, 
internalPosition: undefined, 
internalQuery: undefined, 
where: undefined, 
file: '.\\src\\backend\\catalog\\aclchk.c', 
line: '3166', 
routine: 'aclcheck_error'} 
undefined 

我承认我是一个新人,节点和模块,所以我不知道如何解决这个问题。 任何建议/提示?

非常感谢您

回答

0

是传入字符串比c_name长度更大?

长度:116,

其次,你看code: '42501',这应该是错误代码,你应该在node-postgres项目文档或源搜索。