cancel
Showing results for 
Search instead for 
Did you mean: 

Insufficient privilege for inserting data through XSJS application

Aswin
Explorer
0 Kudos

Hi,

I have written an xsjs application to insert data in to Header table. Below is the code. I am using HANA Ondemand trial for this.

var conn = $.db.getConnection();

conn.prepareStatement("SET SCHEMA \"_SYS_BIC\"").execute(); 

var st = conn.prepareStatement("INSERT INTO \"p123456trial.myhanaxs.PurchaseOrder.data::PurchaseOrder.Header\" values('1','Aswani','','','','','','',1,2,3,'','','','','')"); 

st.setString(1,'2'); 

st.setString(2,'XYZ'); 

st.execute(); 

conn.commit(); 

When I tried to execute this I am getting authorization issue. Please help to assing the concern role. Below is the error.

InternalError: dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at ptime/query/checker/query_check.cc:2422 (line 3 position 0 in /p933543trial/myhanaxs/PurchaseOrder/services/insert.xsjs)

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You created this table, right? Did you also create a role for access to this table?  There is no standard role that will contain rights to a table which you created.

Aswin
Explorer
0 Kudos

Hi Thomas,

Yes I created this table. As per your suggestion I tried creating role for my table but I am getting below error.

Please help.

Regards

Aswani

vivekbhoj
Active Contributor
0 Kudos

Hi Aswani,

While defining role name, enter full path as

role p933543trial.myhanaxs.PurchaseOrder.services::SQL {

}

Regards,

Vivek

Aswin
Explorer
0 Kudos

Thanks Thomas and Vivek.

Former Member
0 Kudos

Hi Vivek,

              i want to download pdf file from database table using xsjs.i am using sps09. please share if you have code example.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Vivek,

I am facing similar isue ,

ERROR

==================================

Connection.prepareStatement: needs one argument.

My code :

==================

var id = $.request.parameters.get("id");

if (id === null) {

    $.response.setContentType("text/plain");

    $.response.addBody("id is null!");

}

var val1 = $.request.parameters.get("val1");

if (val1 === null) {

    $.response.setContentType("text/plain");

    $.response.addBody("val1 is null!");

}

var output = {};

output.data = [];

var connection = $.db.getConnection();

connection.prepareStatement("SET SCHEMA \"xxxxxxxxx","TEST\"").execute();

var st = connection.prepareStatement("INSERT INTO \"pyyyyyyytrial.myhanaxs.hello::hello.model.access\"  values(1,10.5)");

st.setString(1,'1');

st.setString(2,'10.5');

st.execute();

connection.commit();

connection.close();

model_acces is my .hbdfile.

============================

Scenario :

I using HANA TRIal version,  I have created table name TEST and trying to insert to data into that table. But I am facing above mentioned error.

File created :in project explorer -  hello project, --- xsaccess, .xsapp,,xsprivileges,hello.xsjs,model_access.hbdrole

MODELER PART - schema ( DEV one) and table TEST.

Experts, Could you please help me on this.

lucas_oliveira
Advisor
Advisor
0 Kudos

Hi,

Don't highjack answered threads. Create new ones and refer to the current one if necessary.

Please pay attention to

Thanks,

Lucas de Oliveira (moderator)

Answers (0)