Error in the PL/SQL procedure

Kindly suggest how to correct the error in below given procedure

DECLARE
   l_error   VARCHAR2 (4000);
BEGIN
   FOR i IN 1 .. apex_application.g_f02.COUNT
   LOOP
      IF   (apex_application.g_f18(i)) IS NOT NULL
       AND (apex_application.g_f19(i)) IS NULL
       AND (apex_application.g_f20(i)) IS NULL
       AND (apex_application.g_f21(i)) IS NULL
      THEN
         l_error :=' Enter values for column  19,20,21 ';
      END IF;
   END LOOP;
 
   RETURN (l_error);
END;
 
I get the error - In a procedure, RETURN statement cannot contain an expression

user12957777 wrote:

Kindly suggest how to correct the error in below given procedure

DECLARE
l_error   VARCHAR2 (4000);
BEGIN
FOR i IN 1 .. apex_application.g_f02.COUNT
LOOP
IF   (apex_application.g_f18(i)) IS NOT NULL
AND (apex_application.g_f19(i)) IS NULL
AND (apex_application.g_f20(i)) IS NULL
AND (apex_application.g_f21(i)) IS NULL
THEN
l_error :=' Enter values for column  19,20,21 ';
END IF;
END LOOP;

RETURN (l_error);
END;

I get the error - In a procedure, RETURN statement cannot contain an expression

You are in an anonymous PL/SQL block. By definition, they cannot return no matter what... you create a function if you want to use a RETURN order you are trying.

Tags: Database

