Stored procedure serves up its own code

I have a stored procedure in Oracle with no in, out or inout
parameters and it works but . . ..
it also serves up its own sql code as content!?!
How can I prevent this?
Thanks

quote:
it also serves up its own sql code as content
What do you mean by that, exactly? Do you have
an example of what it is doing or some code from the SP?
Phil

Similar Messages

  • Java Stored Procedure / Server Side / Client Side / connection

    Hi,
    I would like to know if we can know at the runtime with a JDBC api if the stored procedure is running in client side or in server side ?
    THANKS

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

  • Calling a stored procedures and using its output parameters in a report

    Hi,,
    I have a procedure defined in a package on the database. This procedure returns a number of output parameters. How do I call this procedure and use the output parameters in my report ?
    Thanks, Mark

    Depends on the level at which the procedure has to be called. If its at report-level, call the Form in the BEFORE-REPORT-trigger (or AFTER-PARAMFORM) and store the out-values in Placeholder-columns. These you can use anywhere in your report.

  • SQL Server 2008 R2 - Report Builder 3.0 - timeout using shared data source and stored procedure

    I select the shared datasource from the data source propeties dialog, test the connection and everything is good.
    I add a dataset by selecting "use a dataset embedded in my report" option within the Dataset properties dialog.
    I select the newly added data source, click the "Stored procedure" query type and drop down the list box and select my intended stored procedure.
    the timeout for the dataset is "0" seconds.
    I click the "OK" button and I'm presented with the parameters to the stored procedure.
    I enter valid data for the parameters and click the "OK" button.
    I then get the following error message after 30 seconds:
    The problem is, all of the timeouts, that I'm aware of, have values of zero (no timeout) or high enough values that 30 seconds isn't even close to the timeout.
    I think the smallest timeout we have is 120 seconds.
    I have searched this site and many others and the solutions all involve altering the stored procedure to get the fields into report builder and then revert the stored procedure back to its original form.
    To me, this is NOT a solution.  
    I have too many stored procedures that need to be brought into Report Builder.
    I need a real solution.
    Thank you for you time, Tim Caldwell.
    Timothy E Caldwell

    I don't mean to be rude, but really, check to see if the stored procedure can return data rows???
    Maybe I'm not being clear enough.
    The stored procedure runs perfectly fine.
    it runs perfectly fine in the production environment and the test environment.
    I can access the stored procedure in several ways and have it return correct data.
    I can even trick report builder into creating a dataset with parameters and run the stored procedure that way.
    What I cannot do, is to get report builder to not timeout after 30 seconds on the initial creation of a dataset with a Query type of stored procedure.
    I have seen this issues posted again and again and again on may different sites and the "solution" is to simplifiy the stored procedure by creating a stored procedure that has a create table and a select in the stored procedure and that's it.  After
    report builder creates the dataset the developer then has to replace the simplified stored procedure with the actual stored procedure and everything works fine after that.
    HOWEVER, having to go through this process for 70 or more stored procedures is ridiculous.
    It would appear that there is something within report builder itself that is causing this issue.
    The SQL Script included is an example of a stored procedure that will not create fields create a dataset with fields and parameters in Report Builder 3.0:
    USE [CRUM_IT]
    GO
    /****** Object: StoredProcedure [dbo].[COGNOS_Level5ScriptSP] Script Date: 11/17/2014 08:02:26 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[COGNOS_Level5ScriptSP]
    @CompanyCode varchar(8) = null,
    @GetSiblings varchar(1) = 'N'
    as
    Begin
    -- get emergency contact info
    select *
    into #tmp_Contacts
    from
    (select
    ConEEID,
    con.connamelast as [Emer Contact Last Name],
    con.connamefirst as [Emer Contact First Name],
    con.connamemiddle as [Emer Contact Middle Initial/Name]--,
    ,ROW_NUMBER() over (Partition by ConEEID order by ConNameLast)as rn
    ,ISNULL(
    case when con.conphonepreferred = 'H'
    then '(' + substring(con.conphonehomenumber, 1, 3) + ')' + substring(con.conphonehomenumber, 4, 3) + '-' + substring(con.conphonehomenumber, 7, 4)
    else '(' + substring(con.conphoneothernumber , 1, 3) + ')' + substring(con.conphoneothernumber , 4, 3) + '-' + substring(con.conphoneothernumber , 7, 4)
    end,
    ) as [Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.Contacts con
    where con.ConIsEmergencyContact='y'
    and con.ConIsActive='y'
    ) A
    where A.rn = 1
    CREATE TABLE #tmp_CompanyCodes (CompanyCode varchar(8))
    If @GetSiblings = 'Y'
    Begin
    INSERT INTO #tmp_CompanyCodes (CompanyCode)
    EXEC [z_GetClientNumbers_For_ParentOrg_By_ClientNumber] @CompanyCode
    End
    INSERT INTO #tmp_CompanyCodes
    values (@CompanyCode)
    select *
    into #tmp_Company
    from [ultiprosqlprod1].[ultipro_crum].dbo.Company
    where cmpcompanycode in (select CompanyCode from #tmp_CompanyCodes)
    select distinct
    cmpcompanycode as [Client ID],
    CmpCompanyDBAName as [Client Name],
    eec.eecEmplStatus AS [Employment Status],
    eec.eecEmpNo AS [Employee Num],
    rtrim(eep.eepNameLast) AS [Last Name],
    rtrim(eep.eepNameFirst) AS [First Name],
    isnull(rtrim(ltrim(eep.eepNameMiddle)), '') AS [Middle Initial/Name],
    rtrim(eep.eepAddressLine1) AS [Address Line 1],
    isnull(rtrim(eep.eepAddressLine2), '') AS [Address Line 2],
    eep.eepAddressCity AS [City],
    eep.eepAddressState AS [State],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 1, 5)
    ELSE rtrim(eep.eepAddressZipCode)
    END AS [Zip code],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 6, 4)
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) > 0
    THEN substring(eep.eepAddressZipCode, charindex(eep.eepAddressZipCode, '-', 1) + 1, 4)
    WHEN len(eep.eepAddressZipCode) <= 5
    THEN ''
    END AS [ZIP + 4],
    substring(eep.eepSSN, 1, 3) + '-' + substring(eep.eepSSN, 4, 2) + '-' + substring(eep.eepSSN, 6, 4) AS [SSN],
    isnull(convert(VARCHAR(10), eep.eepDateOfBirth, 101), '') AS [Date Of Birth],
    eetFED.TAXCODE AS [FED Tax Code],
    eetFED.FILINGSTATUS AS [Fed Filing Status],
    eetFED.EXEMPTIONS AS [Fed Exemption Allowance],
    eetFED.ADDITIONAL AS [Additional Fed Withholding],
    eetSIT.TAXCODE AS [SIT Tax Code],
    eetSIT.FILINGSTATUS AS [State Filing Status],
    eetSIT.EXEMPTIONS AS [State Exemption Allowance],
    eetSIT.ADDITIONAL AS [Additional State Withholding],
    isnull('(' + substring(eep.eepPhoneHomeNumber, 1, 3) + ')' + substring(eep.eepPhoneHomeNumber, 4, 3) + '-' + substring(eep.eepPhoneHomeNumber, 7, 4), '') AS [Home Phone],
    isnull((SELECT cod.codDesc
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.Codes cod WITH (NOLOCK)
    WHERE cod.codCode = eep.eepEthnicID
    AND cod.codDosTable = 'ETHNICCODE'), '') AS [Race-Origin], --eep.eepEthnicID AS [Race-Origin],
    eep.eepGender AS [Gender],
    isnull(convert(VARCHAR(10), eec.eecDateOfOriginalHire, 101), '') AS [Original Hire Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfSeniority, 101), '') AS [Seniority Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfTermination, 101), '') AS [Termination Date],
    isnull(eecTermType,'') as [Termination Type],
    isnull(TchDesc, '') as [Termination Reason],
    rtrim(eec.eecJobCode) AS [WC Code],
    isnull(eec.eecJobTitle, '') AS [Job Title],
    pgr.pgrPayFrequency AS [Pay Frequency],
    eec.eecFullTimeOrPartTime AS [Full/Part Time],
    eec.eecSalaryOrHourly AS [Pay Type],
    isnull(convert(MONEY, eec.eecHourlyPayRate), 0.00) AS [Hourly Rate],
    isnull(eec.eecAnnSalary, 0.00) AS [Annual Salary],
    [YTD Hours],
    isnull(eep.eepNameFormer, '') AS [Maiden Name],
    eec.eecLocation AS [Location ID],
    rtrim(eec.eecOrgLvl1) AS [Department ID],
    eec.eecorglvl2 AS [Cost Item],
    eec.eecorglvl3 as [Client Project],
    eec.eecPayGroup as [Pay Group],
    isnull(eepAddressEMail,' ') as [Email Address],
    isNull(BankName1,' ') as PrimaryBank,
    isNull(BankRoute1,' ') as PrimaryRouteNum,
    isNull(Account1,' ') as PrimaryAccount,
    isNull(AcctType1,' ') as PrimaryAcctType,
    isNull(DepositRule1,' ') as PrimaryDepositRule,
    isNull(BankName2,' ') as SecondaryBank,
    isNull(BankRoute2,' ') as SecondaryRouteNum,
    isNull(Account2,' ') as SecondaryAccount,
    isNull(AcctType2,' ') as SecondaryAcctType,
    isNull(DepositRule2,' ') as SecondaryDepositRule,
    isNull(
    CASE
    WHEN DepositRule2 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct2 AS decimal(10,2)))
    WHEN DepositRule2 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct2*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as SecondaryDepositAmount,
    isNull(BankName3,' ') as ThirdBank,
    isNull(BankRoute3,' ') as ThirdRouteNum,
    isNull(Account3,' ') as ThirdAccount,
    isNull(AcctType3,' ') as ThirdAcctType,
    isNull(DepositRule3,' ') as ThirdDepositRule,
    isNull(
    CASE
    WHEN DepositRule3 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct3 AS decimal(10,2)))
    WHEN DepositRule3 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct3*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as ThirdDepositAmount,
    Supervisor,
    eec.eecEEID AS [Employee EEID],
    eec.EecJobCode As [Job Code],
    isnull(eec.EecTimeclockID,' ') As [Time Clock ID],
    con.[Emer Contact Last Name],
    con.[Emer Contact First Name],
    con.[Emer Contact Middle Initial/Name],
    con.[Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.empPers eep WITH (NOLOCK)
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.empComp eec WITH (NOLOCK)
    ON eep.eepEEID = eec.eecEEID
    inner join #tmp_Company cmp WITH (NOLOCK)
    ON eec.eecCOID = cmp.cmpCOID
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.PayGroup pgr WITH (NOLOCK)
    ON eec.eecPayGroup = pgr.pgrPayGroup
    left outer join [ultiprosqlprod1].[ultipro_crum].dbo.TrmReasn
    on tchCode = eecTermReason
    left join (select CAST(sum(isnull(eee.eeeYTDHrs,0.00))AS DECIMAL(18,2)) as [YTD Hours],
    eeeEEID,
    eeeCOID
    from [ultiprosqlprod1].[ultipro_crum].dbo.EmpEarn eee with (NOLOCK)
    group by eeeCOID,eeeEEID)eee
    on eec.eecEEID = eee.eeeEEID
    and eec.eecCOID = eee.eeeCOID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode = 'USFIT'
    )eetFED
    ON eec.eecCOID = eetFED.COID
    and eec.eecEEID = eetFED.EEID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode like '%SIT'
    AND eetIsWorkInTaxCode = 'Y'
    )eetSIT
    ON eec.eecCOID = eetSIT.COID
    and eec.eecEEID = eetSIT.EEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName1,
    eddEEBankRoute BankRoute1,
    eddAcct Account1,
    EddAcctType AcctType1,
    EddDepositRule DepositRule1,
    EddAmtOrPct EddAmtOrPct1
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '99')edd
    ON eec.eecCOID = edd.eddCOID
    and eec.eecEEID = edd.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName2,
    eddEEBankRoute BankRoute2,
    eddAcct Account2,
    EddAcctType AcctType2,
    EddDepositRule DepositRule2,
    EddAmtOrPct EddAmtOrPct2
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '01')edd2
    ON eec.eecCOID = edd2.eddCOID
    and eec.eecEEID = edd2.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName3,
    eddEEBankRoute BankRoute3,
    eddAcct Account3,
    EddAcctType AcctType3,
    EddDepositRule DepositRule3,
    EddAmtOrPct EddAmtOrPct3
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '02')edd3
    ON eec.eecCOID = edd3.eddCOID
    and eec.eecEEID = edd3.eddEEID
    left outer join (SELECT eecCOID,
    eecEEID,
    rtrim(eepNameLast) + ', ' +
    rtrim(eepNameFirst) + ' ' +
    isnull(rtrim(ltrim(eepNameMiddle)), '') AS [Supervisor]
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpComp WITH (NOLOCK)
    join [ultiprosqlprod1].[ultipro_crum].dbo.EmpPers with (NoLock)
    on eeceeid = eepeeid)eec2
    ON eec.eecSupervisorID = eec2.eecEEID
    left outer join #tmp_Contacts con
    on eep.eepEEID = con.ConEEID
    order by [Client ID],
    [Last Name],
    [First Name]
    drop table #tmp_Contacts
    END
    Timothy E Caldwell

  • SQL Queries in Code V/s Stored Procedures

    Hi Friend,
    Can any one of you guide me with following..
    What is faster ? using SQL Queries in Java code or using Stored Procedures which are called from code?
    I understnd Stroed Procedures are faster and definitely it provides more maintainability.
    If any one can give me any links or resources which outlines pros and cons of using Stored Proc and SQL Queries embedded in Java than it would be a great help..
    If there are any articles which proves either of the above is a preferred way, that would also help..
    Appreciate the effort in advance !!
    Thanks
    Gurudatt

    Well one benefit of Stored Procs is that you "compile" it on the database whereas you might build your query on the fly in java... test coverage is important in order not to have such things as a typo in a column name....
    Still, if you change a table, you have to go through all the procedures in SQL and likely to do so in some of your business object... and trust me, that can be hell!
    It all depends on the use of the app...
    From my experience, Stored procedure are much faster than built-on-the-fly SQL (and quite faster than prepared statements depending on the JDBC driver, the re-use of connections etc...)....
    IMHO, you'd probably be wise to start of with prepared statements, and when the schema seems stable enough (ie unlikely to change), look for the slower queries and convert them to stroed procedures.
    If you don't have to support several databases and are tight on performance, you can even include some logic in your stored procedure (e.g. update several tables, based on various selects...etc...). The language is usually quite powerful, and that can save you the run-time of selecting, converting to object , process and update (i.e. several roud-trip between DB and app)...
    Tshcuss!
    Chris

  • Report with Stored Procedure does not return until refresh

    I'm using RAS server 2008 to run many Crystal reports from a web application (TrackWise) over Oracle 10g DB.
    A new report is using a stored procedure that takes several minutes (5-10) to return before the rest of the report's SQL can execute.
    When running the report from Crystal Developer there is no problem,
    but when running from the application (using the RAS), the report seems to be running forever,
    However, if you wait a few minutes for the DB utilization to drop (i.e. for the stored procedure to finish) and refresh - the full report appears on the screen in a second.
    Since I have many other reports that run for much longer time with no issue, I assume that this has nothing to do with the web application, but rather related to the connection between the RAS and the DB (i.e. the idle time between the beginning of the stored procedure execution to its return and the continuation of the report creation).
    I assume that I need to change one of the RAS settings/ parameters (in the properties or in the registry), but which?
    Please assist.

    Since this app is from TrackWise, I'd recommend contacting TrackWise and see if they have an answer for you. As it is, we have no idea how they implemented the CR components in their app. If they cannot help you, it should be them coming here and asking us - or better yet they should be creating a phone incident.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Problem with stored procedure usage when Toplink api is used

    In one of our applications we used the combination of JBoss4.0.2 application server, Oracle Toplink 10g (9.0.4.5), JDBC Driver Version is ..... 10.1.0.2.0, Database Product Version is Oracle9i Enterprise Edition Release 9.2.0.6.0, j2sdk1.4.2_08
    We faced problem in the application when it is trying to call stored procedure using Oracle Toplink api
    code snippet:
    public ByteArrayOutputStream baos = new ByteArrayOutputStream();
    public PrintStream pos = new PrintStream(baos);
    public String delete(String Id)
    String procedureName = "abc";
    try
    UnitOfWork uow = PersistenceManager.getCurrent().getUnitOfWork();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName(procedureName);
    call.addUnamedArgumentValue(Id);
    uow.executeNonSelectingCall(call);
    uow.commit();
    catch (Exception e)
    message = e;
    e.printStackTrace(pos);
    message = message+ baos.toString();
    return message;
    Stack Trace:
    Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseException Exception Description: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Error Code: 6550Local Exception Stack: Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseException Exception Description: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'DELETE_LOADED_RESULT_SET' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Error Code: 6550 at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:227) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:733) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:781) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:642) at oracle.toplink.publicinterface.UnitOfWork.executeCall(UnitOfWork.java:1400) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:131) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:115) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeNoSelectCall(CallQueryMechanism.java:164) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeNoSelect(CallQueryMechanism.java:143) at oracle.toplink.queryframework.DataModifyQuery.execute(DataModifyQuery.java:41) at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:493) at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1958) at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2236) at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086) at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1038) at oracle.toplink.publicinterface.Session.executeNonSelectingCall(Session.java:816) at com.abc.de.fg.model.resultSet.ResultSetProvider.delete(ResultSetProvider.java:150) at
    Could anyone please let me know what might be the problem in this case.

    Tried and couldn't reproduce the problem using 9.0.4.7.
    Here's the code:
        System.out.println("storedProcedureUnamedValueTest");
        StoredProcedureCall call = new StoredProcedureCall();
        String lastName = "Jones";
        call.setProcedureName("STOREDPROCEDURE_IN");
        call.addUnamedArgumentValue(lastName);
        session.executeNonSelectingCall(call);stored procedure definition in data base:
    CREATE OR REPLACE  PROCEDURE "TEST_904"."STOREDPROCEDURE_IN"  (
         IN_PARAM VARCHAR2) AS
    BEGIN
      UPDATE EMPLOYEE SET F_NAME = 'Indiana' WHERE (L_NAME = IN_PARAM);
    END;log:
    storedProcedureUnamedValueTest
    DatabaseSession(15)--Execute query DataModifyQuery()
    DatabaseSession(15)--Connection(16)--BEGIN STOREDPROCEDURE_IN('Jones'); END;
    DatabaseSession(15)--Connection(16)--reconnecting to external connection poolAndrei

  • Stored Procedure: Extract data into second cursor

    This is ready-to-run script with a commented out INCOMPLETE section of code where i need to select from a cursor.
    --==  PDF Dcument Table of contents ==---
    --==  PDF Report contains Period to date on condiments and bun sales for a region
    --==  For each week for a 4-week period with week 6 representing PTD and week 7 representing
    --==  YTD. Data should be gathered in rowsets and pivoted on client
    --== 
    --== Basic Functionallity:
    --=== Write a stored procedure that performs the following:
    --==  1) Select the report data into cursor 1  in the order with a resultset order
    --==     in the way it will be printed to report.
    --==  2) Create list of inique stores in separate cursor
    --==  Approach: 
    --== Create the Type object of fields needed to build table of contents for each row of the table. Add a sort field
    --== to enable restore the original order of data after any sorting done on client 
    --== Create table table of the row objects
    --== Declare 2 cursors:
    --   a) ) First cursor holds the data for the PDF Report  to be pivoted by the client
    --   b) ) Second should contain a table of contents (unique storenbr) in the 
    --== same order as the stores in the first cursor.
    --== Oracle version 10g v2 on  W2K3
    begin  execute immediate 'drop type TYP_TBL_CWSR_TOC'; exception when others then null; end;
    begin  execute immediate 'drop type TYP_CWSR_TOC';  exception when others then null;  end;
    begin execute immediate 'drop procedure Create_Rpt_and_TOC'; exception when others then null; end;
    create or replace TYPE TYP_CWSR_TOC AS OBJECT
           (   sortcol         number             --== probably not needed, just in case
            ,  storenbr        varchar2(100)
            ,  storename       varchar2(200) 
    create or replace TYPE TYP_TBL_CWSR_TOC AS TABLE OF TYP_CWSR_TOC;
    create or replace procedure create_rpt_and_toc
         pc_report_data               OUT sys_refcursor
    ,    pc_TOC   OUT sys_refcursor     
    AS
    v_tblTOC        TYP_TBL_CWSR_TOC;
    v_rec           TYP_CWSR_TOC := TYP_CWSR_TOC(NULL,NULL, NULL);
    BEGIN
    OPEN pc_report_data FOR
    with  sample_data as
    (    select 22 storeid , 1 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
          select 22 storeid , 6 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
          select 22 storeid , 7 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
          select 23 storeid , 1 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
          select 23 storeid , 6 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
          select 23 storeid , 7 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
          select 24 storeid , 1 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
          select 24 storeid , 6 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
          select 24 storeid , 7 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
          select 25 storeid , 1 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
          select 25 storeid , 6 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
          select 25 storeid , 7 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
          select 27 storeid , 1 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
          select 27 storeid , 6 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
          select 27 storeid , 7 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
          select 31 storeid , 1 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
          select 31 storeid , 6 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
          select 31 storeid , 7 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
          select 38 storeid , 1 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
          select 38 storeid , 6 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
          select 38 storeid , 7 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
          select 39 storeid , 1 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
          select 39 storeid , 6 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
          select 39 storeid , 7 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
          select 41 storeid , 1 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
          select 41 storeid , 6 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
          select 41 storeid , 7 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
          select 42 storeid , 1 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
          select 42 storeid , 6 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
          select 42 storeid , 7 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
          select 65 storeid , 1 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
          select 65 storeid , 6 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
          select 65 storeid , 7 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
          select 66 storeid , 1 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
          select 66 storeid , 6 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
          select 66 storeid , 7 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
          select 67 storeid , 1 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
          select 67 storeid , 6 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
          select 67 storeid , 7 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
          select 68 storeid , 1 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
          select 68 storeid , 6 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
          select 68 storeid , 7 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
          select 70 storeid , 1 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
          select 70 storeid , 6 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
          select 70 storeid , 7 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
          select 71 storeid , 1 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
          select 71 storeid , 6 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
          select 71 storeid , 7 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
          select 82 storeid , 1 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
          select 82 storeid , 6 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
          select 82 storeid , 7 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
          select 83 storeid , 1 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
          select 83 storeid , 6 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
          select 83 storeid , 7 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
          select 181 storeid , 1 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
          select 181 storeid , 6 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
          select 181 storeid , 7 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
          select 221 storeid , 1 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
          select 221 storeid , 6 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
          select 221 storeid , 7 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
          select 222 storeid , 1 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
          select 222 storeid , 6 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
          select 222 storeid , 7 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
          select 223 storeid , 1 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
          select 223 storeid , 6 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
          select 223 storeid , 7 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
          select 224 storeid , 1 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
          select 224 storeid , 6 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
          select 224 storeid , 7 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
          select 260 storeid , 1 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
          select 260 storeid , 6 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
          select 260 storeid , 7 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
          select 280 storeid , 1 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
          select 280 storeid , 6 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
          select 280 storeid , 7 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
          select 294 storeid , 1 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
          select 294 storeid , 6 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
          select 294 storeid , 7 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
          select 362 storeid , 1 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
          select 362 storeid , 6 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
          select 362 storeid , 7 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
          select 501 storeid , 1 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
          select 501 storeid , 6 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
          select 501 storeid , 7 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
          select 521 storeid , 1 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
          select 521 storeid , 6 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
          select 521 storeid , 7 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
          select 524 storeid , 1 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual union all
          select 524 storeid , 6 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual union all
          select 524 storeid , 7 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual
    , store_data as
          select 27   storeid,  'County Gate' storename ,    '5601' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                
          select 67   storeid,  'N. Jackson' storename ,    '0177' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                  
          select 68   storeid,  'Dyersburg' storename ,    '0277' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                  
          select 280   storeid,  'Poplar Ave.' storename ,    '3080' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                   
          select 294   storeid,  'Goodman Rd' storename ,    '5702' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                     
          select 25   storeid,  'Germantown' storename ,    '5094' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                              
          select 181   storeid,  'Mendehall' storename ,    '4090' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                    
          select 31   storeid,  'Winchester' storename ,    '2684' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                    
          select 41   storeid,  'Washington' storename ,    '4190' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                   
          select 42   storeid,  'Cordova' storename ,    '4393' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                       
          select 70   storeid,  'S. Jackson' storename ,    '0679' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                                                                                                                      
          select 221   storeid,  'Jackson' storename ,    '5500' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                      
          select 223   storeid,  'Highway 51' storename ,    '3485' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                        
          select 66   storeid,  'New Summer' storename ,    '2980' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                    
          select 82   storeid,  'Navy Road' storename ,    '1476' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                   
          select 224   storeid,  'New Covington' storename ,    '5397' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                              
          select 501   storeid,  'Kirby Quince' storename ,    '6504' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                               
          select 22   storeid,  'Wchstr/Good' storename ,    '2385' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                  
          select 23   storeid,  'Union Ave' storename ,    '1275' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                 
          select 24   storeid,  'West Poplar' storename ,    '4290' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                   
          select 222   storeid,  'Thomas St.' storename ,    '1977' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                
          select 362   storeid,  'Wolfchase' storename ,    '5802' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                 
          select 524   storeid,  'Houston Levee' storename ,    '6705' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                             
          select 521   storeid,  'G-Town/I-40' storename ,    '6604' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                               
          select 38   storeid,  'Horn Lake' storename ,    '4994' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                    
          select 39   storeid,  'Macon/Syc' storename ,    '2885' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                    
          select 65   storeid,  'Poplar/Fenwick' storename ,    '2581' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                
          select 71   storeid,  'Humboldt' storename ,    '0785' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                      
          select 83   storeid,  'Mt. Moriah' storename ,    '1174' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                
          select 260   storeid,  'Getwell' storename ,    '1576' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual
    select decode(gc,0,companyname, 'VanderbiltFoods') as companyname
    ,       decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')) as regionname
    ,       decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods'))) as districtname
    ,       decode(gs,0,storenbr,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storenbr
    ,       decode(gs,0,storename,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storename
    ,       net_sales
    ,       buns
    ,       condiments
    from    (   select    companyname
                ,         grouping(companyname)     gc
                ,         regionname
                ,         grouping(regionname)      gr
                ,         districtname
                ,         grouping(districtname)    gd
                ,         storenbr
                ,         grouping(storenbr)        gs
                ,         max(storename) storename
                ,         sum(net_sales)            net_sales
                ,         sum(buns)                 buns
                ,         sum(condiments)           condiments
                from store_data  stdata
                inner join sample_data   sampdata on sampdata.storeid  = stdata.storeid
                group by   rollup(companyname, regionname, districtname, storenbr), week_nbr
                order by   companyname nulls first,gc desc, regionname nulls first, gr desc, districtname nulls first, gd desc,storenbr nulls first, gs desc
    /*  --==  INCOMPLETE CODE --
        --== GET TABLE OF CONTENTS In same order as first cursor
        open pc_report_data for
        select   rownum as sortcol
        ,        storenbr
        ,        storename)
        BULK COLLECT INTO pc_TOC
    END create_rpt_and_toc;I don't know sQL developer well enough to view cursor results from stored procedure
    but here is test code from debugger window
    DECLARE
      PC_REPORT_DATA sys_refcursor;
      PC_TOC sys_refcursor;
    BEGIN
      CREATE_RPT_AND_TOC(
        PC_REPORT_DATA => PC_REPORT_DATA,
        PC_TOC => PC_TOC
      -- Modify the code to output the variable
      -- DBMS_OUTPUT.PUT_LINE('PC_REPORT_DATA = ' || PC_REPORT_DATA);
      -- Modify the code to output the variable
      -- DBMS_OUTPUT.PUT_LINE('PC_TOC = ' || PC_TOC);
    END;

    I am currently doing this in the presentation layer but is a lot cleaner and easier to maintain if handled in DB
    I'd googled that suggested this was possible. I had decided on the FETCH. But I've been to avoid FETCH and LOOP
    wherever possible.
    One eample I found: I always try so much stuff, I forget where i got the idea) was:
    -- pseudoscript
    FETCH outer cursor.
        Select outer cursor
        open second cursor for select into and CLOSE Cursor. 
    LOOPI also found this.
    create or replace procedure testproc(c_test out sys_refcursor) is
        begin
          open c_test for select first_name, last_name, email from employees where rownum < 10;
       end;Here though, its a simple select from a table vs. a cursor.
    I thouht it was woth asking the question.

  • Java Stored Procedure in EXECUTE IMMEDIATE

    Hi,
    I need advice for the following.
    I'm on Oracle 11g R2. I'm testing application in Oracle 11gR1 and R2 and Oracle Express.
    Purpose is to generate XML reports.
    I have PLSQL Stored Procedure which does that, but since there is bug in Oracle11gR2 related to XMLTRANSFORM I have and Java Stored Procedure which is workaround. They are both compiled, valid etc.
    Java class is :
    import java.io.PrintWriter;
    import java.io.Writer;
    import oracle.xml.parser.v2.DOMParser;
    import oracle.xml.parser.v2.XMLDocument;
    import oracle.xml.parser.v2.XSLProcessor;
    import oracle.xml.parser.v2.XSLStylesheet;
    * This class is used as Java stored procedure
    * There is a bug on Oracle11gR2, related to the limitation on the number of style sheet instructions
    * This stored procedure is workaround when PLSQL code can not be used.
    * File must not have package, otherwise is wrongly compiled in DB
    public class JavaXslt {
         public static void XMLTtransform(oracle.sql.CLOB xmlInput,oracle.sql.CLOB xslInput,oracle.sql.CLOB output) throws Exception{
              DOMParser parser;
              XMLDocument xml;
              XMLDocument xsldoc;
              try{
                   parser = new DOMParser();
                   parser.parse(xmlInput.getCharacterStream());
                   xml = parser.getDocument();
                   parser.parse(xslInput.getCharacterStream());
                   xsldoc = parser.getDocument();
                   XSLProcessor processor = new XSLProcessor();
                   XSLStylesheet xsl = processor.newXSLStylesheet(xsldoc);
                   Writer w = output.setCharacterStream(1L);
                   PrintWriter pw = new PrintWriter(w);
                   processor.processXSL(xsl, xml, pw);
              }catch (Exception ex){
                   throw ex;
    PROCEDURE Java_XmlTransform (xml CLOB, xslt CLOB, output CLOB) AS LANGUAGE JAVA
    NAME 'JavaXslt.XMLTtransform(oracle.sql.CLOB, oracle.sql.CLOB, oracle.sql.CLOB)';
    I'm calling Java stored procedure from PLSQL Stored procedure (if it is Oracle11gR2) like that :
    Java_Proc.Java_XmlTransform(inputXML, xslt, res);
    So till here everything works ok. XSLT as applied and output XML (res) is OK.
    But when Oracle Express is used Java is out of the question, so there is no Java stored procedure. Howewer PLSQL Stored procedure is still needed.
    So I had to put call to Java Stored procedure in EXECUTE IMMEDIATE statement in order to compile to PLSQL package.
    But when I do that :
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING inputXML, xslt, res;
    result value CLOB (res) has zero length...
    What am I missing? Should i set return value to Java class?
    Hope my explanations are clear though.
    Thanks

    Hi odie_63,
    Thanks for quick response.
    I didn't clearly explained.
    When using Oracle 11gR1 and Oracle Express I'm using only PLSQL Procedure.
    When using Oracle 11gR2 i have to use Java Stored procedure because there is documented bug in R2.
    That's why i have to use EXECUTE IMMEDIATE. I don't know which version is the client DB and whether there is or no Java procedures.
    I did tried
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING IN inputXML, IN xslt, OUT res; and the result was ORA-06537: OUT bind variable bound to an IN position
    When using IN OUT for last parameter i.e.
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING IN inputXML, IN xslt, IN OUT res;
    there is no exception, but still DBMS_LOB.getlength(res) = 0
    Thanks

  • How to use OUT variables in my stored procedure

    I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code...
    CREATE OR REPLACE PROCEDURE testProj.testProcedure (
         v_segment_id IN VARCHAR2,
         v_student_id OUT VARCHAR2,
         v_current_code OUT NUMBER,
         v_new_code OUT NUMBER
    ) AS
    BEGIN
         SELECT
              s.student_id,
              s.quad_code_id,
              nc.quad_code_id
         INTO
              v_student_id,
              v_current_quad_code,
              v_new_quad_code
         FROM testProj.students s
         INNER JOIN testProj.new_codes nc ON s.student_id = nc.student_id
         WHERE s.segment_id = v_segment_id ;
    END testProcedure ;
    EXECUTE testProj.testProcedure ('44') ;
    When I execute that stored procedure with the above execute statement, I get this error:
    Error report:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'testProcedure'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    +06550. 00000 - "line %s, column %s:\n%s"+
    *Cause:    Usually a PL/SQL compilation error.+
    *Action:+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Using Refcursor is one way you can do that ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.21
    satyaki>
    satyaki>
    satyaki>create or replace procedure r_arg(
      2                                      choice in number,
      3                                      b in out sys_refcursor
      4                                   )
      5  is  
      6    str   varchar2(500);
      7  begin   
      8     str := 'select * from emp';   
      9     open b for str;
    10  exception  
    11    when others then     
    12      dbms_output.put_line(sqlerrm);
    13  end;
    14  /
    Procedure created.
    Elapsed: 00:00:01.84
    satyaki>
    satyaki>
    satyaki>declare   
      2    rec_x emp%rowtype;   
      3    w sys_refcursor;
      4  begin  
      5    dbms_output.enable(1000000);  
      6    r_arg(1,w);  
      7    loop    
      8      fetch w into rec_x;     
      9        exit when w%notfound;             
    10        dbms_output.put_line('Employee No: '||rec_x.empno||' - '||                          
    11                             'Name: '||rec_x.ename||' - '||                          
    12                             'Job: '||rec_x.job||' - '||                          
    13                             'Manager: '||rec_x.mgr||' - '||                          
    14                             'Joining Date: '||rec_x.hiredate||' - '||                          
    15                             'Salary: '||rec_x.sal||' - '||                          
    16                             'Commission: '||rec_x.comm||' - '||                          
    17                             'Department No: '||rec_x.deptno);  
    18     end loop;  
    19     close w;    
    20  exception  
    21    when others then    
    22       dbms_output.put_line(sqlerrm);
    23  end;
    24  /
    Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
    Employee No: 7777 - Name: SOURAV - Job: SLS - Manager:  - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
    Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
    Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission:  - Department No: 20
    Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
    Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission:  - Department No: 30
    Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission:  - Department No: 10
    Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission:  - Department No: 20
    Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager:  - Joining Date: 17-NOV-81 - Salary: 7000 - Commission:  - Department No: 10
    Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
    Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission:  - Department No: 20
    Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission:  - Department No: 30
    Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission:  - Department No: 20
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.48
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Calling a Stored Procedure with a IN OUT VAR

    Hi
    I'm trying to call an oracle stored procedure and get a return code if it completely ran successfully. This is my first time doing this and would really appreciate some
    PROCEDURE P_NP_OVERDUE_COMPLETED
    (P_YEAR_NO IN NUMBER, P_WEEK_NO IN NUMBER,
    P_RETURN_CODE IN OUT VARCHAR2)
    I get the following error: One or more errors occurred during processing of command.
    Dim OleDBCon As New OleDbConnection
    Dim conStr As String = "Provider=MSDAORA;Data...................."
    OleDBCon.ConnectionString = conStr
    Dim OleDBCMD = New OleDbCommand _
    ("{call p_np_overdue_completed(?,?,{VARCHAR2(255), P_RETURN_CODE})}", OleDBCon)
    OleDBCMD.CommandType = CommandType.Text
    OleDBCMD.Parameters.Add("P_YEAR_NO", OleDbType.Numeric).Value = year
    OleDBCMD.Parameters.Add("P_WEEK_NO", OleDbType.Numeric).Value = i
    Dim myadapter As New OleDbDataAdapter(OleDBCMD)
    OleDBCon.Open()
    myadapter.Fill(ds)

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Size limitation that can be passed to Java stored procedure

    Hello!
    I enjoy using Oracle8i these days. But I have some questions
    about Java stored procedure. I want to pass the XML data to Java
    stored procedure as IN parameter. But I got some errors when the
    data size is long. Is there any limitation in the data size that
    can be passed to Java stored procedure?
    Would you please help me ?
    This message is long, but would you please read my message?
    Contents
    1. Outline : I write what I want to do and the error message I
    got
    2. About the data size boundary: I write about the boundary
    size. I found that it depend on which calling sequence I use.
    3. The source code of the Java stored procedure
    4. The source code of the Java code that call the Java stored
    procedure
    5. The call spec
    6. Environment
    1.Outline
    I want to pass the XML data to Java stored procedure. But I got
    some errors when the data size is long. The error message I got
    is below.
    [ Error messages and stack trace ]
    java.sql.SQLException: ORA-01460: unimplemented or unreasonable
    conversion reque
    sted
    java.sql.SQLException: ORA-01460: unimplemented or unreasonable
    conversion reque
    sted
    at oracle.jdbc.ttc7.TTIoer.processError(Compiled Code)
    at oracle.jdbc.ttc7.Oall7.receive(Compiled Code)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(Compiled Code)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch
    (TTC7Protocol.java:721
    at oracle.jdbc.driver.OracleStatement.doExecuteOther
    (Compiled Code)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch
    (Compiled Code)
    at oracle.jdbc.driver.OracleStatement.doExecute(Compiled
    Code)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Compiled
    Code
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate
    (OraclePrepar
    edStatement.java:256)
    at oracle.jdbc.driver.OraclePreparedStatement.execute
    (OraclePreparedStat
    ement.java:273)
    at javaSp.javaSpTestMain.sample_test
    (javaSpTestMain.java:37)
    at javaSp.javaSpTestMain.main(javaSpTestMain.java:72)
    2. About the data size boundary
    I don|ft know the boundary that I got errors exactly, but I
    found that the boundary will be changed if I use |gprepareCall("
    CALL insertData(?)");|h or |gprepareCall ("begin insertData
    (?); end ;")|h.
    When I use |gprepareCall(" CALL insertData(?)".
    The data size 3931 byte ---&#61664; No Error
    The data size 4045 byte ---&#61664; Error
    Whne I use prepareCall ("begin insertData(?); end ;")
    The data size 32612 byte --&#61664;No Error
    The data size 32692 byte ---&#61664; Error
    3. The source code of the Java stored procedure
    public class javaSpBytesSample {
    public javaSpBytesSample() {
    public static int insertData( byte[] xmlDataBytes ) throws
    SQLException{
    int oraCode =0;
    String xmlData = new String(xmlDataBytes);
    try{
    Connection l_connection; //Database Connection Object
    //parse XML Data
    dits_parser dp = new dits_parser(xmlData);
    //Get data num
    int datanum = dp.getElementNum("name");
    //insesrt the data
    PreparedStatement l_stmt;
    for( int i = 0; i < datanum; i++ ){
    l_stmt = l_connection.prepareStatement("INSERT INTO test
    " +
    "(LPID, NAME, SEX) " +
    "values(?, ?, ?)");
    l_stmt.setString(1,"LIPD_null");
    l_stmt.setString(2,dp.getElemntValueByTagName("name",i));
    l_stmt.setString(3,dp.getElemntValueByTagName("sex",i));
    l_stmt.execute();
    l_stmt.close(); //Close the Statement
    l_stmt = l_connection.prepareStatement("COMMIT"); //
    Commit the changes
    l_stmt.execute();
    l_stmt.close(); //Close the Statement l_stmt.execute
    (); // Execute the Statement
    catch(SQLException e ){
    System.out.println(e.toString());
    return(e.getErrorCode());
    return(oraCode);
    4. The source code of the Java code that call the Java stored
    procedure
    public static void sample_test(int num) {
    //make data
    Patient p = new Patient();
    byte[] xmlData = p.generateXMLData(num);
    try{
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    Connection m_connection = DriverManager.getConnection
    ("jdbc:oracle:thin:@max:1521:test",
    "testuser", "testuser");
    CallableStatement l_stmt =
    // m_connection.prepareCall(" CALL insertData(?)");
    m_connection.prepareCall("begin insertData(?); end
    l_stmt.setBytes(1,xmlData);
    l_stmt.execute();
    l_stmt.close();
    System.out.println("SUCCESS to insert data");
    catch(SQLException e ){
    System.out.println( e.toString());
    e.printStackTrace();
    5. The call spec
    CREATE OR REPLACE PROCEDURE insertData( xmlData IN LONG RAW)
    AS
    LANGUAGE JAVA NAME 'javaSp.javaSpBytesSample.insertData(byte[])';
    6. Environment
    OS: Windows NT 4.0 SP3
    RDBMS: Oracle 8i Enterprise Edition Release 8.1.5.0.0 for
    Windows NT
    JDBC Driver: Oracle JDBC Drivers 8.1.5.0.0.
    JVM: Java1.1.6_Borland ( The test program that call Java stored
    procedure run on this Java VM)
    null

    Iam passing an array of objects from Java to the C
    file. The total size of data that Iam sending is
    around 1GB. I have to load this data into the Shared
    memory after getting it in my C file. Iam working on
    HP-UX (64-bit). Everything works fine for around 400MB
    of data. When I try to send around 500MB of data, the
    disk utilization becomes 100%, so does my memory
    utilization and I get a "Not enough space" when I try
    to access shared memory. I have allocated nearly 2.5GB
    in my SHMMAX variable. Also, I have around 45GB of
    disk free. The JVM heap size is also at 2048MB. Where did you get the 400/500 number from? Is that the size of the file?
    What do you do with the data? Are you doing nothing but copying it byte for byte into shared memory?
    If yes then a simple test is to write a C application that does the same thing. If it has problems then it means you have an environment problem.
    If no then you are probably increasing the size of the data by creating a structure to hold it. How much overhead does that add to the size of the data?

  • Oracle - how to find columns in a table + stored procedures dependent on th

    Scenario:
    I need to list all the columns in a table1 and all stored procedures that depends on those columns of this table1. I need to populate column name and stored procedures to a new table.
    I created new_table(col1, sProc) and tried to populate the column name and respective stored procedure on this new_table. Code I wrote is given below:
    Declare
    Beginfor i in (select column_name from user_tab_columns where lower(table_name) like 'table1') loop
    insert into new_table
    select i.column_name,   name    from user_source   where lower(text) like '%' || i.column_name || '%';
    commit;
    end loop;
    end;
    Result: The scripts run successfully but the no data is populated on this new_table.
    Stress: I tried to solve it for 1 whole day and could not figure it out. Any help on this would be greately appreciated. Thank you once again.

    select i.column_name,   name    from user_source   where lower(text) like '%' || i.column_name || '%';Hi,
    At first check this,
    SQL> desc user_source
    Name                                      Null?    Type
    NAME                                               VARCHAR2(30)
    TYPE                                               VARCHAR2(12)
    LINE                                               NUMBER
    TEXT                                               VARCHAR2(4000)I tried it like this for my testing purpose,
    SQL> create table new_table(cname varchar2(40),pname varchar2(40));
    Table created.
    SQL> Declare
      2  v_pname varchar2(40);
      3  Begin
      4  for i in (select column_name from user_tab_columns where lower(table_name) like 'table1') loop
      5  dbms_output.put_line(i.column_name);
      6   select name into v_pname from user_source where lower(text) like '% '||lower(i.column_name)||' %';
      7  insert into new_table values(i.column_name ,v_pname);
      8  commit;
      9  end loop;
    10  end;
    11  /
    STR
    PL/SQL procedure successfully completed.
    SQL> select * from new_table;
    CNAME   PNAME
    STR       MY_PROCEDURETwinkle

  • Jdbc - stored procedures

    Please, can anyone show me how to retrieve an array from a stored procedure using JDBC?
    The code below are not working (the exception at bottom). The problem seem to be the third parameter to registerOutParameter, this type do however exist in the database.
    This error occurs also when I use OracleCallableStatement.
    Any help and tips is MUCH appreciated.
    Thanks!
    ++++++++++++++++++
    java.sql.Connection con;
    java.sql.CallableStatement cstmt = con.prepareCall("{call pck_test_array.get_company_array(?)}");
    cstmt.registerOutParameter(1,java.sql.Types.ARRAY, "pck_test_array.app_user_name_text_table");
    cstmt.execute();
    ++++++++++++++++++++++
    This generates the following exception:
    java.sql.SQLException: Fail to construct descriptor: Unable to resolve type: "pc
    k_test_array.app_user_name_text_table"
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:775)
    at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:166)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:89)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Oracl
    eCallableStatement.java:162)

    Here is a sample from Metalink on how to
    fetch arrays from pl/sql
    Program Notes
    o This program can be run with any of the three forms of Oracle JDBC driver.
    o Run the script noted in the comments of the program to create the type
    and the procedure that is called.
    o This program uses the most basic method of calling objects,
    via Oracle.sql.STRUCT.
    References
    "Oracle8i JDBC Developers Guide and Reference" (A64685-01)
    Program
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import java.math.BigDecimal;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    public class callInOutStructArray extends Object {
    This program demonstrates how to emulate calling a stored procedure
    with PL/SQL table of record parameters via JDBC. You cannot call a
    PL/SQL table of records parameter directly, however, you can use an
    Object with the same structure as your table of records.
    The Script used to create the procedure in this example is as follows:
    drop type rectab;
    create or replace type rectype as object(col1 varchar2(10),col2 varchar2(10));
    create or replace type rectab as table of rectype;
    create or replace package ioStructArray as
    procedure testproc(iorec in out rectab,orec out rectab);
    end ioStructArray;
    create or replace package body ioStructArray as
    procedure testproc(iorec in out rectab,orec out rectab) is
    begin
    orec := iorec;
    for i in 1..iorec.count loop
    iorec(i).col1 := orec(i).col2;
    iorec(i).col2 := orec(i).col1;
    end loop;
    end testproc;
    end ioStructArray;
    public static void main(String[] args) throws SQLException {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    Connection conn =
    DriverManager.getConnection ("jdbc:oracle:oci8:@S692815.WORLD",
    "scott", "tiger");
    // First, declare the Object arrays that will store the data.
    Object [] p1recobj = {"FIRST","LAST"};
    Object [] p2recobj = {"SECOND","LAST"};
    Object [] p3recobj;
    Object [] p4recobj;
    // Declare the Object Arrays to hold the STRUCTS.
    Object [] p1arrobj;
    Object [] p2arrobj;
    // Declare two descriptors, one for the ARRAY TYPE
    // and one for the OBJECT TYPE.
    StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",conn);
    ArrayDescriptor desc2=ArrayDescriptor.createDescriptor("RECTAB",conn);
    // Create the STRUCT objects to associate the host objects
    // with the database records.
    STRUCT p1struct = new STRUCT(desc1,conn,p1recobj);
    STRUCT p2struct = new STRUCT(desc1,conn,p2recobj);
    // Initialize the Input array object - to an array of STRUCT Objects.
    p1arrobj = new Object []{p1struct,p2struct};
    // Set up the ARRAY object.
    ARRAY p1arr = new ARRAY(desc2,conn,p1arrobj);
    ARRAY p2arr;
    // Declare the callable statement.
    // This must be of type OracleCallableStatement.
    OracleCallableStatement ocs =
    (OracleCallableStatement)conn.prepareCall("{call iostructarray.testproc(?,?)}");
    // The first parameter is in out so we have to use setARRAY to
    // pass it to the statement
    ocs.setARRAY(1,p1arr);
    // The first parameter is in out, so we have to Register the
    // parameter as well.
    // Note the re use of the TYPE.
    ocs.registerOutParameter(1,OracleTypes.ARRAY,"RECTAB");
    // The second paramter is out, so that has to be registered too.
    // Note the re use of the TYPE.
    ocs.registerOutParameter(2,OracleTypes.ARRAY,"RECTAB");
    // Execute the procedure
    ocs.execute();
    // Associate the returned arrays with the ARRAY objects.
    p1arr = ocs.getARRAY(1);
    p2arr = ocs.getARRAY(2);
    // Get the data back into the data arrays.
    p1arrobj = (Object [])p1arr.getArray();
    p2arrobj = (Object [])p2arr.getArray();
    // Get the data records from each array element (which is of type STRUCT).
    p1recobj = ((STRUCT)p1arrobj[0]).getAttributes();
    p2recobj = ((STRUCT)p1arrobj[1]).getAttributes();
    p3recobj = ((STRUCT)p2arrobj[0]).getAttributes();
    p4recobj = ((STRUCT)p2arrobj[1]).getAttributes();
    // Show the results:
    System.out.println("First Object is now "+p1recobj[0]+" and "+p1recobj[1]);
    System.out.println(" "+p2recobj[0]+" and "+p2recobj[1]);
    System.out.println("Second Object is now "+p3recobj[0]+" and "+p3recobj[1]);
    System.out.println(" "+p4recobj[0]+" and "+p4recobj[1]);
    Sample Output
    First Object is now LAST and FIRST
    LAST and SECOND
    Second Object is now FIRST and LAST
    SECOND and LAST
    Copyright (c) 1995,1999 Oracle Corporation. All Rights Reserved. Legal Notices and Terms of Use.
    null

  • Using Stored Procedures with TopLink / JPA : Success explanation

    For those who have to use Stored Procedures in TopLink this is my success history :
    To call an Stored Procedure from the persistence, we have to use the direct JDBC connection because my TopLink version ( Essentials 10g ) ? to date ( 10g ) does not have support for Stored Procedures.
    Here is my code :
    <address>{color:#0000ff} EntityManagerFactory JPAemfactory = null;{color}</address>
    <address>{color:#0000ff} JPAemfactory = Persistence.createEntityManagerFactory ("MyPersistenceUnit"); // this is the name of the persistence unit wrote in the persistence.xml file{color}</address>
    <address>{color:#0000ff} EntityManagerr MyEntityManager = JPAemfactory.createEntityManager ();{color}</address>
    bq. <address>{color:#0000ff}// creation of the stored procedure calling string .... one question mark for every param, output included \\ String sql = "{call SP_GETLISTATARIFAS(?,?,?,?,?)}"; \\ // We get the JDBC connection \\ oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl entityManager = (oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl) MyEntityManager; \\ UnitOfWorkImpl uow = (UnitOfWorkImpl)entityManager.getUnitOfWork(); \\ // we create a request to the unitofwork because if dont the connection will not exist \\ uow.beginEarlyTransaction(); \\ Connection conexion = ((UnitOfWorkImpl)uow).getAccessor().getConnection(); \\ {color}{color:#0000ff} \\ try { \\ // Creation of the call and we will identify the params as they are in the stored procedure definitiondefinidos \\ CallableStatement call = conexion.prepareCall(sql); \\ {color}</address>
    bq. <address>{color:#0000ff} \\ // params INPUT with their values \\ call.setString("pIDMCUPO", "125"); \\ call.setString("pCODIGOHOT", "8023"); \\ call.setString("pCODCANAL", "WEB"); \\ call.setString("pCODSUBCANAL", "HOTEL"); \\ {color}</address><address>{color:#0000ff} \\ // params OUTPUT \\ call.registerOutParameter("rRESULTADO", java.sql.Types.VARCHAR); \\ {color}</address><address>{color:#0000ff} \\ // execution \\ call.execute(); \\ {color}</address><address>{color:#0000ff} \\ // getting the response \\ mcontratos_out = call.getString("rRESULTADO"); \\ {color}</address><address>{color:#0000ff} \\ // closing the proc \\ call.close(); \\ {color}</address><address>{color:#0000ff} \\ } catch (SQLException ex) { {color}</address><address>{color:#0000ff} // something you do if there is an error \\ {color}</address><address>{color:#0000ff} \\ } {color}</address>
    Hope this helps all the people that have searched a lot like me.......

    I have my entity manager setup in a singleton.
    I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
    I'm committing the connection, and uow, and closing the em at the end of each call.
    But until I close the emf, the open cursors aren't released.
    TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
    tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
    tranPkg.closeConnection();
    conn.commit();
    uow.commit();
    uow.getAccessor().decrementCallCount();
    em.close();
    Am I missing something really obvious here??
    btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html

Maybe you are looking for

  • HT4623 Phone does not work after update

    After update 6.1.4 phone cannot find signal to function even though wireless works.  Cannot reload update...says it's up to date.  Reboot nothing,  Reset, nothing.  Really beginning to dislike this piece of junk.  Just need a phone that works.

  • "No Signal" on my Samsung TV when trying to connect my MacBook Pro

    When I try to connect my MacBook Pro to my Samsung HDTV it says no signal. My Pro doesn't flash blue or anything. I'm using a rocketfish adapter with an HDMI cable connected to it. I got my Pro in June 2010. Any idea on how to get this to work?

  • How do you upgrade CC Indesign so home computer and office computer are same version?

    I have CC for my office computer, and also put my home computer on it so I can work from home. I did some work over weekend, and came to office computer and it could not open files. It said my files (made at home) were Indesign 7, so I needed to save

  • No Apple Bumper available under the Case Program in the UK anymore?

    Hi, I purchased the iPhone 4 on 22nd Sept on the Apple UK site and just received it yesterday. So far so good. I've managed to load the Case Program app onto my iPhone 4 and was looking at the cases available and was surprised not to see the official

  • Direct links to Flex forms

    Hi All, I have a site developed in Adobe Flex which is having multiple forms. where i would like to know if there is any way to get the individual links where i can call from another site that should directly route to the particular form i called.