PL/SQL Procedures using TIME

hello all,
i need some help with using time in my table. how do i insert a time (what data type do i use, and what does the INSERT statement look like), eg. i want a time like 1:00:00am, 2:00:00pm in my receiveTime column.
i have a table:
ID receiveTime
1 need a time
2 need a time
3 need a time
THEN, how would i write a condition for this procedure, the condition is that i want to compare my System Time with the Time in the receiveTime column.
eg. if system time > receive time THEN blah blah;
Edited by: kwerty on Nov 7, 2008 11:47 PM
Edited by: kwerty on Nov 8, 2008 1:18 AM
editted my post a little

DECLARE
    t TIMESTAMP := TIMESTAMP '2008-11-08 11:00:00';
BEGIN
    DBMS_OUTPUT.PUT_LINE('t:             ' || t);
    DBMS_OUTPUT.PUT_LINE('time now:      ' || SYSTIMESTAMP);
    DBMS_OUTPUT.PUT_LINE('30 mins ago:   ' || (SYSTIMESTAMP - INTERVAL '30' MINUTE));
    DBMS_OUTPUT.NEW_LINE;
    IF t < SYSTIMESTAMP - INTERVAL '30' MINUTE
    THEN
        DBMS_OUTPUT.PUT_LINE('Time t is in the last 30 minutes');
    ELSE
        DBMS_OUTPUT.PUT_LINE('t is 30 minutes ago or earlier');
    END IF;
END;
t:             08-NOV-08 11.00.00.000000
time now:      08-NOV-08 11.33.49.010000000 +00:00
30 mins ago:   08-NOV-08 11.03.49.010000000 +00:00
Time t is in the last 30 minutes
PL/SQL procedure successfully completed.

