Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HANA CLOUD PLATFORM

Hello Experts,

I am new to HANA

I have created a code, which inserts entries into table manually ( on URL).

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

Code is as below :

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

if (ID === null) { 

  $.response.contentType="text/plain";

  $.response.setBody("ID is null!") ;

  } 

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

  if (VAL1 === null) { 

  $.response.contentType="text/plain";

  $.response.setBody("VAL1 is null!");

  } 

  var output = {}; 

  output.data = []; 

  var conn = $.db.getConnection();

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

var st = conn.prepareStatement("INSERT INTO \"sxxxxxxxxxxtrial.vinni.insert.SAPSF::TEST\"  values(?,?)");

st.setString(1,ID); 

st.setString(2,VAL1);

st.executeQuery();

st.execute(); 

  conn.commit(); 

  var record = []; 

  record.push(ID); 

  record.push(VAL1); 

  output.data.push(record); 

  conn.close(); 

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

I have also created hdbtable as below,

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

table.schemaName = "NEO_xxxxxxxxxxxxxx";

table.tableType = COLUMNSTORE;

table.columns = [

{name = "ID"; sqlType = INTEGER; nullable = false;},

{name = "VAL1"; sqlType = DECIMAL; nullable = false; precision = 12; scale = 3;}];

table.indexes = [ {name = "INDEX1"; unique = true; indexColumns = ["VAL1"];}];

table.primaryKey.pkcolumns = ["ID"];

Created xsaccess, xsapp, xsprivileges,model_access.hdbrole files.

When I click the URL in xs applications ( added id=5&val1=7 to URL)

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

Below is the error I am facing :

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

InternalError: dberror(PreparedStatement.execute): 301 - unique constraint violated: Table(sxxxxxxxxxxxxtrial.vinni.insert.SAPSF::TEST) at ptime/session/eapi/jdbc/ExternalStatement.cc:927 (line 22 position 0 in /sxxxxxxxxxxtrial/vinni/insert/SAPSF/insert.xsjs)

Could you please help me out.

Thanks ,

VINNI

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question