How to call 'stored procedure'(of an SQL database), from ServiceNow script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 12:47 AM
How to call 'stored procedure'(of an SQL database), from ServiceNow script include?
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Call the Stored Procedure via REST API (Recommended)
You can call a stored procedure through a REST API using a Script Include.
Example: Script Include
var CallStoredProc = Class.create(); CallStoredProc.prototype = { initialize: function () {}, execute: function (param1, param2) { var r = new sn_ws.RESTMessageV2('StoredProc_API', 'post'); r.setStringParameterNoEscape('param1', param1); r.setStringParameterNoEscape('param2', param2); var response = r.execute(); return response.getBody(); }, type: 'CallStoredProc' };
Use MID Server with JDBC (When REST Is Not Available)
If calling the stored procedure via REST is not an option:
Use a MID Server
Create a JDBC Probe or Scripted JDBC Activity
Execute the stored procedure from the MID Server
Conceptual Example:
EXEC dbo.my_stored_procedure @Param1 = ?, @param2 = ?
Use IntegrationHub JDBC Spoke (If Licensed)
If you have IntegrationHub Pro:
Configure a JDBC Connection
Use JDBC Query / Stored Procedure actions
Call them from Flow Designer or Subflows
Optionally trigger the flow from a Script Include
If this response proves useful, please mark it as Accept as Solution and Helpful. Doing so benefits both the community and me.
