Skip to Content
avatar image
Former Member

how to call a calc view with multiple inputs on xsjs?

I have an xsjs file where I want to call a calc view with multiple parameters but my query doesn't seem to work. I've tried a calc view with a single parameter and it works, but now I have to do it with multiple parameters and my query isn't working but I'm not sure how to structure it properly. I get an error saying "error while executing query". Here is my code.

function close(closables) { 

var closable; var i; for (i = 0; i < closables.length; i++) { 

closable = closables[i]; if(closable) { closable.close(); } 
} } 

function getSalesOrders(){ 

var IP = "1852";
var DATE = "201410";

var select_all_sales_orders_query = "SELECT * FROM 
('$$IP$$', '"+IP+"'),('$$DATE$$', '"+DATE+"'))";

var salesOrdersList = []; var connection = $.db.getConnection(); 

var statement = null; var resultSet = null; try{ 

statement = connection.prepareStatement(select_all_sales_orders_query); 

resultSet = statement.executeQuery(); 

var salesOrder; 

while ( { 

    salesOrder = {}; 

  salesOrder.CAGE = resultSet.getString(1); } } 

finally { 

close([resultSet, statement, connection]); } 

 return salesOrdersList; } 

 function doGet() { 


 $.response.contentType = "application/json"; 


 } catch(err){ 

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

 $.response.setBody("Error while executing query: [" + err.message + "]"); 
 $.response.returnCode = 200; } } doGet();
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jun 17, 2017 at 01:38 PM

    For each parameter you need the 'PLACEHOLDER' syntax. For your case:

    ('$$IP$$', '"+IP+"'), 'PLACEHOLDER' = ('$$DATE$$', '"+DATE+"'))"


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for you reply Florian. I tried your solution and I keep getting the same error ("error while executing query"). I believe my code is right. I found and example in the forum with similar code but I can't figure out what's wrong with my query.