Similar Questions

  • Call the PL/SQL procedure with in out parameter of OIC clob

    Hello

    For a few days, I am facing a problem. I have to call the pl/sql procedure with colb parameter out. I use c ++ and OIC (don't ask me why :)).

    I use a pl/sql problem test procedure:

    create or replace function Test (longField outside clob) return number is
    Number of result;
    Start
    longField: = 'prefix ';
    Result: = 12;
    Return (result);
    end Test;

    So I do all the stuff with the connection to the DB,

    I prepare the statement: "start: res: = test(:param); end; »
    So I OCIHandleAlloc (m_pCtx-> hpEnv,
    (void *) & m_hpStatement,.
    OCI_HTYPE_STMT,
    0,
    (NULL);
    and
    OCIStmtPrepare (m_hpStatement,
    m_pCtx-> hpErr,
    (...),
    (...),
    OCI_NTV_SYNTAX,
    OCI_DEFAULT);

    Before the binding I prepare parameters. For a clob I devote to the lob Locator:

    OCIDescriptorAlloc ((dvoid *) m_pCtx-> hpEnv, (dvoid *) & m_pLobLocator,)
    (ub4) OCI_DTYPE_LOB (size_t) 0, (dvoid *) 0);
    OCILobEnableBuffering (m_pCtx-> hpContext, m_pCtx-> hpErr, (OCILobLocator *) m_pLobLocator);

    that I bind parameters using OCIBindByName and OCIStmtExecute statement execution.

    I get an error
    ---------------------------
    Microsoft Visual C++
    ---------------------------
    Unhandled exception in... (ORAOCIEI11. (DLL): 0xC0000005: Access Violation.

    My question is: is it possible to call the pl/sql procedure with parameter BEAK clob?
    If Yes, what steps I need to do to succeed?

    Thank you for your response.

    Hello

    Of course, it is possible :)

    Show that you are your piece of code that is binding.
    Are you sure you had correctly the lob descriptor in the call to bind?

  • Cannot see the table in the p/sql procedure but can in normal sql

    Hello

    using 11.2.0.3

    that sql format

    Select schema_owner. < table > - it works in good sql and pl/sql get message table or view does not exist.

    Other fine tables.

    Y at - it a permission to have reference to the table in the pl/sql procedure rather than sql?

    Thank you

    Hello

    I'm glad you solved the problem!

    Don't forget to mark it as "answered".  It will help others with a similar problem, and it will save time for people answering questions on this forum.

  • Errors in the schema SQL TestStand 4.1.1

    I am trying to create a new MSDE 2005 SQL Server database using the new schema of TestStand 4.1.1. I've used the SQL Server stored procedure to generate a .sql file, and then run this SQL file. I get several errors similar to the following:

    > CREATE TABLE STEP_RESULT (ID uniqueidentifier PRIMARY KEY, UUT_RESULT uniqueidentifier, STEP_PARENT uniqueidentifier, int ORDER_NUMBER, STEP_NAME varchar (255), STEP_TYPE varchar (255), STEP_GROUP varchar (32), STEP_INDEX int, STEP_ID varchar (32), STATUS varchar (255), REPORT_TEXT varchar (255), int, varchar ERROR_MESSAGE ERROR_CODE (255), CAUSED_SEQFAIL bit, MODULE_TIME float, float TOTAL_TIME) Int NUM_PASSED int NUM_LOOPS, int NUM_FAILED, int ENDING_LOOP_INDEX, int LOOP_INDEX, int INTERACTIVE_EXENUM, CONSTRAINT STEP_RESULT_FK FOREIGN KEY (UUT_RESULT) REFERENCES (ID))
    Command failed with the following error...:
    Line 1: Syntax incorrect close '('.) (- 2147217900)

    I tried to run this statement in both MSDE and through the viewer of TestStand database with similar results. Everyone knows this problem or have any ideas?

    Function to generate the SQL files from a schema does not always perfect SQL statements, but closer you get to where you need to be to try to create it from scratch. Have you thought to look at the default SQL files included with the product, specifically the file "SQL Server Create Stored Proc result Tables.sql" located in the directory "\Components\Models\TestStandModels\Database?" It is a file that should work out of the box for the default schemas for SQL server and MSDE. Other SQL files for other schemas by default, and there are older SQL files for previous versions in the subdirectory 'previous patterns (2.x - 4.0).

  • Nested reading XML using XQUERY in the PL/SQL procedure

    I'm using Oracle 11 G.
    I have a PL/SQL procedure, which is reading XML using xquery XMLTYPE column in a table. The XML contains data of the DEPARTMENT and its SECTIONS. DEPARTMENT has a to-many with SECTIONS or a DEPARTMENT can have one or more SECTIONS, and there may be cases where the DEPARTMENT will have all SECTIONS.

    The XML structure is such that
    <DATA>
    label to identify a DEPARTMENT and all its corresponding SECTIONS.

    XML
    <ROWSET> 
    <DATA>
     <DEPARTMENT>
      <DEPARTMENT_ID>DEP1</DEPARTMENT_ID>
      <DEPARTMENT_NAME>myDEPARTMENT1</DEPARTMENT_NAME>
     </DEPARTMENT>
     <SECTIONS>
      <SECTIONS_ID>6390135666643567</SECTIONS_ID>
      <SECTIONS_NAME>mySection1</SECTIONS_NAME>
      </SECTIONS>
       <SECTIONS>
      <SECTIONS_ID>6390135666643567</SECTIONS_ID>
      <SECTIONS_NAME>mySection2</SECTIONS_NAME>
      </SECTIONS>
     </DATA>
     <DATA>
     <DEPARTMENT>
      <DEPARTMENT_ID>DEP2</DEPARTMENT_ID>
      <DEPARTMENT_NAME>myDEPARTMENT2</DEPARTMENT_NAME>
     </DEPARTMENT>
     <SECTIONS>
      <SECTIONS_ID>63902</SECTIONS_ID>
      <SECTIONS_NAME>mySection1</SECTIONS_NAME>
      </SECTIONS>
     </DATA>
    </ROWSET>
    XQUERY
    select
     department_id,
      department_name,
      sections_id,
      sections_name
    from
      OFFLINE_XML xml_list,
      xmltable(
        '
          for $department in $param/ROWSET/DATA
            return $department
        '
        passing xml_list.xml_file as "param"
        columns
          "DEPARTMENT_ID"   varchar2(100) path '//DEPARTMENT/DEPARTMENT_ID',
          "DEPARTMENT_NAME" varchar2(4000) path '//DEPARTMENT/DEPARTMENT_NAME',
          "SECTIONS_ID"     varchar2(100) path '//SECTIONS/SECTIONS_ID',
          "SECTIONS_NAME"   varchar2(4000) path '//SECTIONS/SECTIONS_NAME'
      ) section_list
    where
      xml_list.Status = 5
    The performance of the query, you receive an error
    ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton 
    sequence - got multi-item sequence
    It is natural because I have several sections, now how I'll handle this situation.

    It's the usual approach to manage several nested collections:

    SQL> select d.department_id
      2       , d.department_name
      3       , s.sections_id
      4       , s.sections_name
      5  from offline_xml t
      6     , xmltable(
      7         '/ROWSET/DATA'
      8         passing t.xml_file
      9         columns
     10           DEPARTMENT_ID   varchar2(20) path 'DEPARTMENT/DEPARTMENT_ID'
     11         , DEPARTMENT_NAME varchar2(30) path 'DEPARTMENT/DEPARTMENT_NAME'
     12         , SECTIONS        xmltype      path 'SECTIONS'
     13       ) d
     14     , xmltable(
     15         '/SECTIONS'
     16         passing d.sections
     17         columns
     18           SECTIONS_ID     varchar2(20) path 'SECTIONS_ID'
     19         , SECTIONS_NAME   varchar2(30) path 'SECTIONS_NAME'
     20      ) s
     21  ;
    
    DEPARTMENT_ID        DEPARTMENT_NAME                SECTIONS_ID          SECTIONS_NAME
    -------------------- ------------------------------ -------------------- ------------------------------
    DEP1                 myDEPARTMENT1                  6390135666643567     mySection1
    DEP1                 myDEPARTMENT1                  6390135666643567     mySection2
    DEP2                 myDEPARTMENT2                  63902                mySection1
     
    
  • Call the PL/SQL procedure with different parameters?

    I use PL/SQL for web development. I have a page of PL/SQL which collects information and returns the user off site with one return url (another PL/SQL procedure).

    I have the return procedure with every documented return variable (default null) in order to always take the return. However, there are (reported... cannot reproduce because of the nature of the business) cases where a 404 error is returned because of the incompatibility of parameter.

    Is it possible to proceed regardless of the parameters? Someone at - it suggestions?

    Thank you!

    user2960509 wrote:

    My problem is that they sometimes send back of settings that do not match what I expect.

    Use the interface "+ flexible +" mod_plsql - see the Oracle® HTTP Server mod_plsql user's Guide for the documented details.

    The signature of the procedure parameter is as follows (it is called by mod_plsql using tables of name value pairs):

    create or replace procedure Scott.MyWebProc( name_array owa.vc_arr, value_array owa.vc_arr) is
    ...
    

    In your code, you just browse the berries to get the name values passed query string. You can even filled an associative array in your code (a table indexed by string and no number, where the index string represents the name of param)-this approach can make it pretty easy for the code make reference to a parameter, with little effort on your part to provide an interface to query by name for code to get the value of a parameter name.

    To enable the flexible (aka parameter 2) call interface, precede the call to web with an exclamation character. For example

    http://my-webserbver.my-domain.com/pls/dad/!scott.mywebproc?name-1=val-1&name-2=val-2..,name-n=val=n
    
  • Thread safe operations on the table in the pl/sql procedure?

    I develop java application that will run in N locations simultaneously, each application will be of the sons of Mr. each thread takes a unique ID with the NOT_TAKEN State of the queue table and changes its status to TAKEN.
    Problem:
    How to prevent situation like this thread:
    1 get a first select ID with NOT_TAKEN status
    2. at the same time thread B select first (so it will be the same ID chosen thread A) ID have the status of NOT_TAKEN.
    3 put on a status of changes of identity and
    4 thread B status of the TAKEN ID changes
    After this thread A and B using the same ID.

    What I did:
    I've written pl/sql procedure that queue table in exclusive mode lock, selects the first ID, changes its status to CATCH and unlocks the table. Because it is lock in exclusive mode for a single thread can run this procedure at the same time.

    Question:
    Optimal how must it be resolved, because mine solution prevents to perform all the other updates on the queue table, while it is locked, as the change in status of OPERATION_DONE TAKEN so there performance problem.

    As Centinul said, you need to lock just one line.
    I would just add NOWAIT to the select statement to let the Java thread go and try again, rather than wait for other threads.
    Example: (not tested)

    
    --
    -- Assuming structure of your QueueTable: ( IDCol is PK , StatusCol is VARCHAR2, ... )
    --
    --
    -- or make it part of the package....
    CREATE OF REPLACE
    FUNCTION updateQueue( nQID QueueTable.IDCol%TYPE) RETURN VARCHAR2 AS
       eLocked EXCEPTION;
       PRAGMA EXCEPTION_INIT(eLocked,-54);
       CURSOR curQueueTable IS SELECT 1 CNTR FROM QueueTable WHERE IDCol=nQID AND StatusCol='NOT_TAKEN' FOR UPDATE OF StatusCol NOWAIT;
       recQueueTable curQueueTable%ROWTYPE;
       cRtn VARCHAR2(1); 
    
    BEGIN 
    
       cRtn := 'Y';
       BEGIN 
    
          OPEN curQueueTable;
          FETCH curBuffSummary INTO recQueueTable;
          CLOSE curQueueTable; 
    
          IF recQueueTable.CNTR IS NOT NULL AND recQueueTable.CNTR = 1 THEN
              UPDATE QueueTable SET StatusCol = 'TAKEN' WHERE IDCol=nQID;
          ELSE
              -- Already updated
              cRtn := 'N';
          END IF; 
    
             -- You can control your transaction here as well
             -- COMMIT;
             -- But if realy should be done in the Java thread. 
    
        EXCEPTION
           WHEN eLocked OR STANDARD.TIMEOUT_ON_RESOURCE THEN
           -- Thread could not get exclusice row lock. Ignore error.
             cRtn := 'N';
             NULL; 
    
          WHEN OTHERS THEN
             -- Handle other errors...
             -- NULL; just kidding...
             RAISE;
       END;
       RETURN cRtn; 
    
    END; 
    

    Published by: thomaso September 18, 2009 10:30

  • Insertion of 2 items in the PL/SQL procedure

    Hello

    I am writing a database to a control system which is as follows:

    Drop table Orders cascade constraints;
    Drop type item_type;
    Type of projection Item_nested;

    Create or replace Type item_type () AS Object
    Cat_code Varchar2 (6).
    Amount_ord Number (3).
    Cost Number (5.2));
    /

    Create or replace Type item_nested as the item_type table;
    /

    Create Table orders)
    Key primary forced pkorder of Order_no Varchar2 (8).
    Client_name Varchar2 (30),
    AddressLine1 Varchar2 (20).
    AddressLine2 Varchar2 (20).
    City Varchar2 (20).
    Code postal Varchar2 (10),
    Country Varchar2 (20).
    Order_items item_nested,
    Order_date Date)
    The nested Table Order_items
    Store nested_items return in the form of index;

    I wrote a PL/SQL procedure to enter all the necessary information including 1 item ordered (which is Order_items as a nested table). It's as follows:

    CREATE OR REPLACE PROCEDURE add_1order (ordno IN VARCHAR2, Cust_name IN VARCHAR2, add1 IN VARCHAR2,
    Add2 IN VARCHAR2, Addtown IN VARCHAR2, Pstcde IN VARCHAR2, addcountry IN VARCHAR2,
    cat_cde IN VARCHAR2, Amnt_ord in NUMBERS, itemcost in NUMBER, ord_date IN DATE)
    AS
    BEGIN

    DBMS_OUTPUT. Put_line ('Insert attempted");

    INSERT INTO Orders (Order_no, client_name, AddressLine1, AddressLine2, city, postal code, country, order_items, Order_Date)
    VALUES (ordno, Cust_name, add1, add2, Addtown, Pstcde, addcountry, item_nested (item_type (cat_cde, Amnt_ord, itemcost))
    ord_date);

    DBMS_OUTPUT. Put_line ('Insert successful");

    EXCEPTION
    WHILE OTHER THEN DBMS_OUTPUT. PUT_LINE ('ERROR');
    DBMS_OUTPUT. Put_line ('procedure failed");
    END;
    /

    I need to write another procedure that will allow me to insert elements of order 2, but I can't handle

    Can anyone help please?

    See you soon

    SG200407 wrote:

    Just another question - is possible in this PL/SQL statement for only 2 articles are updated and not more?

    Ensure that:

    CREATE OR REPLACE
      PROCEDURE add_order(
                          ordno      IN VARCHAR2,
                          Cust_name  IN VARCHAR2,
                          add1       IN VARCHAR2,
                          add2       IN VARCHAR2,
                          Addtown    IN VARCHAR2,
                          Pstcde     IN VARCHAR2,
                          addcountry IN VARCHAR2,
                          item_list  IN item_nested,
                          ord_date   IN DATE
                         )
        AS
        BEGIN
            IF item_list.count > 2
              THEN
                DBMS_OUTPUT.PUT_LINE ('Too many (' || item_list.count ||
                                        ') order items. Maximum number of items per order is 2.'
                                     );
                RAISE_APPLICATION_ERROR(
                                        -20900,
                                        'Too many (' || item_list.count ||
                                        ') order items. Maximum number of items per order is 2.'
                                       );
            END IF;
    
            DBMS_OUTPUT.PUT_LINE ('Insert attempted');
    
            INSERT
              INTO Orders
              VALUES(
                     ordno,
                     Cust_name,
                     add1,
                     add2,
                     Addtown,
                     Pstcde,
                     addcountry,
                     item_list,
                     ord_date
                    );
    
            DBMS_OUTPUT.PUT_LINE ('Insert successful');
    
          EXCEPTION
            WHEN OTHERS
              THEN
                DBMS_OUTPUT.PUT_LINE ('ERROR');
                DBMS_OUTPUT.PUT_LINE ('Procedure failed');
    END;
    /
    BEGIN
        add_order(
                  1,
                  'Customer1',
                  '100 Main Street',
                  NULL,
                  'New York',
                  '12345',
                  'USA',
                  item_nested(
                              item_type('book',1,45),
                              item_type('dvd',1,15)
                             ),
                  sysdate
                 );
    END;
    /
    BEGIN
        add_order(
                  1,
                  'Customer1',
                  '100 Main Street',
                  NULL,
                  'New York',
                  '12345',
                  'USA',
                  item_nested(
                              item_type('book',1,45),
                              item_type('dvd',1,15),
                              item_type('cd',1,10)
                             ),
                  sysdate
                 );
    END;
    /
    select * from Orders
    /
    
    SQL> CREATE OR REPLACE
      2    PROCEDURE add_order(
      3                        ordno      IN VARCHAR2,
      4                        Cust_name  IN VARCHAR2,
      5                        add1       IN VARCHAR2,
      6                        add2       IN VARCHAR2,
      7                        Addtown    IN VARCHAR2,
      8                        Pstcde     IN VARCHAR2,
      9                        addcountry IN VARCHAR2,
     10                        item_list  IN item_nested,
     11                        ord_date   IN DATE
     12                       )
     13      AS
     14      BEGIN
     15          IF item_list.count > 2
     16            THEN
     17              DBMS_OUTPUT.PUT_LINE ('Too many (' || item_list.count ||
     18                                      ') order items. Maximum number of items per order is 2.'
     19                                   );
     20              RAISE_APPLICATION_ERROR(
     21                                      -20900,
     22                                      'Too many (' || item_list.count ||
     23                                      ') order items. Maximum number of items per order is 2.'
     24                                     );
     25          END IF;
     26
     27          DBMS_OUTPUT.PUT_LINE ('Insert attempted');
     28
     29          INSERT
     30            INTO Orders
     31            VALUES(
     32                   ordno,
     33                   Cust_name,
     34                   add1,
     35                   add2,
     36                   Addtown,
     37                   Pstcde,
     38                   addcountry,
     39                   item_list,
     40                   ord_date
     41                  );
     42
     43          DBMS_OUTPUT.PUT_LINE ('Insert successful');
     44
     45        EXCEPTION
     46          WHEN OTHERS
     47            THEN
     48              DBMS_OUTPUT.PUT_LINE ('ERROR');
     49              DBMS_OUTPUT.PUT_LINE ('Procedure failed');
     50  END;
     51  /
    
    Procedure created.
    
    SQL> BEGIN
      2      add_order(
      3                1,
      4                'Customer1',
      5                '100 Main Street',
      6                NULL,
      7                'New York',
      8                '12345',
      9                'USA',
     10                item_nested(
     11                            item_type('book',1,45),
     12                            item_type('dvd',1,15)
     13                           ),
     14                sysdate
     15               );
     16  END;
     17  /
    Insert attempted
    Insert successful
    
    PL/SQL procedure successfully completed.
    
    SQL> BEGIN
      2      add_order(
      3                1,
      4                'Customer1',
      5                '100 Main Street',
      6                NULL,
      7                'New York',
      8                '12345',
      9                'USA',
     10                item_nested(
     11                            item_type('book',1,45),
     12                            item_type('dvd',1,15),
     13                            item_type('cd',1,10)
     14                           ),
     15                sysdate
     16               );
     17  END;
     18  /
    Too many (3) order items. Maximum number of items per order is 2.
    ERROR
    Procedure failed
    
    PL/SQL procedure successfully completed.
    
    SQL> select * from Orders
      2  /
    
    ORDER_NO CUSTOMER_NAME                  ADDRESSLINE1
    -------- ------------------------------ --------------------
    ADDRESSLINE2         TOWN                 POSTCODE   COUNTRY
    -------------------- -------------------- ---------- --------------------
    ORDER_ITEMS(CAT_CODE, AMOUNT_ORD, COST)
    --------------------------------------------------------------------------------
    ORDER_DAT
    ---------
    1        Customer1                      100 Main Street
                         New York             12345      USA
    ITEM_NESTED(ITEM_TYPE('book', 1, 45), ITEM_TYPE('dvd', 1, 15))
    24-JAN-09
    
    SQL> 
    

    SY.

  • Need to check delays in update of 1000 lines using the PL/SQL procedure.

    Hi all

    I'm new to PL/SQL. I need your help to build a procedure that executes the following statement and follows the time of update of 1000 rows. This is to check the performance of the database. I need to print the timestamp of start before the update and end timestamp after update. I need to do for the 1000 lines. The statement that will be used in the procedure is:

    SELECT

    'UPDATE XXAFL_MON_FACTS_F SET TASK_WID =' | NVL (TO_CHAR (TASK_WID), 'NULL') |', EXECUTION_PLAN_WID =' | NVL (TO_CHAR (EXECUTION_PLAN_WID), 'NULL').

    ', DETAILS_WID =' | NVL (TO_CHAR (DETAILS_WID), 'NULL') |', SOURCE_WID =' | NVL (TO_CHAR (SOURCE_WID), 'NULL') |', TARGET_WID = ' | NVL (TO_CHAR (TARGET_WID), 'NULL').

    ', RUN_STATUS_WID =' | NVL (TO_CHAR (RUN_STATUS_WID), 'NULL') |', SEQ_NUM =' | NVL (TO_CHAR (SEQ_NUM), 'NULL') |', NAME = "' | NVL (TO_CHAR (NAME), 'NULL').

    "', NO_POSITION =" ' | NVL (TO_CHAR (INSTANCE_NUM), e ') | " ', INSTANCE_NAME = "' | NVL (TO_CHAR (INSTANCE_NAME), 'NULL').

    "', TYPE_CD =" ' | NVL (TO_CHAR (TYPE_CD), e ') | " ', STATUS_CD = "' | NVL (TO_CHAR (STATUS_CD), e ') | " ', START_TS =' | NVL (TO_CHAR (START_TS), 'NULL').

    ', END_TS =' | NVL (TO_CHAR (END_TS), 'NULL') |', DURATION = ' | NVL (TO_CHAR (DURATION), 'NULL') |', STATUS_DESC = "' | NVL (TO_CHAR (STATUS_DESC), 'NULL').

    "', DBCONN_NAME =" ' | NVL (TO_CHAR (DBCONN_NAME), e ') | " ', SUCESS_ROWS =' | NVL (TO_CHAR (SUCESS_ROWS), 'NULL').

    ', FAILED_ROWS =' | NVL (TO_CHAR (FAILED_ROWS), 'NULL') |', ERROR_CODE = ' | NVL (TO_CHAR (ERROR_CODE), 'NULL') |', NUM_RETRIES =' | NVL (TO_CHAR (NUM_RETRIES), 'NULL').

    ', READ_THRUPUT =' | NVL (TO_CHAR (READ_THRUPUT), 'NULL') |', LAST_UPD = ' | NVL (TO_CHAR (LAST_UPD), 'NULL') |', RUN_STEP_WID = "' | NVL (TO_CHAR (RUN_STEP_WID), 'NULL').

    "', W_INSERT_DT = ' | NVL (TO_CHAR (W_INSERT_DT), 'NULL') |', W_UPDATE_DT = ' | NVL (TO_CHAR (W_UPDATE_DT), 'NULL').

    ', START_DATE_WID =' | NVL (TO_CHAR (START_DATE_WID), 'NULL') |', END_DATE_WID = ' | NVL (TO_CHAR (END_DATE_WID), 'NULL') |', START_TIME =' |

    NVL (TO_CHAR (START_TIME), 'NULL') |', END_TIME =' | NVL (TO_CHAR (END_TIME), 'NULL'). "WHERE INTEGRATION_ID ="' | INTEGRATION_ID | " « ; »  OF XXAFL_MON_FACTS_F;

    The above query creates instructions of update that must be executed 1000 times and the time required to update the 1000 lines should be followed.

    Thanks in advance!

    Code horribly wrong!

    Why this approach?

    Dynamic SQL is almost NEVER needed in PL/SQL. And if you think it's necessary and taking into account what is displayed as being problems here, you have a 99% chance of being wrong.

    This 1% where dynamic SQL is necessary, he will WITH bind variables to create shareable SQL, decrease memory requests, decrease the likelihood of a fragmented shared reel and decrease the burning CPU cycles on hard analysis.

    An example below. Your approach is the 1st. One that is slower than the correct approach to 37 (x_!) ...

    SQL> create table t ( n number );
    
    Table created.
    
    SQL>
    SQL> var ITERATIONS number;
    SQL> exec :ITERATIONS := 100000;
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL>
    SQL> TIMING START "INSERTs using Hard Parsing"
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  execute immediate 'insert into t values ('||i||')';
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using Hard Parsing
    Elapsed: 00:02:00.33
    SQL>
    SQL> TIMING START "INSERTs using Soft Parsing"
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  execute immediate 'insert into t values ( :1 )' using i;
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using Soft Parsing
    Elapsed: 00:00:06.06
    SQL> drop table t;
    
    Table dropped.
    
    SQL> create table t( n number );
    
    Table created.
    
    SQL>
    SQL>
    SQL> TIMING START "INSERTs using a single parse and repeatable statement handle "
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  insert into t values ( i );
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using a single parse and repeatable statement handle
    Elapsed: 00:00:04.81
    SQL>
    
  • The problem with ampersand in the PL/SQL procedure

    Dear Oracle experts,

    Please, help me to understand this case. I have the following code
    V_RESPONSE := UTL_HTTP.GET_RESPONSE (V_REQUEST);
    
          LOOP
             UTL_HTTP.READ_LINE (V_RESPONSE, V_BUFFER, FALSE);
             DATA_OUT := DATA_OUT || V_BUFFER;
          --DBMS_OUTPUT.PUT_LINE (V_BUFFER);
          END LOOP;
    And I'm getting DATA_OUT as
    <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:chargeSubscriberResponse xmlns:ns="http://ws.cube.az"><ns:return>&lt;?xml version="1.0" encoding="UTF-8"?>
    &lt;response>
         &lt;retval>-2200003&lt;/retval>
         &lt;retmsg>Invalid Service&lt;/retmsg>
         &lt;quantity>&lt;/quantity>
         &lt;cube-transaction-id>&lt;/cube-transaction-id>
    &lt;/response></ns:return></ns:chargeSubscriberResponse></soapenv:Body></soapenv:Envelope>
    A don't have to '&' in this output. I need to analyze this variable to clear all ampersands. How can I do?

    Just replace does not work... I tried
    PROCEDURE Clean_up_xml (v_xml IN OUT VARCHAR2)
       IS
       BEGIN
          WHILE INSTR (v_xml, 'lt;') > 0
          LOOP
             v_xml :=
                SUBSTR (v_xml, 1, INSTR (v_xml, 'lt;') - 2)
                || SUBSTR (v_xml, INSTR (v_xml, 'lt;') + 4);
          END LOOP;
       END;
    But no luck...

    Does not erase the procedure '& '. How can I disable ampersand in PL/SQL procedure?

    Thanks in advance.

    PS: I know SET DEFINE OFF. But it only works in SQL * MORE.
    SQL> declare
      2
      3    data_out clob :=
      4  '<?xml version="1.0" encoding="UTF-8"?>
      5  <response>
      6       <retval>-2200003</retval>
      7       <retmsg>Invalid Service</retmsg>
      8       <quantity></quantity>
      9       <cube-transaction-id></cube-transaction-id>
     10  > </response>' ;
     11
     12  begin
     13
     14    for rec in (
     15        select r.*
     16        from xmltable(
     17               xmlnamespaces(
     18                 'http://www.w3.org/2003/05/soap-envelope' as "soap"
     19               , 'http://ws.cube.az' as "ns"
     20               )
     21             , '/soap:Envelope/soap:Body/ns:chargeSubscriberResponse'
     22               passing xmlparse(document data_out)
     23               columns xml_return clob path 'ns:return'
     24             ) x
     25           , xmltable('/response'
     26               passing xmlparse(document x.xml_return)
     27               columns retval              number       path 'retval'
     28                     , retmsg              varchar2(30) path 'retmsg'
     29                     , quantity            number       path 'quantity'
     30                     , cube_transaction_id varchar2(30) path 'cube-transaction-id'
     31             ) r
     32    )
     33    loop
     34
     35      dbms_output.put_line('retval = '||rec.retval);
     36      dbms_output.put_line('retmsg = '||rec.retmsg);
     37      dbms_output.put_line('quantity = '||rec.quantity);
     38      dbms_output.put_line('cube_transaction_id = '||rec.cube_transaction_id);
     39
     40    end loop ;
     41
     42  end;
     43  /
    
    retval = -2200003
    retmsg = Invalid Service
    quantity =
    cube_transaction_id = 
    
    PL/SQL procedure successfully completed
     
    
  • Declarations of error in the PL/SQL Code

    Hi all:

    I have a routine of PL/SQL that I need to add "Error Statements" in case something thing errors when it is run, the user will know and be able to solve the problem. Here's a copy of what I need to run. Is a unique it will only be run once and when it is finished without error, it will not be used again, but when it ran inside TOAD / TORA / SQLPlus, how to display an error to the user in case something goes wrong? I know it's probably a very simple thing to do, but I come from SQL Server and only learn PL/SQL - Oracle and I do not know how to do this. Any help would be greatly appreciated.

    DECLARE
    -----------------------------------------------------------------------------------------------
    -Local Variables
    -----------------------------------------------------------------------------------------------
    l_gm_master_label VARCHAR2 (20);
    l_active_flag VARCHAR2 (1);
    l_currdate DATE;
    l_comp_id VARCHAR2 (10);
    l_site_id VARCHAR2 (12);
    l_gm_master_id NUMBER;
    BEGIN
    -----------------------------------------------------------------------------------------------
    -Set default values
    -----------------------------------------------------------------------------------------------
    l_gm_master_label: = 'DMLogic001 ';
    l_active_flag: = 'n';
    l_currdate: = SYSDATE;
    l_comp_id: = 'XE ';
    l_site_id: = "OHIO."
    l_gm_master_id: = 0;
    -----------------------------------------------------------------------------------------------
    -Get the next value
    -----------------------------------------------------------------------------------------------
    SELECT
    trn_gm_master_seq. NEXTVAL
    IN
    l_gm_master_id
    Of
    Double;
    -----------------------------------------------------------------------------------------------
    -Insert generic Gray number master record who will join all the serial numbers DMLogic
    -----------------------------------------------------------------------------------------------
    INSERT INTO ebiznet.trn_gm_master
    (gm_master_id,
    gm_master_label,
    active_flag,
    CURRDATE,
    identifiant_composant,
    Site_ID)
    VALUES
    (l_gm_master_id,
    l_gm_master_label,
    l_active_flag,
    l_currdate,
    l_comp_id,
    l_site_id);
    -----------------------------------------------------------------------------------------------
    -Insert the records
    -----------------------------------------------------------------------------------------------
    INSERT INTO ebiznet.trn_gm_serial_number
    (gm_serial_number_id,
    gm_master_id,
    gm_serial_number,
    received_by,
    received_date,
    picked_by,
    picked_date,
    ebiz_sku_no,
    identifiant_composant,
    Site_ID,
    ebiz_ord_no,
    interface_date)
    SELECT
    trn_gm_serial_number_seq. NEXTVAL,
    l_gm_master_id,
    S.Serial_number,
    1,
    S.CREATION_DATE,
    1,
    S.CREATION_DATE,
    S.ebiz_sku_no,
    l_comp_id,
    l_site_id,
    O.ebiz_ord_no,
    S.interface_date
    Of
    dmlogic.trn_rm_serial_number S
    INNER JOIN ebiznet.trn_ordhead O ON S.ord_no is O.ord_no;.
    ----------------------------------------------------------------------------------------------
    -Commit the changes
    ----------------------------------------------------------------------------------------------
    COMMIT;
    -----------------------------------------------------------------------------------------------
    -Rollback If an error occurred
    -----------------------------------------------------------------------------------------------
    EXCEPTION
    WHILE OTHERS THEN
    ROLLBACK;
    END;

    Remove WHEN OTHERS will allow exceptions to access the user and halt execution. You get a descriptive message and the line in PL/SQL, where it has occurred.

    In very rare occasions when OTHERS WHEN is inevitable, RAISE re-lift the exception and stop running.

    You can increase your own exceptions to conditions specific to your application with RAISE_APPLICATION_ERROR(). (Syntax and parameters can be found in the documentation)

  • How to call sql loader control file with in the pl/sql procedure

    Hi friends,

    I am doing a project in relation to the transfer data using queues. In the queue, I'll get a data delimited by tabs in the form of CLOB variable/message. I don't want to keep this dat in the oracle table.
    During the updating of the data in the table.

    1. don't want to write data to a file. (You want to access directly after the specific queue).

    2. as the data is in the form of delimited by tabs, I want to use sql loader concept.

    How can I call the ctrl charger sql file with in my pl/sql procedure. When I searched, most forums recommending the external procedure or a Java program.

    Please guide me on this issue. My preferrence is pl sql, but don't know the external procedure. If no other way, I'll try Java.

    I'm using oracle 9.2.0.8.0.

    Thanks in advance,
    Vimal...

    Or SQL * Loader, or external tables are designed to read data from a CLOB stored in the database. They both work on files stored on the file system. If you don't want the data to be written to a file, you have to roll your own parsing code. It is certainly possible. But it will be much less effective than SQL * Loader or external tables. And it is likely to lead to a little more code.

    The simplest possible thing that might work would be to use something like Tom Kyte string tokenization package to read a line in the CLOB, divide the component parts and save the different chips in a significant collection (i.e. an object type or a record type that matches the table definition). Of course, you need manage things like the conversion of strings to numbers or dates, rejecting the lines, writing to log files, etc.

    Justin

  • Run the PL/SQL procedure periodically

    Hello everyone.

    Im working with Oracle 10 G R1.

    I need execute a PL/SQL procedure every 5 minutes.

    Can anyone send me an example or a link where I can study how to proceed?

    Thanks in advance and greetings to all.

    Hello

    From the point of view Os you use crontab - to run a script
    Refer to:
    http://dbamac.WordPress.com/2008/08/01/running-sqlplus-and-PLSQL-commands-from-a-shell-script/
    sqlplus and Unix crontab - example

    With the help of planners you can do
    Please visit: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm
    http://www.Oracle-base.com/articles/10G/Scheduler10g.php

    -Pavan Kumar N

  • Error in the pl/sql process

    Hi guru

    I get the error message like: -.

    "1 error has occurred."
    ORA-06550: line 6, column 32: PLS-00103: encountered the symbol "&" when expecting one of the following values :), * & - + / in rem rest mod and/or as | multiset.


    BEGIN

    IF (: P3_ID! = null & &: P3_ID! = ") THEN
    INSERT
    ON THE OTHER
    INSERT
    END IF;

    END;


    I get the error under the present: - < b > (: P3_ID! = null & &: P3_ID! = ") < /b >, I am writing to you as: - < b > (: P3_ID! = null) < /b > the pl/sql process works very well, so how can specify two different conditions with & & operators in the middle.


    Thanks for your help


    Kind regards
    Kumar

    In my opinion, as AND would be the correct logical operator.
    Why not just use a declarative validation? Also, I don't think you can compare to NULL - you can say whether a value IS NULL or IS NOT NULL.

    Georger

    gkkumar wrote:
    Hi guru

    I get the error message like: -.

    "1 error has occurred."
    ORA-06550: line 6, column 32: PLS-00103: encountered the symbol "&" when expecting one of the following values :), * & - + / in rem rest mod and/or as | multiset.

    BEGIN

    IF (: P3_ID! = null &: P3_ID! = ") THEN
    INSERT
    ON THE OTHER
    INSERT
    END IF;

    END;

    I get the error under the present:- (: P3_ID! = null &: P3_ID! = "), if I write like:- (: P3_ID! = null) pl/sql process works very well, so how can specify two different conditions with & operators in the middle.

    Thanks for your help

    Kind regards
    Kumar

  • Accept user entries in the pl/sql procedure

    Someone would want to explain to me how can I accept user entries in the following stored procedure
    CREATE OR REPLACE PROCEDURE calsal
    IS
       CURSOR maxsal
       IS
          SELECT *
            FROM emp;
    
       max_sal   emp.sal%TYPE;
    BEGIN
       SELECT MAX (sal)
         INTO max_sal
         FROM emp;
    
       FOR i IN maxsal
       LOOP
          IF i.sal = max_sal
          THEN
             DBMS_OUTPUT.put_line (   ' Maximum salary plus bonus of '
                                   || i.empno
                                   || ' is '
                                   || (i.sal + i.sal * 0.5)
                                  );
          END IF;
       END LOOP;
    END;
    The above program works very well, but if I want to keep a condition WHERE No. 12 online which is WHERE deptno: = & deptno... My logic does not work with just like that. So, can anyone tell me what can I do to accept a number of the user Department.

    Thanks in advance!

    And what happens if there are several employees who earn max or min. I'll assume that all get award-winning correspondent. I will also assume that if all employees of the Department get the same salary (so they are min and max), they will get. 5% bonus:

    CREATE OR REPLACE
      PROCEDURE calsal(p_deptno number)
        IS
            CURSOR maxsal
              IS
                SELECT  empno,
                        CASE
                          WHEN cnt = 1 THEN SAL * 1.005
                          WHEN rank_max = 1 THEN SAL * 1.005
                          WHEN rank_min = 1 THEN SAL * 1.1
                        END sal_and_bonus
                  FROM  (
                         SELECT  empno,
                                 COUNT(DISTINCT SAL) OVER() cnt,
                                 RANK() OVER(ORDER BY SAL DESC) rank_max,
                                 RANK() OVER(ORDER BY SAL) rank_min,
                                 sal
                           FROM  emp
                           WHERE deptno = p_deptno
                        )
                 WHERE rank_max = 1
                    OR rank_min = 1;
        BEGIN
            FOR v_rec IN maxsal LOOP
              DBMS_OUTPUT.put_line (   ' Salary plus bonus of '
                                   || v_rec.empno
                                   || ' is '
                                   || v_rec.sal_and_bonus
                                  );
            END LOOP;
    END;
    /
    

    SY.

    Published by: Solomon Yakobson August 1, 2011 13:50

Maybe you are looking for

  • Driver serial port PCI to 6450 laptop computer b

    I'm looking for the driver for a PCI serial port for our 645 HP b. Operating system is company Win7 64 bit I had a glance at the site of pilots http://goo.gl/4fxIFa but can not find the right pair. Any help please? Nick

  • How do we refill my mouse

    How we recharge my mouse?

  • How to build a correct relative path?

    I watched this on the Microsoft Web site, but their views did not work. I have an application called Notepad ++ in my programs folder. The documentation says that so that the spell check function works, I have to include in the configuration of Notep

  • I am running virtual xp on a Windows 7 system, but I can't get cursor flashing at the command prompt... help?

    I am running virtual XP on a Windows 7 system, but I can't get cursor flashing at the command prompt... help?    I studied the orders autoexe.bat, command.exe and cmd.exe, son and so on.  However, nothing seems to work.

  • HTTP Patch request

    Hello I was wondering if anyone has experience with queries HTTP PATCH? In the QNetworkAccessManager, I can see POST, GET, PUT, but not patch. Apparently, it is absent of QT4. Does anyone know a work around? I need, because the API of Google Drive de