Serverscript Database Query APIs


execute

Use this API to perform insert, update, or delete query operation and get the results.

Syntax: $s.execute()

Return: String

Exception: Throws error if there is any issue in the query execution.

getBlob

Use this API to read a blob field value from the query results.

Syntax: $s.getBlob(parameter)

Parameters:

  • parameter: (string) Name of the parameter whose value is to retrieve.

Return: StudioBlob

query

Use this API to initialize database query operation.

Syntax: $s.query(datasourceName, query)

Parameters:

  • datasourceName: (string) Name of the datasource on which to perform the query.
  • query: (string) The content of query to execute.

Exception: Throws error if the query initialization fails.

queryDb

Use this API to perform select query operations and get results

Syntax: $s.queryDb()

Return: String

Exception: Throws error if the query execution fails.

setBigDecimal

Use this API to set the BigDecimal value to the Query Statement.

Syntax: $s.setBigDecimal(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The name of the parameter whose value is to set.

Exception: Throws error if there is an issue in setting or converting the value to statement value.

setBytes

Use this API to set the Binary value to the Query Statement.

Syntax: $s.setBytes(position, parameterKey)

Parameters:

  • position: The position in the query statement at which the value needs to set.
  • parameterKey: (string) The name of the parameter whose value is to set.

Exception: Throws error if there is an issue in setting or converting the value to statement value.

setDate

Use this API to set the Date value to the Query Statement.

Syntax: $s.setDate(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The position in the query statement at which the value needs to set.

Exception: Throws error if there is any issue in setting or converting the value to statement value.

setInteger

Use this API to set the Integer value to the Query Statement.

Syntax: $s.setInteger(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The position in the query statement at which the value needs to set.

Return: Throws error if there is any issue in setting or converting the value to statement value.

setLong

Use this API to set the Long value to the Query Statement.

Syntax: $s.setLong(position, parameterKey)

Parameters:

  • parameterKey: (string)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The position in the query statement at which the value needs to set.

Return: Throws error if there is any issue in setting or converting the value to statement value.

setObject

Use this API to set the Object value to the Query Statement.

Syntax: $s.setObject(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The name of the parameter whose value is to set.

Exception: Throws error if there is an issue in setting or converting the value to statement value.

Example:

var position = 1;
var parameterKey = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

setString

Use this API to set the String value to the Query Statement.

Syntax: $s.setString(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The name of the parameter whose value is to set.

Exception: Throws error if there is an issue in setting or converting the value to statement value.

setTime

Use this API to set the Time value to the Query Statement.

Syntax: $s.setTime(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The position in the query statement at which the value needs to set.

Exception: Throws error if there is any issue in setting or converting the value to statement value.

setTimestamp

Use this API to set the Timestamp value to the Query Statement

Syntax: $s.setTimestamp(position, parameterKey)

Parameters:

  • position: (integer) The position in the query statement at which the value needs to set.
  • parameterKey: (string) The position in the query statement at which the value needs to set.

Exception: Throws error if there is any issue in setting or converting the value to statement value.

getDatasourceDetails

Use this API to get the datasource details.

Syntax: $s.getDatasourceDetails(datasourceName)

Parameters:

  • datasourceName: (String) Name of the datasource to retrieve its details.

Example:

var datasourceName= "KYCDS";
$s.getDatasourceDetails(datasourceName)

getFunctionDetails

Use this API to get webservice function details.

Syntax: $s.getFunctionDetails(webserviceId,functionName)

Parameters:

  • webserviceId: (String) The ID of the webservice method that includes the required function.
  • functionName: (String) The name of the function to retrieve its details.

Example:

var functionName= "getEmployee";
var webserviceId ="123";
$s.getFunctionDetails(webserviceId,functionName)

getRequest

Use this API to get HttpServletRequest.

Syntax: $s.getRequest()

Example:

var request = $s.getRequest();

print(request)

getResponse

Use this API to get HttpServletResponse.

Syntax: $s.getResponse()

Example:

var response =$s.getResponse();
print(response);

getContextName

Use this API to get context name.

Syntax: $s.getContextName()

Example:

var contextName =$s.getContextName();
print(contextName);

getApplicationName

Use this AI to get application name.

Syntax: $s.getApplicationName()

Example:

var applicationName =$s.getApplicationName();
print(applicationName);

getRequestBody

Use this API to get request body

Syntax: $s.getRequestBody()

Example:

var requestBody = $s.getRequestBody();
print(requestBody);

getHeader

Use this API to get header

Syntax: $s.getHeader(headerKey)

Parameters:

  • headerKey: (String) Specifies the key of the request header.

Example:

var header = $s.getHeader("Authorization");
print(header);

setString

Use this API to set string.

Syntax: $s.setString(position,parameterKey)

Parameters:

  • position: (Integer) The position where you want to set the string.
  • parameterKey: (String) The key of the parameter you want to set as string.

setDateTime

Use this API to set date time.

Syntax: $s.setDateTime(position,parameterKey)

Parameters:

  • position: (Integer) The position where you want to set the datetime.
  • parameterKey: (String) The key of the parameter you want to set as datetime.

sendResponse

Use this API to send response.

Syntax: $s.sendResponse(int code, String data)

Parameters:

  • int code: (Integer) The code that you want to send as response.
  • string data: (String) The data or message that you want to send as response.

getCurrentTime

Use this API to get current time.

Syntax: $s.getCurrentTime()

Example:

var currentTime = $s.getCurrentTime();
print(currentTime);

callHTTPget

Use this API to call HTTP GET.

Syntax: $s.get(sUrlstr,sParams,sHeaders)

Parameters:

  • sUrlstr: (String) Specifies the URL that you want to call.
  • sParams: (String) Specifies the parameters that you want to pass along with URL.
  • sHeaders: (String) Specifies the header tht you want to pass with the URL.

Example:

var sUrlstr = "localhost:8080/employee";
var sParams = {"userName":"asgUser"}
var sHeaders = Moorthi N pls update{"Content-Type":"application/json"}

callHTTPpost

Use this API to call HTTP POST.

Syntax: $s.get(sUrlstr,sData,sParams,sHeaders)

Parameters:

  • sUrlstr: (String) Specifies the URL that you want to post.
  • sData: (String) Specifies the data that you want post.
  • sParams: (String) Specifies the parameters that you want to pass along with URL.
  • sHeaders: (String) Specifies the header tht you want to pass with the URL.

callHTTPput

Use this API to call HTTP PUT.

Syntax: $s.get(sUrlstr,sData,sParams,sHeaders)

Parameters:

  • sUrlstr: (String) Specifies the URL that you want to put.
  • sData: (String) Specifies the data that you want put.
  • sParams: (String) Specifies the parameters that you want to pass along with URL.
  • sHeaders: (String) Specifies the header tht you want to pass with the URL.

callHTTPdelete

Use this API to call HTTP DELETE.

Syntax: $s.get(sUrlstr,sData,sParams,sHeaders)

Parameters:

  • sUrlstr: (String) Specifies the URL that you want to delete.
  • sData: (String) Specifies the data that you want delete.
  • sParams: (String) Specifies the parameters that you want to pass along with URL.
  • sHeaders: (String) Specifies the header tht you want to pass with the URL.