Stored Procedure using Date/Time Comparison

I’m running SQL Server 2012. I need to write a procedure that will send out emails based on a date/time comparison.
In my table, ‘tickets’, I have a smalldatetime column ‘ticket_date’ and another column ‘responded’ which is a bit field. I need to check the current date to see if 24 hours has passed from the ticket_date. If 24 hours has passed and responded is 0, then
I need to email a manager ( I already have the code for  emailing with SMTP).
The next step is to see if 48 hours has passed from the ticket_date and if responded is 0.
 If this is true, then I need to email someone else.
I don’t want to include weekends in my time comparison. My procedure will only run Mon – Fri. 
Thanks in advance!

Check the below sample and hope this will help you:
DECLARE @Tickets TABLE (TicketID INT, TicketDate SMALLDATETIME, Responded BIT)
INSERT INTO @Tickets
SELECT 1, '01/10/2015 10:00AM', 0 UNION ALL
SELECT 2, '01/13/2015 12:00PM', 1 UNION ALL
SELECT 3, '01/12/2015 05:30PM', 0 UNION ALL
SELECT 4, '01/09/2015 08:00AM', 1
SELECT *, '24 Hour' AS TicketCase
FROM
@Tickets
WHERE
Responded = 0
AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) <= (CASE DATEPART(WEEKDAY, TicketDate) WHEN 7 THEN 48 WHEN 1 THEN 24 ELSE 0 END) + 24
UNION ALL
SELECT *, '48 Hour' AS TicketCase
FROM
@Tickets
WHERE
Responded = 0
AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) >= 24
AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) <= (CASE DATEPART(WEEKDAY, TicketDate) WHEN 7 THEN 48 WHEN 1 THEN 24 ELSE 0 END) + 48
Output
TicketID | TicketDate | Responded | TicketCase
3 | 2015-01-12 17:30:00 | 0 | 24 Hour
1 | 2015-01-10 10:00:00 | 0 | 48 Hour
You can make the separate SQL statements and email to proper people based on 24 hour or 48 hour case. 
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

