Skip to Content
0
Aug 19, 2015 at 02:39 PM

Issues while passing Input Parameter from a URL to a SELECT statement

44 Views


hi Team,

I am developing an XS JS Application in which the following is needed:

the User through a link passes the value of the Customer Id and the XS JS application reads this Input Parameter and uses it in a SELECT statement dynamically to fetch the corresponding Customer details(say eg., CITY of the Customer).

I attempted the following ways and all of them failed and getting HTTP error 500:

1)var pstmt = conn.prepareStatement( "SELECT CITY FROM MYSCHEMA.MYTABLE WHERE CUSTOMER_ID = ?" ); and

passed the '?' value as : pstmt.setInteger(1,$.request.parameters.get("custid"));

2)var custid = $.request.parameters.get("custid");

var query = "SELECT CITY FROM MYSCHEMA.MYTABLE WHERE CUSTOMER_ID =" + custid;

var rs = pstmt.executeQuery(query);

Please let me know if there is a way out of this issue. if yes, what is to be done to fetch the Customer details(CITY) for a particular customer(which is coming from the Input Parameter in the LINK/URL)?

Thanks in advance for your help in advance.

Regards,

Vishnu