Collable statement and stored procedure problem

Hi,
I am using a collable statement to execute a stored procedure.
The stored procedure is a bit complex since it uses a function to retrieve sequence nextval (newId),
than insert a row and returns the newId.
Anyway, I checked it with sql plus and it works, but when trying to execute it from my Java code, I get the following error message:
java.sql.SQLException: ORA-06550: line 1, column 33:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( ) , * @ % & | = - + < / > at in mod not range rem => ..
<an exponent (**)> <> or != or ~= >= <= <> and or like
between is null is not || indicator is dangling
The symbol ")" was substituted for ";" to continue.
Anyone can help?
Thanks,
Michal

My PL/SQL code:
CREATE OR REPLACE FUNCTION getNotifSeq RETURN NUMBER
IS
newId NUMBER;
BEGIN
     SELECT NOTIFICATION_SEQ.NEXTVAL INTO newId FROM DUAL;
RETURN newId;
END;
run
CREATE OR REPLACE PROCEDURE insertNotifMsg (
sentBy IN VARCHAR,
subject IN VARCHAR,
msg IN VARCHAR,
newId OUT NUMBER)
IS
BEGIN
newId := getNotifSeq;
INSERT INTO NOTIFICATIONS(NOTIF_ID,SENT_BY,SUBJECT,MSG)
VALUES(newId,sentBy,subject,msg);
END insertNotifMsg;
run;
My Java code to call the procedure:
try
conn = myDBconn.getConnection();
CallableStatement callStmt = conn.prepareCall("{call insertNotifMsg(?,?,?,?}");
callStmt.setString(1,notif.getSentBy());
callStmt.setString(2,notif.getSubject());
callStmt.setString(3,notif.getMsg());
callStmt.registerOutParameter(4, Types.INTEGER);
ResultSet rs = callStmt.executeQuery();
if (!rs.next()) {
throw new SQLException("ERROR: Notification was not inserted into database!");
long newId = callStmt.getInt(4);
callStmt.close();
notif.setNotifId(newId);
conn.commit();
callStmt.close();
finally
myDBconn.closeConnection(conn);
Thanks,
Michal

Similar Messages

  • MS SQL Server 7 - Performance of Prepared Statements and Stored Procedures

    Hello All,
    Our team is currently tuning an application running on WL 5.1 SP 10 with a MS
    SQL Server 7 DB that it accesses via the WebLogic jConnect drivers. The application
    uses Prepared Statements for all types of database operations (selects, updates,
    inserts, etc.) and we have noticed that a great deal of the DB host's resources
    are consumed by the parsing of these statements. Our thought was to convert many
    of these Prepared Statements to Stored Procedures with the idea that the parsing
    overhead would be eliminated. In spite of all this, I have read that because
    of the way that the jConnect drivers are implemented for MS SQL Server, Prepared
    Statments are actually SLOWER than straight SQL because of the way that parameter
    values are converted. Does this also apply to Stored Procedures??? If anyone
    can give me an answer, it would be greatly appreciated.
    Thanks in advance!

    Joseph Weinstein <[email protected]> wrote:
    >
    >
    Matt wrote:
    Hello All,
    Our team is currently tuning an application running on WL 5.1 SP 10with a MS
    SQL Server 7 DB that it accesses via the WebLogic jConnect drivers.The application
    uses Prepared Statements for all types of database operations (selects,updates,
    inserts, etc.) and we have noticed that a great deal of the DB host'sresources
    are consumed by the parsing of these statements. Our thought was toconvert many
    of these Prepared Statements to Stored Procedures with the idea thatthe parsing
    overhead would be eliminated. In spite of all this, I have read thatbecause
    of the way that the jConnect drivers are implemented for MS SQL Server,Prepared
    Statments are actually SLOWER than straight SQL because of the waythat parameter
    values are converted. Does this also apply to Stored Procedures???If anyone
    can give me an answer, it would be greatly appreciated.
    Thanks in advance!Hi. Stored procedures may help, but you can also try MS's new free type-4
    driver,
    which does use DBMS optimizations to make PreparedStatements run faster.
    Joe
    Thanks Joe! I also wanted to know if setting the statement cache (assuming that
    this feature is available in WL 5.1 SP 10) will give a boost for both Prepared Statements
    and stored procs called via Callable Statements. Pretty much all of the Prepared
    Statements that we are replacing are executed from entity bean transactions.
    Thanks again

  • Prepared Statement and Stored Procedure..

    I have about 200 SQL statement in my Java application
    I have two options either to convert into
    Stored procedures
    or to convert into prepared statement ....
    Please guide me which options should be best....
    I need difference
    1)in term of speed.
    2)Memory..
    Regards
    Mahesh
    Senior DBA

    club your statements on the basis of related functionalities and change it to stored procedures as it will redudce no. of calls to the database and will be faster to fetch data in one go and even reduce the memory requirements.

  • Prepared Statement and Stored Procedure difference?

    For SQL in my web applications I use PreparedStatement object alot in my JDBC working with Oracle 9i.
    I also heard the term Stored Procedure. What is the difference between Stored Procedure and Prepared Statement?

    I am new to java programming, can anybody explain
    what exactly precompiled means
    Thank you
    PalspaceWhat does you subject line have to do with your question?
    The difference between a stored proc and a prepared statement is mainly this.
    A stored proc is stored in the database server permanently and can be used and re-used from a different connections.
    A PreparedStatement is not valid across connections.
    Stored procs are almost always precompiled. (I am just hedging a bit here just in case but you can consider it 100%)
    PreparedStatements MAY be precompiled. Hard to say.
    Precompiling means at least one of and perhaps all of the following depending on the database
    - The parsing of the SQL statement
    - The checking of the SQL against the data dictionary to ensure that the tables and columns referenced actually exist
    - The preparation of a query plan
    Last but not least Stored procedures may (and often do) contain more than simple queries but are in fact relatively complex programs written in a DB specific language (an offshoot of SQL of some sort).

  • TableAdapters and stored procedures

    Anyone know if there is any support for Oracle using stored procedures with a TableAdapter?
    For those unfamiliar with this feature in VS 2005, we create a strongly typed DataSet, put a table on it using the designer, add/configure a TableAdapter and enter the TableAdapter Configuration Wizard. From here, we choose a connection string, then the next wizard step asks "How should the TableAdapter access the database?" Using an Oracle connection string, the only option that is not disabled is "Use SQL statements".
    At this step, for an SQL Server connection string, we can select "Use existing stored procedures", which is what we want to use now with Oracle 9i R2. We've been using SQL DML statements quite happily with TableAdapters so far, and had not really noticed that this feature would not be available for Oracle. Unfortunately, we now need to use stored procedures, and we quite like the TableAdapters --- once you get over the rather obvious coupling of data access to the DataSet, not having to write so much code to use DataAdapters is quite nice.
    I've read a little about the ODT, and the Oracle Explorer stuff looks pretty cool, but if I go to the trouble of installing the ODT, will it fix my TableAdapter stored procedures problem? Are there any other tools or workarounds?

    Well, I tried it and you're correct; the designer doesn't like package procedures.
    And the designer doesn't like ref cursors, either. I was able to use them, however, by writing my own method. I added the method to my dataset (patial class) and it works great. I probably could have (and should have) put the method in the table adapter class (again, in separate partial class file so that it doesn't get discarded by the designer) but I didn't know that I could do that at the time. Now that I know, I may move it.
    Somewhat related, I found that I could handle events of the OracleDataAdapter in a partial TableAdapter class. Why is this interesting? Because after TableAdapter updates, I think that I can select the updated rows back in to the DataTable. This will be handy (if possible) if the data that I update is modified by a trigger or something. Let me know if you've tried this. By the way, SQL Server makes this easy! Follow your update SQL with a select statement; it all happens in the same command!
    Namespace DGPPDbDataSetTableAdapters
         Partial Public Class MilestoneDatesTableAdapter
              Private Sub adapterRowUpdated(ByVal sender As Object, ByVal e As System.Data.OracleClient.OracleRowUpdatedEventArgs) Handles _adapter.RowUpdated
                   'TODO: Re-Select the updated rows back in to the DataTable
              End Sub
         End Class
    End Namespace

  • Approval Procedures and Stored Procedures

    Hi All
    I have a problem with approval procedures and stored procedures.
    I created an approval procedure to check if a value in the udf is selected or not . if not then a messge is produced to ask the user to select the person to approve the PO.
    Biut now the problem is the PO's are linked approval templates to the error messge don't show before the approval template screen.
    Please assist.
    Thanks
    Bongani Dlamini

    Hi Gordon
    The stored procedure is just for validating if the user has selected the udf value.
    It is not for approval*
    I created an approval template for this purpose. So my problem is when I add the Po to the system the SP doesn't kick-in and alert the user to select the person to approve the PO.
    Process Flow.
    User captures PO then select the value on the UDF Field ( Approver) The value selected is linked to a query which is used by the Approval Template
    If this method is still not supported then please let me know .
    Thanks
    Bongani Dlamini

  • Re   Java Stored Procedure Problem

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

  • DAC task with Informatica mapping and stored procedure (very slow)

    Hello,
    We have a DAC task that launch an Informatica Workflow with a simple query and stored procedure, like this:
    SQL QUERY
    ==========================
    SELECT
    W_ACTIVITY_F.ROW_WID,
    W_AGREE_D.AGREE_NUM,
    W_PRODUCT_D.ATTRIB_51,
    W_SRVREQ_D.ATTRIB_05,
    W_ORG_DH.TOP_LVL_NAME,
    W_ORG_D.ATTRIB_06,
    W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_PRODUCT_D.PROD_NAME
    FROM
    W_AGREE_D,
    W_SRVREQ_F,
    W_ACTIVITY_F,
    W_PRODUCT_D LEFT OUTER JOIN W_PRODUCT_GROUPS_D ON W_PRODUCT_D.PR_PROD_LN = W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_ORG_D,
    W_SRVREQ_D,
    W_ORG_DH
    WHERE
    W_SRVREQ_F.AGREEMENT_WID = W_AGREE_D.ROW_WID AND
    W_SRVREQ_F.SR_WID = W_ACTIVITY_F.SR_WID AND
    W_SRVREQ_F.PROD_WID = W_PRODUCT_D.ROW_WID AND
    W_SRVREQ_F.ACCNT_WID = W_ORG_D.ROW_WID AND
    W_SRVREQ_F.SR_WID = W_SRVREQ_D.ROW_WID AND
    W_ORG_D.ROW_WID = W_ORG_DH.ROW_WID
    STORED PROCEDURE
    ===========================
    ConvSubProy(W_AGREE_D.AGREE_NUM,
    W_PRODUCT_D.ATTRIB_51,
    W_SRVREQ_D.ATTRIB_05,
    W_ORG_DH.TOP_LVL_NAME,
    W_ORG_D.ATTRIB_06,
    W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_PRODUCT_D.PROD_NAME)
    The mapping is very simple:
    Source Qualifier -> Stored procedure -> Update strategy (only two ports: ROW_WID and custom column) -> Target Table
    When I launch the DAC Execution Plan the corresponding task take much time (40 minuts). But when I launch the corresponding Workflow from Informatica PowerCenter Workflow Manager this only take 50 seconds... when I see the log session for the task I can see that much time is spent on the time of the updates. For example, when DAC is running the writer updates 10000 records every 6/7 minuts, but when Workflow Manager is running thw writer updates 10000 records every 8/9 seconds.
    So, what happens (in the DAC) to that so much time difference? Is there a way to reduce the execution time when the task is launched from DAC?
    Thanks
    Best Regards
    Benjamin Tey

    Have you tried using bulk load type?
    In Workflow Manager can you open the associated task, navigate to the mapping tab and seled the target table.
    What is the value for "Target load type" and which of the following boxes are checked: Insert, Update as Update, Update as Insert, Update else Insert, Delete?

  • Database updation using XML and stored Procedure?

    Hello,
    I want to perform updation in multiple tables using XML files.Please suggest can I do updation using xml and stored procedure.
    If yes then which is more efficient and takes less time.
    1.Updation using xml files only
    2.Updation using xml files with stored procedure.
    3.Stored procedure alone.
    If direct xml and stored procedure communication is possible.then please write how.
    Thanks in advance for any help.

    Here's a sample. The next code drop of the XSQL Servlet will make the easy-to-do from within XSQL Pages:
    package package1;
    import org.w3c.dom.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    public class Class1 extends Object {
    public static void main( String[] arg ) throws Exception {
    Connection conn = getConnection();
    CallableStatement ocs = conn.prepareCall("begin ? := App.HotItems('PAUL'); end;");
    ocs.registerOutParameter(1,OracleTypes.CURSOR);
    ocs.execute();
    ResultSet rs = ((OracleCallableStatement)ocs).getCursor(1);
    OracleXMLQuery oxq = new OracleXMLQuery(conn,rs);
    System.out.println(oxq.getXMLString());
    oxq.close();
    rs.close();
    ocs.close();
    conn.close();
    public static Connection getConnection() throws Exception {
    String username = "scott";
    String password = "tiger";
    String dburl = "jdbc:oracle:thin:@localhost:1521:xml";
    String driverClass = "oracle.jdbc.driver.OracleDriver";
    Driver d = (Driver)Class.forName(driverClass).newInstance();
    return DriverManager.getConnection(dburl,username,password);
    null

  • 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

  • Oracle 8i and stored procedures

    Hi I was hoping someone could point me to the right direction here.
    I have been using SQL server before and often use stored procedures. I understand that if you want to use stored procedures you will use the CallableStatement object and the prepareCall method of the Connection object like so:
    let's say my stored proc has 2 number parameters:
    CallableStatement cs = con.prepareCall( " { call <stored_proc_name> (?, ?) } );
    cs.getString(1, 1);
    cs.getString(2, 2);
    ResultSet rs = cs.executeQuery( );
    where con is my connection object that i used to connect to my database. So far am I right with the following code?
    But my problem is I have to use Oracle 8i. So what is the equivalent of SQL server stored procs in Oracle? Is it functions? Procedures? Or Java Stored Procedures? I have been reading all these sites and the forums for ideas but still haev no clue what approach I should take
    I have managed to connect to my db using the thin drivers and have successfully passed SQL statements. Although, I don't want to pass SQL statements, I want to use stored procedures. With SQL server I would create all my stored procedures and use my beans to call these stored procedures. So as a new user of Oracle 8i coming form SQL server, what approach do I use and how?
    Thanks in advance for all the help!

    Alright well looks like I'm stuck now.
    This seems more like a PL\SQL question though. If I want to return 2 or more values do I use function or a procedure? here's the code I made:
    CREATE OR REPLACE FUNCTION sign_in(username VARCHAR(20), userpassword VARCHAR(20))
    RETURN NUMBER IS id_num NUMBER, user_type VARCHAR(1);
    BEGIN
    SELECT * INTO id_num, user_type
    FROM ID_MASTER idm, PERSON prs
    WHERE USERNAME = username
    AND USER_PASSWORD = userpassword
    AND idm.ID_NUM = prs.ID_NUM;
    RETURN id_num, user_type;
    END;
    now according to Oracle this is an invalid function. But the error message doesn't say much. Basically I want to pass 2 parameters to use for a query and return 2 variables from the result of the query. Am I suppose to use a procedure?
    If I pass paramters do which string do I use to prepareCall: "{ ? = CALL sign_in (?, ?) }" or do I use the "{ CALL sign_in (?, ?) }"
    But my problem right now is how to make the proper stored procedure. I'd be very much obliged to anyone who can give a sample. Thank you all for your time!

  • Stored Procedure Problem

    Hello,
    I have a stored procedure that I thought worked. but I am getting an error. Basically, what it does is accept some search terms and then based on whether a value has been passed (-1 is a non value for numbers and 'null' is a non value for varchar2 fields) it returns the matching rows.
    Here is the code for the stored procedure.
    CREATE OR REPLACE  PROCEDURE "SYSADM"."SP_SEARCH_BCRS"
    (  bcr_id_in in number,
        bcr_number_in in varchar2,
        agency_id_in in number,
        lead_analyst_id_in in number,
        programmer_analyst_id_in in number,
        functional_analyst_id_in in number,
        status_id_in in number,
        status_modifier_id_in in number,
        issue_numbers_in in varchar2,
        date_reported_in in varchar2,
        short_description_in in varchar2,
        order_by_in in varchar2,
        cursor_out out types.cursorType )
    AS
          mySQL varchar2(255);
          issue_numbers_and_clause varchar(1000);
          short_desc_and_clause varchar(1000);
    BEGIN
      mySQL := 'select ID, SHORT_DESC, AGENCY_ID, TO_CHAR(DATE_REPORTED, ''MM/DD/YYYY'') "DATE_REPORTED", BCR_NUMBER from bcrs where 1=1';
      IF (bcr_id_in > 0) THEN
        mySQL := mySQL || ' and id = ' || bcr_id_in;
      END IF;
      IF (bcr_number_in != 'null') THEN
        mySQL := mySQL || ' and bcr_number like ''' || UPPER(bcr_number_in) || '''';
      END IF;
      IF (agency_id_in > 0) THEN
        mySQL := mySQL || ' and agency_id = ' || agency_id_in;
      END IF;
      IF (lead_analyst_id_in > 0) THEN
        mySQL := mySQL || ' and lead_analyst_id = ' || lead_analyst_id_in;
      END IF;
      IF (programmer_analyst_id_in > 0) THEN
        mySQL := mySQL || ' and programmer_analyst_id = ' || programmer_analyst_id_in;
      END IF;
      IF (functional_analyst_id_in > 0) THEN
        mySQL := mySQL || ' and functional_analyst_id = ' || functional_analyst_id_in;
      END IF;
      IF (status_id_in > 0) THEN
        mySQL := mySQL || ' and status_id = ' || status_id_in;
      END IF;
      IF (status_modifier_id_in > 0) THEN
        mySQL := mySQL || ' and status_modifier_id = ' || status_modifier_id_in;
      END IF;
      IF (issue_numbers_in != 'null') THEN
        SP_BUILD_TEXT_SEARCH(issue_numbers_in, 'issue_numbers', issue_numbers_and_clause);
        mySQL := mySQL || issue_numbers_and_clause;
      END IF;
      IF (date_reported_in != 'null') THEN
        mySQL := mySQL || ' and date_reported > to_date(''' || date_reported_in || ''', ''MM/DD/YYYY'')-7 and date_reported < to_date(''' || date_reported_in || ''', ''MM/DD/YYYY'')+7 and 1=1 ';
      END IF;
      IF (short_description_in != 'null') THEN
        SP_BUILD_TEXT_SEARCH(short_description_in, 'short_desc', short_desc_and_clause);
        mySQL := mySQL || short_desc_and_clause;
      END IF;
      -- add the order by clause
      mySQL := mySQL || ' order by ' || order_by_in;
      open cursor_out for mySQL;
    END;When I call it like this:
    variable people_out refCursor;
    set serveroutput on
    set autoprint on
    execute sp_search_bcrs(-1, 'null', -1, -1, -1, -1, -1, -1, 'null', 'null', 'null', 'date_reported', :people_out);I get this...
    PL/SQL procedure successfully completed.
            ID SHORT_DESC                                                                                                                                              AGENCY_ID DATE_REPOR BCR_NUMBER
            31 Use this BCR for Testing                                                                                                                                       13 02/12/2004 STW-0034
            32 adf adsf d as dfsd f                                                                                                                                           13 02/16/2004 STW-0035
            33 This is my new BCR                                                                                                                                             12 02/18/2004 HHS-0021
            34 J.P.'s New BCR                                                                                                                                                 13 02/20/2004 STW-0036
    4 rows selected.But when I call it like this...
    variable people_out refCursor;
    set serveroutput on
    set autoprint on
    execute sp_search_bcrs(-1, 'null', -1, -1, -1, -1, -1, -1, 'null', '02/03/2004', 'null', 'date_reported', :people_out);I get this.
    BEGIN sp_search_bcrs(-1, 'null', -1, -1, -1, -1, -1, -1, 'null', '02/03/2004', 'null', 'date_reported', :people_out); END;
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SYSADM.SP_SEARCH_BCRS", line 70
    ORA-06512: at line 1
    ERROR:
    ORA-24338: statement handle not executed
    SP2-0625: Error printing variable "people_out"Note that the only difference is that I am passing a date in the second call for the "date_reported" parameter.
    What I have already tried:
    -- commenting out the statement that appends the order by clause....the sp runs fine.
    -- commenting out the statement that appends the date_reported clause...the sp runs fine.
    I am pretty sure it is a problem with the line that has the date compare for the 'date_reported' but neither my DBA or I can find it.
    I would much appreciate any eyes looking at this.
    Thanks.
    James.

    I must admit, why pass 4-char 'null' instead of just null?
    procedure my_proc (p1 varchar2) is
    begin
    if p1 is not null then -- not if p1 != 'null'
    do something
    end if;
    end;
    execute my_proc (null) not my_proc ('null')
    Also, your params that are meant to be dates, I might just declare them as type date (Oracle will convert) or use a temp date var and to_date(p_date) into it, then add -7 or +7 to the temp date var and to_char that on your output.
    Your proc requires 13 params, 12 IN and 1 OUT (I never use keyword IN if in only). I would put the OUT param first, followed by all 'required' IN parameters, lastly the remaining optional parameters (if any). This may not apply to your example but you can specify a default value for any optional parameters at the end.
    procedure my_proc (p1 varchar2,
    p2 varchar2,
    p3 varchar2 default 'X',
    p4 varchar2 default null);
    execute my_proc ('a','b','c','d')
    execute my_proc ('a','b','c')
    execute my_proc ('a','b')
    Some people prefer overloading.

  • Sp_executesql vs transaction statement within Stored Procedure

    Experts,
    Any difference between sp_executesql vs Transaction/Commit statement or try/catch block within Stored Procedure?
    What is the best practice to use and why?
    Thank You
    Regards,
    Kumar
    Please do let us know your feedback. Thank You - KG, MCTS

    Your question is a bit strange. sp_executesql is used for dynamic SQL. Unless the problem demands dynamic SQL and, therefore, sp_executesql, there is no need to use it.
    For a single statement I would not use transaction and try/catch. For multiple statements you do need to use transaction. It's up to you if you want to use try/catch in the SP or not and trap the error in the client application.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Oracle Stored Procedure problem

    I am upgrading to Coldfusion 8 from MX. I currently have a
    program that accesses Oracle 10g using a stored procedure call
    (cfstoredproc). It works on MX but not on 8. I can do regular
    queries to the Oracle database successfully. Here is the error
    mesage I'm receiving:
    Error Executing Database Query.
    [Macromedia][Oracle JDBC Driver][Oracle]ORA-06550: line 1,
    column 18: PLS-00222: no function with name 'EVENT_COUNT' exists in
    this scope ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    Any ideas?

    Perhaps this tech note may point to one possible solution.
    Updated
    DataDirect JDBC drivers (version 3.5)
    The following problems are corrected in this release of the
    DataDirect drivers.
    Oracle
    61145 - Oracle 10g R2 not supported. cfstoredproc calls that
    return result sets hang the server with both the 3.3, 3.4 and 3.5
    drivers until this version. The 3.5 build 13 drivers support Oracle
    10g R2.
    Phil

  • Using Copy statement in Stored procedure

    The following statement works in sqlplus session:
    copy from comment/password@servername append amcomment_temp using
    select * from amcomment
    where commentid in(1,2,3,4)
    I want to use this in a stored procedure. There is a long datatype in this table. The
    procedure will not compile. Have tried execute immediate and compiler rejects this statement also.

    'COPY' is a SQL*Plus command, not PL/SQL. This is why the PL/SQL compiler throws it out.

Maybe you are looking for

  • Install Error SAP NetWeaver 7.0 ABAP Trial Version SP12  - MaxDB SAP DB WWW

    Hello everybody I try to install the SAPNW7.0 and in the first run I forgot to install the MS Loopback Adapter. And now every installation retry fails. I read a lot of threads, and every time I do the reinstallation, I clean the system (XP Prof SP2)

  • Oracle 8.1.7 for Linux

    Anyone know when Oracle 8.1.7 for Linux will be available for download or if it will fix the incompatibility problems with Red Hat 7? Philip Ross

  • Web query in intranet

    Hello,        I need add a BW web query a intranet's company. This company doesn't have SAP portal but they want have some querys in their intranet. Somebody can help me? Best Regards, César

  • Need to rename files parsing date formats in the filename [SOLVED]

    Godaddy changed the naming scheme of their server logs again.  I need some perl or something magic that will convert format A to format B.  Doing this is bash is going to be painful so I'm hoping some of your perl or python ninjas out there could hel

  • Application video out

    I am building an iPhone application and would like a demo video. Ideally I would like to connect my phone to my tower and have the tower record my iPhone screen while i play with the application. Is this at all possible?