Similar Messages

  • Error while Executing stored procedure using ant

    Hi,
    I am trying to execute a stored procedure using ant ..
    My build.xml is like this...
    <project name="myproject" default="db.build">
    <target name="db.build">
    <sql driver="oracle.jdbc.driver.OracleDriver"
    url="jdbc:oracle:thin:@idm.orademo.com:1521:orcl"
    userid="test"
    password="oracle11g"
    print="yes"
    classpath="E:\\ojdbc14.jar"
    src="E:\\upg_9102BP07.sql" />
    <!--
    <classpath>
    <pathelement path=""\\>
    <\\classpath> -->
    </target>
    </project>
    I have my stored procedure in upg_9102BP07.sql as shown in above src..
    When im executing ant cmd I got the following exception
    E:\>ant -f test.xml
    Buildfile: test.xml
    db.build:
    *[sql] Executing resource: E:\upg_9102BP07.sql*
    *[sql] Failed to execute: declare cnt int*
    BUILD FAILED
    E:\test.xml:12: java.sql.SQLException: ORA-06550: line 1, column 15:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    *:= . ( @ % ; not null range default character*
    Total time: 44 seconds
    I have no clue.. But this sql ran successfully when did manually..
    Please help me in solving the issue...
    -- Marias

    Here is my script bit lengthy...
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_ddl_AddcolumnToRCE_Oracle.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:24:19 devjain Exp $
    Rem
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem Create a new column 'RCE_DELETE' in RCE table
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem blaksham 09/30/09 - Created
    Rem
    declare cnt int;
    Begin
         Select Count(1) into cnt From User_Tab_Columns Where TABLE_NAME='RCM' And COLUMN_NAME='RCM_DELETE';
         IF cnt=0 Then
         Begin
              Execute Immediate 'ALTER TABLE RCM ADD RCM_DELETE VARCHAR2(1)';
         End;
         Else
              DBMS_OUTPUT.PUT_LINE('Column already exists in the DB');
         End IF;
    End;
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_dml_odf_source_name.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:44:45 devjain Exp $
    Rem
    Rem 9103_dml_odf_source_name.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9103_dml_odf_source_name.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem <short description of component this file declares/defines>
    Rem
    Rem NOTES
    Rem <other useful comments, qualifications, etc.>
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem vpotukuc 09/17/09 - Bug8796435: Increase the size of odf_source-name
    Rem vpotukuc 09/17/09 - Created
    Rem
    SET ECHO ON
    SET FEEDBACK 1
    SET NUMWIDTH 10
    SET LINESIZE 80
    SET TRIMSPOOL ON
    SET TAB OFF
    SET PAGESIZE 100
    declare
    collen NUMBER := 0;
    begin
    select char_length into collen from user_tab_columns where table_name = 'ODF' and column_name = 'ODF_SOURCE_NAME';
    IF (collen < 400) then
    execute immediate 'alter table ODF modify ODF_SOURCE_NAME varchar2(400)';
    END IF;
    END;
    File name: 91_dml_update_reviewers_With_NoEmail_attestation.sql
    Purpose: Modify the email template to replace the 'Delegated By Last Name' with 'Reviewer Last Name' and 'Delegated By User Id' to 'Reviewer User Id'.
    Author: Babu Lakshamanaiah
    Description: Modify the email template 'Attestation Reviewers With No E-mail Addresses Defined'
    declare
    cnt int;
    begin
    Select Count(1) into cnt From emd Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    IF cnt=0 Then
    Begin
    DBMS_OUTPUT.PUT_LINE('There is no record with emd_name Attestation Reviewers With No E-mail Addresses Defined ');
    End;
    Else
    update emd set emd_body='The following attestation reviewers do not have email addresses defined. Attestation requests have been generated for these reviewers and can be accessed by loging in to Oracle Identity Manager. However, notification emails were not sent.' ||chr(10) || chr(10) ||
    'Attestation process: <Attestation Definition.Process Name>' || chr(10) ||
    'Attestation Request ID: request <Attestation Request.Request Id>' || chr(10) ||
    'Request date: <Attestation Request.Request Creation Date>' || chr(10) || chr(10) ||
    'Reviewers Without E-mail Address: <reviewers> ' || chr(10) ||
    '<Attestation Task.Reviewer First Name> <Attestation Task.Reviewer Last Name> [<Attestation Task.Reviewer User Id>]' Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    End IF;
    commit;
    end;
    Please help me out.....
    --Marias                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java Stored Procedure using XSU on 9i Lite

    I have create Java Stored Procedure using XML SQL Utility to return results in XML format. I have tested the stored procedure on the development machine (with SDK and Webtogo)without any problem. When I tested it on the client machine (with only the lite database for Window download from the webtogo server as part of the setup), there's an error [POL-8035] no such attribute or method when I call the procedure through MSQL. However, after calling the stored procedure the 3rd times, it will return the results in XML. Once I logout after that, I will have to call the same SP 3 times (always 3 times) before I get the results.
    I'm running on Win2000, Oracle lite 5.0.1. with jdk 1.3.1 - same for the development machine.
    I'm using the same xsu12.jar file.
    What did I miss?

    Nothing?
    No one? No ideias?
    Regards,
    Flavio Matiello

  • Improve the performance in stored procedure using sql server 2008 - esp where clause in very big table - Urgent

    Hi,
    I am looking for inputs in tuning stored procedure using sql server 2008. l am new to performance tuning in sql,plsql and oracle. currently facing issue in stored procedure - need to increase the performance by code optmization/filtering the records using where clause in larger table., the requirement is Stored procedure generate Audit Report which is accessed by approx. 10 Admin Users typically 2-3 times a day by each Admin users.
    It has got CTE ( common table expression ) which is referred 2  time within SP. This CTE is very big and fetches records from several tables without where clause. This causes several records to be fetched from DB and then needed processing. This stored procedure is running in pre prod server which has 6gb of memory and built on virtual server and the same proc ran good in prod server which has 64gb of ram with physical server (40sec). and the execution time in pre prod is 1min 9seconds which needs to be reduced upto 10secs or so will be the solution. and also the exec time differs from time to time. sometimes it is 50sec and sometimes 1min 9seconds..
    Pl provide what is the best option/practise to use where clause to filter the records and tool to be used to tune the procedure like execution plan, sql profiler?? I am using toad for sqlserver 5.7. Here I see execution plan tab available while running the SP. but when i run it throws an error. Pl help and provide inputs.
    Thanks,
    Viji

    You've asked a SQL Server question in an Oracle forum.  I'm expecting that this will get locked momentarily when a moderator drops by.
    Microsoft has its own forums for SQL Server, you'll have more luck over there.  When you do go there, however, you'll almost certainly get more help if you can pare down the problem (or at least better explain what your code is doing).  Very few people want to read hundreds of lines of code, guess what's it's supposed to do, guess what is slow, and then guess at how to improve things.  Posting query plans, the results of profiling, cutting out any code that is unnecessary to the performance problem, etc. will get you much better answers.
    Justin

  • HOW TO CREATE STORED PROCEDURE IN DATA INTEGRATOR

    Hi to every one,
    Can any one help in giving me a solution for creating stored procedure in Data Integrator.
    I m new to this field

    Hi nath,
    Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
    http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
    http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
    EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
    [SCHEMA_NAME]-->is the user with which your creating
    [PROCEDURE_NAME] --> the name given to procedure
    You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
    (OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
    hope answered your question.
    CHeers,
    KK

  • Calling Stored Procedure using J2EE (CMP/BMP)

    Hi guys,
    Can anyone please help me of how to call a stored procedure using a bean in J2EE? I am using Sybase as a database. I am not sure of how to call a stored procedure that is stored in the database server.
    I have one more problem that I am getting in my application. I have 6 entity beans for 6 tables (3 temporary which are deleted and created as and when deployed and 3 permanent which are not deleted when deployed). When I access and manipulate data in temporary tables, everything works fine. But when I try to insert records in the 3 permanent tables, i get an error saying...
    ejbexception.transactionrolledbackerror - Client's transaction rolledback
    Your suggestions would be very valuable.
    Thanks in advance,
    ashish

    Actually, I was getting the RolledBack exception before I was using stored procedure. The bean was supposed to make a few transactions in the tables within the Sybase database. Since it gave me rolledback error, I decided to write a stored proc. in the database and to call that procedure using the bean.
    Now, I am not sure of how to call that procedure using the bean. Also, the syntax of calling that procedure using CallableStatement. I believe, I would have to use Bean Managed Persistence (BMP) if I want to use CallableStatement. I am fooling around with it right now and would let you know if I am getting any exceptions or errors. Meanwhile, any help on the syntax of calling the stored proc. would be highly appreciated.
    Thanks in advance
    Ashish

  • PLS-00306:NET to call Oracle stored procedure,Use Array parameters

    Development Environment:Windows 2003 SP2+Oracle 10g
    . NET to call Oracle stored procedure, use an array of types of parameters
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    OR
    CREATE OR REPLACE type string_array is table of nvarchar2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    ODP.NET(Oracle 10g)
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[2] { "11", "222" };
    cmd.ArrayBindCount=2;
    OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p1.Value = str;
    p1.ArrayBindSize=new int[2]{2,3};
    p1.ArrayBindStatus = new OracleParameterStatus[2]{
    OracleParameterStatus.Success,
    OracleParameterStatus.Success
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
    p2.Direction = ParameterDirection.Output;
    P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p2.Value=0;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored

    Hi,
    See the answer in [this thread|http://forums.oracle.com/forums/thread.jspa?threadID=909564&tstart=0]
    Hope it helps,
    Greg

  • . NET to call Oracle stored procedure, use an array of types of parameters

    . NET to call Oracle stored procedure, use an array of types of parameters
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    Use System.Data.OracleClient
    C# Code:
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[] { "11", "22" };
    OracleParameter p1 = new OracleParameter("i_test", OracleType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.Value = str;
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleType.Int32);
    p2.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored
    Edited by: user10133982 on Jun 4, 2009 7:13 AM

    . NET to call Oracle stored procedure, use an array of types of parameters
    The use of ODP.net(Oracle 10g), the error is still the same
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    ODP.NET(Oracle 10g)
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[2] { "11", "222" };
    cmd.ArrayBindCount=2;
    OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p1.Value = str;
    p1.ArrayBindSize=new int[2]{2,3};
    p1.ArrayBindStatus = new OracleParameterStatus[2]{
    OracleParameterStatus.Success,
    OracleParameterStatus.Success
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
    p2.Direction = ParameterDirection.Output;
    P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p2.Value=0;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored
    Edited by: user10133982 on Jun 5, 2009 7:48 AM

  • Calling an Oracle stored procedure using Toplink API - Please help

    Hi,
    We are evaluating Toplink as a possible data access layer in large service-oriented application. The ability to call db stored procedures from within business object layer is crucial for our architechture.
    I am trying to follow toplink application developer's guide examples on how to call stored procedures using toplink.
    I have the folling java code:
    call.setProcedureName("PR_ROMAN_TEST");
    call.addNamedArgument("IN_PARAM");
    call.addNamedOutputArgument("OUT_PARAM");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    query.addArgument("IN_PARAM");
    Vector params = new Vector();
    params.addElement(new Integer(5));
    Number result = (Number) session.executeQuery(query, params);
    This generates the following SQL statement:
    BEGIN PR_ROMAN_TEST(IN_PARAM=>5, OUT_PARAM=>?); END;
    An attempt to execute it causes a
    java.sql.SQLException: Invalid column index.
    As I understand it, this exception is thrown because of the "?" in place of the out-parameter value holder.
    The SQL statement that I would want toplink to generate and execute should look like:
    DECLARE result number; BEGIN PR_ROMAN_TEST(IN_PARAM=>5, OUT_PARAM=>result); END;
    , but how do I achieve it and how do I capture the return value, all using toplink api?
    Please help
    Thank you in advance,
    Roman

    I read the conversation above. I am running into a similar kind of problem. I get the following error.
    <an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs 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 38: PLS-00103: Encountered the symbol "NAME" when expecting one of the following:. ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like as between from using || The symbol "." was substituted for "NAME" to continue.ORA-06550: line 1, column 55: PLS-00103: Encountered the symbol "ID" when expecting one of the following:. ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 38:PLS-00103: Encountered the symbol "NAME" when expecting one of the following . ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like as between from using || The symbol "." was substituted for "NAME" to continue.ORA-06550: line 1, column 55:PLS-00103: Encountered the symbol "ID" when expecting one of the following: . ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs 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.DatabasePlatform.executeStoredProcedureCall(DatabasePlatform.java:1605)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:649)
    at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:506)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.executeSelectCall(CallQueryMechanism.java:194)
    at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(CallQueryMechanism.java:175)
    at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(DirectReadQuery.java:65)
    at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:73)
    at oracle.toplink.queryframework.ValueReadQuery.execute(ValueReadQuery.java:59)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:493)
    at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:125)
    at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1958)
    at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
    at oracle.toplink.threetier.ClientSession.internalExecuteQuery(ClientSession.java:392)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2246)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1055)
    at com.eplinc.common.persistence.toplink.TopLinkTemplate$2.readFromSession(TopLinkTemplate.java:181)
    at com.eplinc.common.persistence.toplink.SessionReadCallback.doInTopLink(SessionReadCallback.java:59)
    at com.eplinc.common.persistence.toplink.TopLinkTemplate.execute(TopLinkTemplate.java:110)
    at com.eplinc.common.persistence.toplink.TopLinkTemplate.executeQuery(TopLinkTemplate.java:178)
    at com.eplinc.common.persistence.toplink.TopLinkTemplate.executeQuery(TopLinkTemplate.java:172)
    at com.epl.outletteller.dao.toplink.TopLinkOIDGeneratorDAO.generateId(TopLinkOIDGeneratorDAO.java:45)
    The call I am making is as follows :
    public long generateId(String name, long outletId) throws DataAccessException {
    TopLinkTemplate tlTemplate = new TopLinkTemplate();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("AUTONUM.GET_NEXT_VALUE");
    call.addNamedArgument("autonum name");
    call.addNamedArgument("outlet id");
    call.addNamedOutputArgument("OUTPUT_1");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    query.addArgument("autonum name");
    query.addArgument("outlet id");
    Object[] parameters = new Object[2];
    parameters[0] = name;
    parameters[1] = Long.toString(outletId);
    Number uniqueNumber = (Number)tlTemplate.executeQuery(query,parameters);
    return uniqueNumber.longValue();
    This is my Table AUTONUM_SETTING
    AUTONUM_NAME AUTONUM_TYPE START_VAL END_VAL INCREMENT_VALUE
    TRAN_NUM GLOBAL 1 999999 1
    TRACE_NUM OUTLET 1 999999 1
    Any help would be appreciated. Thanks

  • Hi to all... What is a  XML data provider,stored Procedure, personal data

    Hi to all... What is a  XML data provider,stored Procedure, personal data providers in deski.  when we use these data provider in desk top intelligence.. and use of it.
    Please give detail description of the above...
    Thanks for reply..........

    Hi,
    We can create Desktop Intelligence reports using XML Data Provider, Personal Data Files and Stored Procedure.
    Following is some detailed information about these three.
    Xml data provider:
    Xml data provider is used for the integration of external data sources stored in XML format.
    This is similar to HTML.
    Stored Procedure:
    A stored procedure is a set of SQL commands that has been compiled and stored on the database server.
    Once the stored procedure has been "stored", client applications can execute the stored procedure over and over again without sending it to the database server again and without compiling it again.
    Stored procedures improve performance by reducing network traffic and CPU load.
    Personal data files:
    u2022     *.prn files
         A PRN file is a special type of file which contains instructions for a printer, it tells the printer what to print on the page and where as well as which paper tray to use, what the paper size is and a number of other controls.
    u2022     *.asc files
          Between the values of a row any number of carriage returns  or blanks are allowed. In any case it is strongly recommended that the data table be stored in such a way that it can be read and edited easily.
           The values may be stored in any format (integer, floating point, exponential notation) and they must be separated at least by one blank. The class information must be of integer type, the row identifiers are interpreted as strings. The lines can have any length and must not contain any comment.
    u2022     *.csv files
    A CSV file is a specially formatted plain text file which stores spreadsheet or basic database-style information in a very simple format, with one record on each line, and each field within that record separated by a comma.
    Regards,
    Pradnya Kokil

  • Oracle Database Procedure Execute Date/Time

    Hi,
    Is possible to track the Oracle Database Procedure Execute Date/Time?

    Is possible to track the Oracle Database Procedure Execute Date/Time?Yes, by using
    CONNECT sys/password AS SYSDBA
    AUDIT EXECUTE PROCEDURE BY fireid BY ACCESS;

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Running a stored procedure using  isqlPlus

    I have written a simple stored procedure which takes EMPLOYEE_ID as IN parameter returns EMPLOYEE_FIRST_NAME as OUT parameter (For Learning purpose only)
    How do I run this stored procedure using isqlPlus.
    Below is my stored procedure.
    CREATE OR REPLACE PROCEDURE "HR"."MY_PROC_2" (
    EMPLOYEE_ID_NUM in NUMBER,
    EMPLOYEE_FIRST_NAME out VARCHAR2
    as
    begin
    Select FIRST_NAME into EMPLOYEE_FIRST_NAME from Employees
    where Employee_ID = EMPLOYEE_ID_NUM;
    return;
    end;

    did you run that same procedure in SQL*Plus and it functioned ?
    Joel P�rez

  • How to call a stored procedure using its package name in Oracle

    hi
    we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
    i have got 2 queries:
    1- How to call the stored procedure using it's package.
    2- How to capture the In/Out parameter in the response.

    hi Prateek
    thanks for the reply.
    However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
    As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
    How to get the IN-OUT parameter in XI?

  • How to call PL/SQL stored procedure using ODBC?

    Could anyone tell me how can I call PL/SQL stored procedure using
    ODBC? Are there any sample codes?
    Thanx!
    null

    You are correct on all counts, they all should work.
    Oracle Product Development Team wrote:
    : Hi,
    : I don't know the exact syntax in ODBC, but reasoning by analogy
    : with other API's, I'd bet one of the following works
    : (for a call to: procedure my_proc(n1 number, n2 number);):
    : "{ my_proc(1,2); }"
    : "{ call my_proc(1,2); }"
    : "{ begin my_proc(1,2); end }"
    : "begin my_proc(1,2); end;"
    : "begin my_proc(1,2); end"
    : Hope this helps. - Pierre
    : jiangbuf (guest) wrote:
    : : Could anyone tell me how can I call PL/SQL stored procedure
    : using
    : : ODBC? Are there any sample codes?
    : : Thanx!
    : Oracle Technology Network
    : http://technet.oracle.com
    null

Maybe you are looking for

  • It is no longer possible to use ALT + N and ALT + P from the "get info" window.

    On a PC, previously, when in the "get info" windows, it was possible to use ALT + N and ALT + P to switch to the song information for the next and previous song.  Since the update to the newest iTunes, it's no longer possible.  Has anybody found a ke

  • Plm in fileupload with struts commons-fileupload-1.0.jar

    In my application, I use commons-fileupload-1.0.jar for file upload. In the Jsp page, I use the <html:form action="EventDetailsForScheduler" enctype="multipart/form-data" method="POST">. and a file for field <html:file name="eventdetailsform" propert

  • RE: (forte-users) memory management

    Brenda, When a partition starts, it reserves the MinimumAllocation. Within this memory space, objects are created and more and more of this memory is actually used. When objects are no longer referenced, they remain in memory and the space they occup

  • Data Manager Clear Package - VBA Automation Parameters

    Hello guys, I have built an input sheet, where the user selects members from BPC dimensions (ACCDETAIL,ACCOUNT, ACTIVITY,ASSET, etc.). Next, the user clicks on the "Clear Data" button, which triggers a VBA macro (EPM_Clear). This macro should call th

  • PS CS3 Error! plaease help

    I am working on a website that I've already finished building and everything has worked perfectly. However, this morning I opened of the pages in photoshop and all I did was change a font and its color, I did not edit or move anything else. Now when