Similar Messages

  • Link to PL/SQL procedure using a Template Manager template.

    Hi,
    I need to link a portal application report (report from SQL query) to a SQL procedure that uses a template manager template. The PL/SQL procedure requires parameters. I'm not be able to create a link based on a PL/SQL procedure. The only solution I found is to setup a link to a Form based on that procedure. But the form is only used to call the PL/SQL procedure by clicking the submit button and redirect to the template.
    Another question:
    Is it planed to support dynamic links based on column conditions?
    I'm using Portal release 3.0.7.6.2.
    thanks in advance
    Jens

    Jens,
    You may want to search the Oracle9iAS Portal Applications forum. It may have the answer you are looking for. This forum is for questions related to the Portal Development Kit.
    Thanks,
    Sue
    Sue

  • Regarding execution of pl/sql procedure using JSP

    HI all
    Please help me.
    i am customizing a jsp page ,which is executing one sql procedure first then selecting data from the table in which procedure is inserting.
    How can i pass parameter dynamically to the sql procedure ? ,which i am getting from an HTML page.
    Please help me out.
    regards
    satendra

    this is the sample code provided by oracle.
    * This sample shows how to call PL/SQL blocks from JDBC.
    import java.sql.*;
    class PLSQL
    public static void main (String args [])
    throws SQLException, ClassNotFoundException
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String url = "jdbc:oracle:oci8:@";
    try {
    String url1 = System.getProperty("JDBC_URL");
    if (url1 != null)
    url = url1;
    } catch (Exception e) {
    // If there is any security exception, ignore it
    // and use the default
    // Connect to the database
    Connection conn =
    DriverManager.getConnection (url, "scott", "tiger");
    // Create the stored procedures
    init (conn);
    // Cleanup the plsqltest database
    Statement stmt = conn.createStatement ();
    stmt.execute ("delete from plsqltest");
    // Close the statement
    stmt.close();
    // Call a procedure with no parameters
    CallableStatement procnone = conn.prepareCall ("begin procnone; end;");
    procnone.execute ();
    dumpTestTable (conn);
    procnone.close();
    // Call a procedure with an IN parameter
    CallableStatement procin = conn.prepareCall ("begin procin (?); end;");
    procin.setString (1, "testing");
    procin.execute ();
    dumpTestTable (conn);
    procin.close();
    // Call a procedure with an OUT parameter
    CallableStatement procout = conn.prepareCall ("begin procout (?); end;");
    procout.registerOutParameter (1, Types.CHAR);
    procout.execute ();
    System.out.println ("Out argument is: " + procout.getString (1));
    procout.close();
    // Call a procedure with an IN/OUT prameter
    CallableStatement procinout = conn.prepareCall ("begin procinout (?); end;");
    procinout.registerOutParameter (1, Types.VARCHAR);
    procinout.setString (1, "testing");
    procinout.execute ();
    dumpTestTable (conn);
    System.out.println ("Out argument is: " + procinout.getString (1));
    procinout.close();
    // Call a function with no parameters
    CallableStatement funcnone = conn.prepareCall ("begin ? := funcnone; end;");
    funcnone.registerOutParameter (1, Types.CHAR);
    funcnone.execute ();
    System.out.println ("Return value is: " + funcnone.getString (1));
    funcnone.close();
    // Call a function with an IN parameter
    CallableStatement funcin = conn.prepareCall ("begin ? := funcin (?); end;");
    funcin.registerOutParameter (1, Types.CHAR);
    funcin.setString (2, "testing");
    funcin.execute ();
    System.out.println ("Return value is: " + funcin.getString (1));
    funcin.close();
    // Call a function with an OUT parameter
    CallableStatement funcout = conn.prepareCall ("begin ? := funcout (?); end;");
    funcout.registerOutParameter (1, Types.CHAR);
    funcout.registerOutParameter (2, Types.CHAR);
    funcout.execute ();
    System.out.println ("Return value is: " + funcout.getString (1));
    System.out.println ("Out argument is: " + funcout.getString (2));
    funcout.close();
    // Close the connection
    conn.close();
    // Utility function to dump the contents of the PLSQLTEST table and
    // clear it
    static void dumpTestTable (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("select * from plsqltest");
    while (rset.next ())
    System.out.println (rset.getString (1));
    stmt.execute ("delete from plsqltest");
    rset.close();
    stmt.close();
    // Utility function to create the stored procedures
    static void init (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    try { stmt.execute ("drop table plsqltest"); } catch (SQLException e) { }
    stmt.execute ("create table plsqltest (x char(20))");
    stmt.execute ("create or replace procedure procnone is begin insert into plsqltest values ('testing'); end;");
    stmt.execute ("create or replace procedure procin (y char) is begin insert into plsqltest values (y); end;");
    stmt.execute ("create or replace procedure procout (y out char) is begin y := 'tested'; end;");
    stmt.execute ("create or replace procedure procinout (y in out varchar) is begin insert into plsqltest values (y); y := 'tested'; end;");
    stmt.execute ("create or replace function funcnone return char is begin return 'tested'; end;");
    stmt.execute ("create or replace function funcin (y char) return char is begin return y || y; end;");
    stmt.execute ("create or replace function funcout (y out char) return char is begin y := 'tested'; return 'returned'; end;");
    stmt.close();
    }

  • Generating Web Service from PL/SLQL procedures using ODSI

    1) Is there a way for us to generate REST based web services from PL/SQL procedures using Oracle data services Integrator? If Yes, Can you please point me to any available documentation
    2) I am trying to create a phyiscal data source based on PL/SQL procedures in the hope of turning these data sources into web services. I created a JDBC connection in web logic server console and am trying to view the packages under APPS but ODSI always crashes after selecting APPS. Is there a way to resolve this?
    Thanks
    Bhanu

    Hi..
    We came accross this problem a while back (I think it was us that the patch was created for). The patch was released under CR369707.
    Additionally it took us a while to figure out how to use it correctly.. Here's the info for it from a mail i receievd from our support contact..
    Here is more information from engineering on the patch:
    This is patch for filtering Stored Procedures in the New Physical Data Service Wizard. It is a partial fix to the problem. It just does filtering - it still retrieves all the jdbc metadata for everything that matches the filter. Ideally, the wizard would let you explore the stored procedures - retrieving the name only - and once you selected a stored procedure, it would retrieve the argument types (which is the expensive part).
    Copy these two files to a safe place
    <bea_home>\<aldsp_home>\eclipse-plugins\dsp\eclipse\plugins\com.bea.dsp.ide.external_10.3.0\dsp-ide-ldshredder.jar
    <bea_home>\<aldsp_home>\eclipse-plugins\dsp\eclipse\plugins\com.bea.dsp.ide.import_metadata_10.3.0.jar
    Replace the files with the ones provided in the patch (which I sent you be eMail recently).
    Creating Relational Database Physical Data Services -> Stored Procedures will be affected as follows :
    The Search field used to represent a pattern for the stored procedures only, and this patterns were applied against every schema visible to ALDSP. The patch allows you to also specify a list of catalogue patterns (useful only when applicable), a list of schema patterns and a list of procedure name patterns. These lists are separated by the pipe symbol, and the lists themselves are command-separated. The catalogue and schema patterns are regular expressions, the procedure pattern is for a database 'like' clause. For, Oracle, the catalogue patterns are not applicable.
    Example:
    |ODM1,ODM2|B% // look in schemas containing the strings ODM1 or ODM2 for procedures that start with B
    // possible results would be MY_ODM1.BUILDER, ODM2.BOTTOM
    |^ODM$|B%D // look in the ODM schema for procedures that start with B and end with D.
    Also - if there is a search string in the Search box, that search string will be applied to the schema when you click on the + to expand it in the Tree.
    Note that once a schema has been 'explored' - either by a search, or by expanding it in the tree, further searches will not update it's children. You would need to quit the wizard and restart.
    Once you get the patch if you have issues let me know..

  • Calling pl/sql procedure from a java class.

    I have an onSubmit event that needs to call a pl/sql procedure using the named connection. Can anyone tell me how this is code in a Model 1 ADF JSP page?

    Look at the following related thread:
    Programatically setting attribute values.

  • PL/SQL procedure -- log files?

    Say when i execute a PL/SQL procedure using SQL* Plus. Is there a place where these executions are stored/logged? Any trace files?
    And, when a Java program calls my stored procedure, is there a place these transactions are stored, just to check what exactly is being passed to my stored procedure and what the procedure gave back as result set?
    Any pointers will be appreciated. Thanks.

    Hi
    Use a system.out.println(parametername) to check what values you are passing to the procedure.. you can see the results in your application server console.
    Thanks

  • Calling PL\SQL procedures

    What's the best way to invoke a PL\SQL procedure using Java?
    I am hoping to use the values passed from the JSP into the database for computations but don't know how to call the procedure after the commit.
    Any ideas?
    Thanks a lot!

    Example follows for a PL/SQL proc call from a Java application that returns a result set and displays it in a scrolling pane. Hope it helps you:
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try
    CallableStatement call =
    OpenDBConnections.myJdbcConnection.prepareCall
    ("{? = call MY_PLSQL_PROC(?)}");
    call.registerOutParameter(1,OracleTypes.CURSOR);
    call.setString(2,partNumber_tf.getText().toString());
    call.execute();
    OracleResultSet rset=(OracleResultSet)call.getObject(1);
    /* use caching result set cuz it is non scrollable stored proc result */
    model = new CachingResultSetTableModel(rset);
    result_tbl = new JTable(model);
    status_tf.setText(result_tbl.getRowCount()+" matching Rows found.");
    jScrollPane1.getViewport().add(result_tbl, null);
    rset.close();
    call.close();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    catch (SQLException esql)
    System.out.println(esql.toString());
    }

  • Make EXE for Pl/sql procedure

    Hi all,
    I have one Pl/sql procedure for which i want make EXE.
    can we make EXE files for PL/sql procedures using ' Oracle Developer Tools for Visual Studio .NET'
    Thank you.

    Hi Al,
    Can you tell me in steps how to create EXE for pl/sql procedure using C# console application.
    I have one webservice link which i want to invoke and i have to put the webservice output in a saparate file.
    I wrote Pl/sql procedure which invokes/consumes the webservice using UTL_HTTP and also placed the output of Webservice in a saparate file using UTL_FILE.
    But i have to execute this procedure on a Workstation where there is No Oracle installed.
    as you suggested using C# console application. Will this Procedure with UTL_FILE & UTL_HTTP packages run in that c# console application.
    Thank you

  • DBI Reports Using PL/SQL Procedure

    Hi all,
    Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure.
    I want to customize a Report that is using Data Source as of type PL/SQL Procedure.
    Please Reply to me If anyone has any Idea on this..
    Thanks in Advance..

    Hi Blushadow
    Now if i want to update say only 10 records at a time what should i put into my Proc?
    Please go thru my Proc below..
    CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
    As
    Cursor cur_user_role Is
    Select a.org_id,a.user_id
    from prts_user a,issue_user_role b
    where a.user_id=b.user_id;
    upd_rec cur_user_role%rowtype;
    v_rows_processed Number:=0;
    Begin
    Open cur_user_role;
    Loop
    Fetch cur_user_role into upd_rec;
    If cur_user_role%NOTFOUND
    Then
    Exit;
    Else
    update Issue_user_role
    set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
    Where Issue_User_Role.rowid in
    (select issue_user_role.rowid
    FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
    Where Issue_User_Role.Issue_Id=Issue.Issue_id
    And Issue_User_Role.Issue_id=issue_workflow.issue_id
    And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
    And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
    And Issue.Issue_id=Issue_workflow.Issue_Id
    And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And issue_workflow.primry_workflow_flag='Y'
    And issue_user_role.user_id = upd_rec.user_id
    And issue.issue_status_id in (1636,50738,275,50737,2090)
    And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
    v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
    If Mod (v_rows_processed,v_rows_processed)=10
    then
    COMMIT;
    End if;END IF;
    End Loop;
    Commit;
    dbms_output.enable(1000000);
    dbms_output.put_line('There were '||v_rows_processed||' rows updated');
    Close cur_user_role;
    End;
    I would appreciate if you can let me know any other alternative way to meet this requirment.
    Cheers
    Vineet

  • Performance of AQ when using callback procedure (using PL/SQL notification)

    I am enqueueing XMLType in AQ.XML file is large in size.NOw I want to dequeue the AQ using PL/SQL notification(using callback procedure which will call DBMS_AQ.DEQUEUE to dequeue the AQ and process the XML.After fetching the data from XML ,I want to store these data in another table columns).
    Please suggest,In this case which approach would be better to dequeue the AQ table :
    1.PL/SQL notification(using callback procedure)
    OR
    2.Scheduling the call to DBMS_AQ.DEQUEUE to dequeue the AQ table
    What would be the impact on performance of above two approaches?

    Hi,
    The question of performance is not down to the technique one employes to enqueue/dequeue, but at a basic level, is relative to the number of messages!
    The is what the Oracle documentation states:
    >
    When persistent messages are enqueued, they are stored in database tables. The performance characteristics of queue operations on persistent messages are similar to underlying database operations. The code path of an enqueue operation is comparable to SELECT and INSERT into a multicolumn queue table with three index-organized tables. The code path of a dequeue operation is comparable to SELECT, DELETE, and UPDATE operations on similar tables.
    >
    So, if anything, the dequeue is a fraction more time & resource consuming. However, it is only a "fraction". You could always add multiple subscribers to dequeue if you want!
    You could ofcourse choose to have non-persistent messages if your application does not need the kind of fault-tolerance that persistent messaging offers, which speed things up, but only a bit, so don't get too excited about it!
    There are other things to consider however, which you may wish to read up on before getting bogged down on whether you should use notification or the scheduler:
    - Is your system clustered?
    - Concurrency on a single queue (i.e. multiple enqueues/dequeues, but single queue)
    - Propogation latency issues
    Read about these and much more at:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/perform.htm
    Finally, whether you pl/sql notification or not and whether you use dbms_scheduler is down to your application requirements!
    P;

  • Creating page items from pl/sql procedure and using them on a page

    I have a page containing 2 select lists (P21_DEPARTMENTS and P21_DATE). Originally I added them as items that were "select list with submits". The problem is that based on the clearance level of the currently logged on user I only wanted the P21_DEPARTMENTS to be a select list if the user was an administrator. If however the user is not an admin then I want the page to have a hidden form field called P21_DEPARTMENTS that stores the user's department and has a label item that has the department name.
    There is also a report region that generates a table based on the department selected from the select list (if the user is an admin) or the value stored in the hidden form field if the user is not.
    My problem is that I cannot have both those items on the same page and use the HTML built-in authentication to determine which item should be rendered because I need to use the same ID for both items so that the stored procedure in my report region doesn't break. HTML does not permit items to share the same ID.
    I tried to circumvent the problem by creating a stored procedure that performs all of the item rendering in the procedure and uses "htp.p()" to output all of my HTML code. This solution would allow me to pass a parameter into the procedure informing me as to whether or not the user is an administrator. If the user is an administrator the procedure would use a conditional statement and render a select list. If not, the hidden form field and label option would be used instead.
    I finally got the stored procedure working perfectly. Now I am encountering the most bizarre thing. Since the "select list with submit" was not working (I used the same code that gets generated when I created other items using htmlDB's GUI) I decided to use a JavaScript function instead that gets triggered by the onChange event. I send along the value that is currently selected in the select list and in the function I set:
    location.href='http://www.myoraclesite.com/pls/htmldb/f?p=111:21:729740000000000000::NO::P21_DEPARTMENTS:1';
    In theory this should work. The problem is that it doesn't. The page reloads and the P21_DEPARTMENTS select list is not pre-selected.
    The only thing I can think of is that when htmlDB generates page items that you've created with it's own admin tool it assigns some internal guid or something as opposed to when someone tries to generate dynamic page items of their own from a pl/sql procedure it's like the application doesn't even know they exist.
    Any help would be GREATLY appreciated.
    My only other solution would be to create a totally separate page (one for admin and another for non-admin). I would really like to avoid this.
    Thanks in advance.

    I would love to be able to generate my menus and
    various other items in my htmlDB applications in much
    the same way I can using ASP, PHP and Cold Fusion.
    Users should have the ability to write server-side
    code wherever they feel like it. The way htmlDB works
    right now I spend more time trying to figure out how
    to create simple effects and generate simple
    interfaces when I need to be building a portal. Ami - it's important to understand that HTML DB is not like other languages. Thus, trying to force concepts which are common in other languages into HTML DB will often result in more work.
    It's definitely worth the time to go over the HTML DB 2-day Developer, which can be found here: http://www.oracle.com/technology/products/database/htmldb/pdf/B14377_01.pdf
    I can build a portal using Classic ASP, C#, PHP or Cold
    Fusion in like 1/10 of the time that it takes me to
    build one using htmlDB. I understand that this is not
    meant for the hard-core programmer but no web
    programming application in today's day and age should
    prevent experts from getting under the hood.And I can build a Portal in HTML DB in 1/10 the time it will take me to do it in any other language. It's like anything else - proficiency comes with practice and work.
    As for getting under the hood, there is plenty of places you can do that with HTML DB. Keep in mind that HTML DB itself is an HTML DB application, so the limits on what you can build with HTML DB are virtually limitless.
    Sorry for the vent there. After spending the last 2
    days trying to figure out how to implement such a
    straightforward thing and now being informed that it
    can't be done kind of bugged me.I understand your frustration, as I've been there before. My rule for beginners is that if you are writing more than a line or two of code in the first week, you're doing something wrong. Stop, take a break, and then use the ample resources (including searching this forum) to help solve your problem. There are plenty of resources available for you to learn about HTML DB on the HTML DB home page: http://otn.oracle.com/htmldb
    Good luck,
    - Scott -

  • Deploy warnings using a PL/SQL procedure (from a Public Transform Package)

    OWB Version: 10.2
    I am receiving the following warnings when I attempt to deploy a map that contains a reference to a custom pl/sql procedure that is setup in a public transformation package:
    Warning
    ORA-06550: line 115, column 32:
    PLS-00112: end-of-line in quoted identifier
    ORA-06550: line 115, column 9:
    PLS-00103: Encountered the symbol "." when expecting one of the following:
    := . ( @ % ; not null range default character
    I reviewed the OWB generated code and I discovered the OWB is a adding two double quotes in front of any reference to the package name. For example.....
    BEGIN
    COMMIT;
    sql_stmt := 'ALTER SESSION DISABLE PARALLEL DML';
    EXECUTE IMMEDIATE sql_stmt;
    IF NOT ""ZZTEST"."INIT_SF_USER_CLAS_St" THEN
    * note the "" in front of ZZTEST, which is the package name.
    Has anyone else encountered this issue? I can manually correct the generated the code, but it would be overridden every the time the map is deployed. I encounter the same issue if I import a custom pl/sql procedure from the database into OWB using the Metadata Import Wizard and use the imported procedure in a map. However, I can setup an standalone procedure or function as a public transformation and the map deploys successfully. Please advise.
    Regards,
    Matt

    You have to create a job to start your procedure.
    Example :
    * http://psoug.org/reference/OLD/dbms_job.html
    Then create a procedure to start your job, call it from your dashboard and you're done.
    Success
    Nico

  • ORA-01458 error while using Pro*C to invoke PL/SQL procedure, pls help

    I am using Pro*C (Oracle 10g on Itanium platform) to invoke PL/SQL procedure to read RAW data from database, but always encoutered ORA-01458 error message.
    Here is the snippet of Pro*C code:
    typedef struct dataSegment
         unsigned short     len;
         unsigned char     data[SIZE_DATA_SEG];
    } msg_data_seg;
    EXEC SQL TYPE msg_data_seg IS VARRAW(SIZE_DATA_SEG);
         EXEC SQL BEGIN DECLARE SECTION;
              unsigned short qID;
              int rMode;
              unsigned long rawMsgID;
              unsigned long msgID;
              unsigned short msgType;
              unsigned short msgPriority;
              char recvTime[SIZE_TIME_STRING];
              char schedTime[SIZE_TIME_STRING];
              msg_data_seg dataSeg;
              msg_data_seg dataSeg1;
              msg_data_seg dataSeg2;
              short     indSeg;
              short     indSeg1;
              short     indSeg2;
         EXEC SQL END DECLARE SECTION;
         qID = q_id;
         rMode = (int)mode;
         EXEC SQL EXECUTE
              BEGIN
                   SUMsg.read_msg (:qID, :rMode, :rawMsgID, :msgID, :msgType, :msgPriority, :recvTime,
                        :schedTime, :dataSeg:indSeg, :dataSeg1:indSeg1, :dataSeg2:indSeg2);
              END;
         END-EXEC;
         // Check PL/SQL execute result, different from SQL
         // Only 'sqlcode' and 'sqlerrm' are always set
         if (sqlca.sqlcode != 0)
              if (sqlca.sqlcode == ERR_QUEUE_EMPTY)          // Queue empty
                   throw q_eoq ();
              char msg[513];                                        // Other errors
              size_t msg_len;
              msg_len = sqlca.sqlerrm.sqlerrml;
              strncpy (msg, sqlca.sqlerrm.sqlerrmc, msg_len);
              msg[msg_len] = '\0';
              throw db_error (string(msg), sqlca.sqlcode);
    and here is the PL/SQL which is invoked:
    SUBTYPE VarChar14 IS VARCHAR2(14);
    PROCEDURE read_msg (
         qID          IN     sumsg_queue_def.q_id%TYPE,
         rMode          IN     INTEGER,
         raw_msgID     OUT     sumsg_msg_data.raw_msg_id%TYPE,
         msgID          OUT sumsg_msg_data.msg_id%TYPE,
         msgType          OUT sumsg_msg_data.type%TYPE,
         msgPrior     OUT sumsg_msg_data.priority%TYPE,
         msgRecv          OUT VarChar14,
         msgSched     OUT VarChar14,
         msgData          OUT sumsg_msg_data.msg_data%TYPE,
         msgData1     OUT sumsg_msg_data.msg_data1%TYPE,
         msgData2     OUT sumsg_msg_data.msg_data2%TYPE
    ) IS
    BEGIN
         IF rMode = 0 THEN
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY sched_time, raw_msg_id)
                   WHERE ROWNUM = 1;
         ELSIF rMode = 1 THEN
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY recv_time, raw_msg_id)
                   WHERE ROWNUM = 1;
         ELSE
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY priority, raw_msg_id)
                   WHERE ROWNUM = 1;
         END IF;
         UPDATE sumsg_msg_data SET status = 1 WHERE raw_msg_id = raw_msgID;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
              raise_application_error (-20102, 'Queue empty');
    END read_msg;
    where sumsg_msg_data.msg_data%TYPE, sumsg_msg_data.msg_data1%TYPE and sumsg_msg_data.msg_data2%TYPE are all defined as RAW(2000). When I test the PL/SQL code seperately, everything is ok, but if I use the Pro*C code to read, the ORA-01458 always happen, unless I change the SIZE_DATA_SEG value to 4000, then it passes, and the result read out also seems ok, either the bigger or smaller value will encounter ORA-01458.
    I think the problem should happen between the mapping from internal datatype to external VARRAW type, but cannot understand why 4000 bytes buffer will be ok, is it related to some NLS_LANG settings, anyone can help me to resolve this problme, thanks a lot!

    It seems that I found the way to avoid this error. Now each time before I read RAW(2000) data from database, i initialize the VARRAW.len first, set its value to SIZE_DATA_SEG, i.e., the outside buffer size, then the error disappear.
    Oracle seems to need this information to handle its data mapping, but why output variable also needs this initialization, cannot precompiler get this from the definition of VARRAW structure?
    Anyone have some suggestion?

  • 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

  • Execute Dynamic SQL statement using procedure builder

    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks

    Hi,
    You can very well use DBMS_SQL Package supplied by Oracle for doing this.
    Search for DBMS_SQL in OTN. You will get all info regarding this.
    Regards.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by itslul:
    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks<HR></BLOCKQUOTE>
    null

Maybe you are looking for

  • Importing Organization in CRM 2015 Issueing timeout Errror

    Dear All. I am Having Trouble with importing the Organization into MSCRM 2015 , The Following screenshot is showing that Error. And The full description of that error is "Timeout expired.  The timeout period elapsed prior to completion of the operati

  • Having issues installing Laserjet 2250n on Windows XP

    Hi, I am having issues installing my HP Laserjet 2250n on my computer running Windows XP. I have downloaded a number of drivers from the HP site (listed below) and each time i try to install through windows new hardware wizard, it gives me a message

  • Notebook crash

    i have a hp pavilion dv7-1130us and it has crashed.  was my late mother-in-law & we do not have the disc that came with the notebook.  Screen is asking for book disk...I do not have it.  Any assistance is appreciated.

  • Finder file arrangement

    I know there are differece way of catogorizing the file structure in finder, but I use the colum view mostly. Now I want the files seperated from the folder, this works when you use "kind" but it just never gets in alpabetically order. when I do by n

  • XQuery is causing lots of disk writing

    Hi, In our system, we found that XQuery is causing lots of disk writing. I guess it is due to cache. In dbxml document, it says: All Berkeley DB XML applications are capable of writing temporary files to disk. This happens when the disk cache fills u