Call MS SqlServer store procedure

Hi all,
Is there a way to call SqlServer store procedure in BC4J?
I looked at other questions/answers from this forum but they all related to Oracle. My store procedures were built from multi-tables.
thanks in advance

I'm not very familiar with SQL*Server, but if you can do it from a JDBC PreparedStatement or CallableStatement, you can do it from within BC4J for sure.

Similar Messages

  • JDBC receiver adapter to call MS SQLServer stored procedure with parameters

    We are trying to use the JDBC receiver adapter to call a stored procedure in MS SQLServer with parameters.  According to the help documentation for the JDBC receiver adapter for action=EXECUTE,  "The elements within the stored procedure are interpreted as parameters" and "The parameter names must be identical to those of the stored procedure definition".  The parameters within a MS SQLServer stored procedure are required to begin with the '@' symbol.  The element names within a XML document i.e. used to call the stored procedure can not contain a special character such as '@' in the first position.  For all of the tests we have done where the parameter name in the XML document omits the '@' character, the parameters are not being received by the stored procedure.  Is there a way around this  problem?
    Thank you,
    Harold

    Hello Harold - I am facing the EXACTLY SAME problem.Pls let me know how did you fix this problem ?
    This is the message I am passing on to the DB SP:
    <?xml version="1.0" encoding="UTF-8"?>
    <MRIRequestInbound>
       <StatementName>
          <prc_FC_InsertStagingJournalEntries action="EXECUTE"/>
          <JournalData isInput="true" type="STRING">
    <NewDataSet><Table ITEM = "" ENTITYID = "" PERIOD = "" ACCTNUM = "" DEPARTMENT = "" JOBCODE = "" AMT = "" REF = "" DESCRPN = "" ENTRDATE = "" BASIS = " " BALFOR = "N" REQUESTNUM = "" ACCTNAME = "" TYPE = "" DESCRPTN = "" GDEP_DESCRPN = "" GJOB_DESCRPTN = "" JOBTYPE = ""  /></NewDataSet>
    </JournalData>
       </StatementName>
    </MRIRequestInbound>
    Out of which,
    <NewDataSet> tag contains the value of the parameter in the SP. So, my value to the SP's parameter is :
    <NewDataSet><Table ITEM = "" ENTITYID = "" PERIOD = "" ACCTNUM = "" DEPARTMENT = "" JOBCODE = "" AMT = "" REF = "" DESCRPN = "" ENTRDATE = "" BASIS = " " BALFOR = "N" REQUESTNUM = "" ACCTNAME = "" TYPE = "" DESCRPTN = "" GDEP_DESCRPN = "" GJOB_DESCRPTN = "" JOBTYPE = ""  /></NewDataSet>
    Any clue ?
    Cheers,
    Amrish.

  • JDBC receiver adapter to call MS SQLServer stored procedure

    Harold,
    Could you please post/email ou IR details to call Stored procedure and the SP itself.
    It will greately help me in my next senario.
    Thanks
    Venu
    [email protected]

    Hi,
    Go thru this blog to get the feel of this-
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    http://help.sap.com/saphelp_nw2004s/helpdata/en/22/b4d13b633f7748b4d34f3191529946/content.htm
    Regards,
    Moorthy

  • Calling a Java Store Procedure from PL\SQL

    I have this code in pl/sql
    FUNCTION validate_against_schema (p_schema IN VARCHAR2, p_xml IN BLOB)
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA
    NAME 'JAVA_SCHEMA_VALIDATOR.validation(java.lang.String, java.sql.Blob) return java.lang.String';
    And when i'm calling it i'm getting the following error:
    ORA-00932: inconsistent datatypes: expected an IN argument at position 2 that is an instance of an Oracle type convertible to an instance of a user defined Java class got an exception while converting to the user class
    I had this code working in another database user, but in the new user i get this error. There's something i have to do for the conversation BLOB-> java.sql.Blob run without a problem?

    Antonio,
    Are you sure you didn't use oracle.sql.BLOB instead of java.sql.Blob?
    Cheers,
    Colin

  • Call Store Procedure in SQL Server

    How can I call an Oracle Store Procedure in a SQL Server procedure?

    Make sure you're calling the stored procedure with the same parameters at the same database. If that's not the case then send the procedure body and how you are calling it from code and DB .
    "If there's nothing wrong with me, maybe there's something wrong with the universe!"

  • Error when call sql server stored procedure

    hello everybody,
    I'm working with MII 14 and I want call a SqlServer stored procedure provided from my customer.
    I configured a FixedQuery like this:
    [dbo].[spElencoEntrateUscite_AV] @delta = 0, @daquando='130101', @CompanyID='000002', @Elenco = @MyCursor OUTPUT
    but when i test the query i have back the error:
    com.microsoft.sqlserver.jdbc.SQLServerException: Must declare the scalar variable "@MyCursor".
    I tried also to set the query like this:
    [dbo].[spElencoEntrateUscite_AV]
    and pass Parameters:
    0
    130101
    000002
    OUTPUT
    but i have this error:
    com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function 'spElencoEntrateUscite_AV' expects parameter '@Elenco', which was not supplied.
    Any suggestion?
    thanks in advance
    Alex

    hello Kuldeep!
    yes i solved.
    I used fixed query in MII and declared the cursor:
    example:
    DECLARE @MyCursor CURSOR
    EXEC [dbo].[spElencoEntrateUscite_AV] @delta = 0,@daquando='[Param.1]', @CompanyID='[Param.2]', @Elenco = @MyCursor OUTPUT
    I hope this may help u
    Alessandro

  • How to set store procedure parameters

    Hello,
    To summarize our problem, we are not able to set store procedure parameters using JRC and without using a Viewer.
    Inside an rpt document we use a call to a store procedure that requires some input parameters.
    We attempted to pass the required parameters to the report (please see below) but it seems that those parameters are somehow ignored.
    In fact null values are always received by the store procedure.
    For your information, if the document doesnu2019t contain a call to a store proc but SQL clause parameters instead, then that works.
    Does that mean that sp parameters have to be set in a specific way?
    Please can you advise?
    Tanks a lot,
    Joseph
    This is how we set parameter values:
    private void handleParameters(ReportClientDocument pm_document, List pm_parameters) throws Exception
         ParameterFieldController pfc = pm_document.getDataDefController().getParameterFieldController();
         pfc.setCurrentValue(reportName, parameterFieldName, parameterValue);
    Then we export in a pdf file:
    private InputStream createInputStream(ReportClientDocument pm_document, String pm_reportName) throws Exception
         return (ByteArrayInputStream)pm_document.getPrintOutputController().export(ReportExportFormat.PDF);

    First question:
    Do you set the parameters before the database logon?
    Sincerely,
    Ted Ueda

  • Call store procedure wich have parameter from html

    Hi all,
    I have search function, which will allow users to select all database.
    I want to use stor procedure to handle this part , if it is a sample select procedure than just using
    CallableStatement cs = conn.prepareCall("{call SHow_SubType}");
                     ResultSet rs = cs.executeQuery();but if the store procedure have parameter
    like
    union 
    select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
            from yunnan.dbo.ViruName04    
         where SubType like'%@SubType%'        
            and Name like'%@Name%'How can I call this stored procedure in my bean
    I have
    public String getName() {
        return name;
      public void setName(String _name) {
        name = _name;
    .....thankyou

    Hi ram,
    I try every hard, but still can't got result.
    my code is
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    * TryJdbc.java
    * This servlet demonstrates using JDBC
    public class displayT extends HttpServlet {
       CallableStatement cs = null;
        ResultSet rs = null;
        Connection conn = null;
       * We want to initialized the JDBC connections here
        public void init()
            try{
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            catch( Exception e )
                e.printStackTrace();
       * This responds to an HTTP GET request.
        public void doGet(
        HttpServletRequest req,
        HttpServletResponse response)
        throws IOException, ServletException {
           String string= req.getParameter("string").trim();             
           String Type =req.getParameter("myType").trim();
            response.setContentType("text/html");
        PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head>");        
            try{
                conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;selectMethod=cursor","test","1234" );
                DatabaseMetaData md = conn.getMetaData();
                //select a database
                conn.setCatalog("HKData");
           //we made it!
            out.println("connection established sucessfully!");
                CallableStatement cs = conn.prepareCall("call SHow_SubType(?,?)}");
                  cs.setString(1, "Dk");
                   cs.setString(2,"H5");
              // register int OUT parameter
         cs.registerOutParameter( 1, java.sql.Types.VARCHAR);
         cs.registerOutParameter( 2, java.sql.Types.VARCHAR);
                     ResultSet rs = cs.executeQuery();       
                  rs = (ResultSet)cs.getObject(1);
          while(rs.next()) {
          // String Name=rs.getString(2);    
           // out.print(""+Name+"");
           // out.print("br");
           System.out.println(rs.getString(1));
            out.print("</body></html>");
              out.close();
         cs = null;
    conn.close();
    conn = null;
    catch(NullPointerException sqle)
    sqle.printStackTrace();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println("error in finding class "+ex);
    public void doPost(HttpServletRequest Request, HttpServletResponse Response)
                    throws ServletException, IOException {
    public String getServletInfo()
        return "A Simple Servlet";
    }what is the psooible mistake , I use SQL2000.
    Thank you

  • Permission problem calling a java object from a store procedure

    When I run my store procedure
    CREATE OR REPLACE PACKAGE BODY confirms_write_to_file
    AS
    FUNCTION translate(in_en_var in VARCHAR2)
    RETURN VARCHAR2
    AS LANGUAGE JAVA
    NAME 'translate.translatePath(java.lang.String) return java.lang.String';
    PROCEDURE write_to_file(in_file_name IN VARCHAR, in_en_var IN VARCHAR)
    IS
    file_handle               UTL_FILE.FILE_TYPE;
    file_location VARCHAR2(50);
    BEGIN
    file_location := translate(in_en_var);
    dbms_output.put_line ('opened file location' ||file_location);
    END write_to_file;
    END confirms_write_to_file;
    I get the following error:
    exec confirms_write_to_file.write_to_file('zzzz','$RIMS_LOG');
    SQL> exec confirms_write_to_file.write_to_file('zzzz','$RIMS_LOG');
    Exception java.security.AccessControlException: the Permission
    (java.io.FilePermission <<ALL FILES>> execute) has not been granted by
    dbms_java.grant_permission to
    SchemaProtectionDomain(RIMS|PolicyTableProxy(RIMS))
    opened file locationProcess problem
    PL/SQL procedure successfully completed.
    When I try to to grant myself the permissions
    begin
    dbms_java.grant_permission('rims','java.io.FilePermission','*','execute');
    dbms_java.grant_permission('rims', 'java.lang.RuntimePermission', '*','writeFileDescriptor' );
    end;
    I get the following Error:
    oracle.aurora.vm.IdNotFoundException: rims is not a user or role
    at oracle.aurora.rdbms.DbmsRealm.getId(DbmsRealm.java)
    at oracle.aurora.rdbms.DbmsRealm.getId(DbmsRealm.java)
    at
    oracle.aurora.rdbms.security.PolicyTableManager.findAll(PolicyTableManager.java)
    at oracle.aurora.rdbms.security.PolicyTableManager.find(PolicyTableManager.java)
    at
    oracle.aurora.rdbms.security.PolicyTableManager.activate(PolicyTableManager.java
    at
    oracle.aurora.rdbms.security.PolicyTableManager.grant(PolicyTableManager.java)
    begin
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.aurora.vm.IdNotFoundException: rims is not a user or role
    ORA-06512: at "SYS.DBMS_JAVA", line 0
    ORA-06512: at line 2
    My java code is as follows
    import java.io.*;
    import java.util.*;
    class translate
         public static String translatePath(String envar)
              Runtime rt = Runtime.getRuntime();
              int bufSize = 4096;
              byte buffer[] = new byte[bufSize];
              String path = null;
              Process p = null;
              int len = 0;
              try
                   p = rt.exec("echo "+envar);
                   BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
                   while ((len = bis.read(buffer, 0, bufSize)) != -1)
                        System.out.write(buffer, 0, len);
                   path = new String(buffer);
                   p.waitFor();
              catch(Exception e)
                   System.out.println("Exception "+e);
                   return "Process problem ";
              return path;

    Tony,
    I answered this very same question that you posted at the JavaRanch forum.
    Good Luck,
    Avi.

  • Oracle JBDC error while calling the store procedure

    HI All,
    I am get one strange error while calling a store procedure which has two parameter in and out.
    I am pass the correct XML file which reaches the RDB and then PI receives a exception error message saying:
    oracle.rdb.jdbc.common.RdbException: Closed Resultset
    where as no error log is availble in RBD for the same.
    Can anybody tell me what can be the cause of the error.
    Let me know if you requires more information on this.
    -adi

    Hi Kiran,
    Thanks..
    But I am not able to understand you. I am calling a store procedure not a table. and we not doing anything in the store procedure except return one constant value in Out parameter.
    -Adi

  • Store procedure call to fetch data in JDBC sender adapter

    Hi guys,
    I have to fetch data from a Oracle server through JDBC adpater.
    the partner has in place some store procedure that have to be used with this purpose.
    But al the time I try to call a store procedure I got error that variables are not binded.
    I fill up the query sql statement field with following text
    call <store procedure name> (v1 OUT VARCHAR2, v2 in varchar2)
    Does anyone know the syntax to access such store procedure within jdbc adapter?
    As far as I know the jdbc call the store procedure with Callable statement but the paremeters need to be linked to datatype,but here I do not see such possibility.

    HI
    A stored procedure is a subroutine available to applications accessing a relational database system. Stored procedures (sometimes called a sproc or SP) are actually stored in the database data dictionary.
    Typical uses for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures are used to consolidate and centralize logic that was originally implemented in applications. Large or complex processing that might require the execution of several SQL statements is moved into stored procedures and all applications call the procedures only.
    Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement
    Stored procedures can return result sets, i.e. the results of a SELECT statement. Such result sets can be processed using cursors by other stored procedures by associating a result set locator, or by applications. Stored procedures may also contain declared variables for processing data and cursors that allow it to loop through multiple rows in a table. The standard Structured Query Language provides IF, WHILE, LOOP, REPEAT, CASE statements, and more. Stored procedures can receive variables, return results or modify variables and return them, depending on how and where the variable is declared.
    http://help.sap.com/saphelp_nw04/helpdata/en/1d/756b3c0d592c7fe10000000a11405a/content.htm
    One of the usage is to prevent the query to directly write to the database
    http://en.wikipedia.org/wiki/Stored_procedure
    Check these:
    http://help.sap.com/saphelp_nw04s/helpdata/en/b0/676b3c255b1475e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/4d/8c103e05df2e4b95cbcc68fed61705/frameset.htm
    Integration with Databases made easy – Part 1.
    JDBC Stored Procedures
    http://help.sap.com/saphelp_nw04/helpdata/en/45/023c41325fa831e10000000a1550b0/frameset.htm
    Calling stored procs in MaxDb using SAP Xi
    cheers

  • Calling ORACLE Store Procedure with parameters in user define function

    Hi everybody,
    We have a scenario connecting Oracle DB thru JDBC adapter.
    We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
    Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
    I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
    I am looking for an example.
    Thanks in advance,
    Gigi

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • About JDBC CALL STORE PROCEDURE with out parameter is greater than 4000

    Hi Guys,
    I have a problem call store procedure with a large string.
    as i know varchar2 can contain 32767 characters in pl/sql .
    But when i used varchar2 as a out parameter in a store procedure, if the out parameter is greater than 4000 characters , it always give me error message as 'the buffer is too small'.
    why it happened?
    I read some article that says i need configure a property in data-source.xml , and jdbc 10g driver already solved this problem, but i used jdev 10.1.3.2 ,the driver should be fine.
    How can i solve this problem?
    Thanks in advance,
    AppCat

    Object is Foundation, Execute Script
    This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import java.sql.*;
    PreparedStatement stmt = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
    conn = ds.getConnection();
    stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
    stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
    rs = stmt.executeQuery();
    rs.next();
    patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
    } finally {
    try {
    rs.close();
    } catch (Exception rse) {}
    try {
    stmt.close();
    } catch (Exception sse) {}
    try {
    conn.close();
    } catch (Exception cse) {}

  • How to call a Store Procedure with IN PARAMETER

    Hi, im new using Oracle 10G with Oracle SQL Developer, my cuestion is how to call a Store Procedure with IN PARAMETER, I tried the following without results
    SELECT * FROM procedure_name(parameter);
    PROCEDURE procedure_name(parameter);
    EXEC procedure_name(parameter);
    CALL procedure_name(parameter);
    Please help me....

    Hi,
    As Beijing said,
    EXEC procedure_name(parameter);
    CALL procedure_name(parameter);work for me.
    So does
    BEGIN
        procedure_name(parameter);
    END;Can you be more specific about what you're doing? That is, are you testing it in SQL Developer? Where are you entering the commands? Where are you looking for output? Do you get error messages? Does anything else (like "SELECT SYSDATE FROM dual;") work?

  • Problem of retrieve a set of data when calling store procedure using vb with ODBC

    when I use ODBC, it can return 1 record (1 field) using pass and retrieve the parameter. but it cannot success when return a set of data (using recordset to store it), when i do it, the error message (Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if availabl. No work was done.). Why ? and how can solve it ?\
    Thanks in advance.

    oh, really ? it is not use ODBC to connecto to oracle ?
    Here is my program code:
    STORE PROCEDURE:
    PROCEDURE getInforcePolicy(PClient_ID IN VARCHAR2, PPolicy_No IN VARCHAR2, BasicCur OUT oraoledb.m_refcur, RiderCur OUT oraoledb.m_refcur)
    IS
    BEGIN
    OPEN BasicCur FOR SELECT * FROM
    inforce200111 WHERE Client_ID = PClient_ID and Policy_No = PPolicy_No and coverage_No = 1;
    OPEN RiderCur FOR SELECT * FROM
    inforce200111 WHERE Client_ID = PClient_ID and Policy_No = PPolicy_No and coverage_No <> 1;
    END getInforcePolicy;
    PACKAGE oraoledb AS
    TYPE m_refcur IS REF CURSOR;
    END oraoledb;
    Program:
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim rs2 As New ADODB.Recordset
    Dim cmd As New ADODB.Command
    Dim paramclient As New ADODB.Parameter
    Dim parampolicy As New ADODB.Parameter
    Dim I As Integer
    cn.Open "ridev", "abc","abc"
    cmd.ActiveConnection = cn
    Set paramclient = cmd.CreateParameter("PClient", adVarChar, adParamInput, 10)
    Set parampolicy = cmd.CreateParameter("PPolicy", adVarChar, adParamInput, 10)
    paramclient.Value = "0000023011"
    parampolicy.Value = "HK0010021U"
    cmd.Parameters.Append paramclient
    cmd.Parameters.Append parampolicy
    cmd.CommandText = "{call getInforcePolicy}"
    Set rs = cmd.Execute
    Do While Not rs.EOF
    Loop
    Set rs2 = rs.NextRecordset
    Do While Not rs2.EOF
    loop
    Where the RIDEV is a datasource that created from Data Source in Control Panel using the driver call "Microsoft ODBC for ORACLE"

Maybe you are looking for