4 Replies Latest reply: Nov 3, 2008 6:23 AM by 656067 RSS

    Using a StoredProcedureCall - session

    656067
      Hi,
      pls help me!
      I'm a newbie in the use of TopLink. I want call PL/SQL stored procedures from Oracle. I try example ftrom TopLink documentation:

      Example 109–46 Specifying a StoredProcedureCall with an Input Argument: JDBC Data
      Types
      // CREATE PROCEDURE INSERT_EMPLOYEE(L_NAME IN VARCHAR) AS
      // BEGIN
      // Insert an EMP record initialized with last name.
      // END;
      StoredProcedureCall spcall = new StoredProcedureCall();
      spcall.setProcedureName("INSERT_EMPLOYEE");
      spcall.addNamedArgument("L_NAME", "last_name");
      DataModifyQuery query = new DataModifyQuery();
      query.setCall(spcall);
      query.addArgument("last_name"); // input
      Vector arguments = new Vector();
      arguments.add("MacDonald");
      session.executeQuery(query, arguments);

      But I don't now, how works this "session" - session.executeQuery(query, arguments);

      Please, somebody help me. The best would be an example, or even source code, how to create and use these sessions.
        • 1. Re: Using a StoredProcedureCall - session
          Cdelahun-Oracle
          Hello,

          The early parts of the documentation you are looking at describe sessions. For a tutorial and examples, I'd recommend:
          http://www.oracle.com/technology/products/ias/toplink/doc/11110/tutorial/index.htm

          http://www.oracle.com/technology/products/ias/toplink/doc/index.html
          has all the docs and tutorials for different TopLink versions.


          Best Regards,
          Chris
          • 2. Re: Using a StoredProcedureCall - session
            JamesSutherland
            The example looks correct, are you using JPA or the native API? The TopLink Session is the main object in TopLink, you can create one through code, or through the SessionManager and a sessions.xml, or if your using JPA, you can access it from the JPA EntityManager. The documentation includes a section of the Using Sessions, perhaps start by reviewing this.

            If you are using JPA and EclipseLink, there are now annotations for NamedStoredProcedureQuery's, and you could use the EclipseLink JpaQuery API to set a DataModifyQuery into a JPA Query.

            ----
            James : http://www.eclipselink.org
            • 3. Re: Using a StoredProcedureCall - session
              656067
              Thx for your help..
                   
              I forgot to mention that I creating a web application using framework JSF in Eclipse. I found this thread and it works Using Stored Procedures with TopLink / JPA : Success explanation
              • 4. Re: Using a StoredProcedureCall - session
                656067
                Hi,
                my problemy still not solved :( If I using CallableStatement from this example - Using Stored Procedures with TopLink / JPA : Success explanation , I can not return record type :( And I need to return the type of record.. I don't now, if StoredProcedureCall can return this types, but I think that is possiblem, isn't it?
                2 jsutherl :
                How did you mean using JPA EntityManager to acces from calling stored procedures? (Do you have some example pls? :) ) Or I can use EntityManager to create session? In this example Using Stored Procedures with TopLink / JPA : Success explanation I can create Unit Of Work, but if I want create session from EntityManager, then still returns NullPointer Exceptions! There is another way to call stored procedures of the Oracle with using the JPA?
                And how work NamedStoredProcedureQuery's in EclipseLink? :) They can return record type?
                Thx;)

                P.S. Sry for my English ;)

                P.P.S. And how can I create session through the code?

                Edited by: KLD on Nov 3, 2008 4:21 AM