Select in cursors

Hi,
I need to do a select within cursor, in other words, my cursor have a select from table and I want to do other select within this data. By example, my cursor have all calls but I want the calls successfully and/or the calls failure , how can to do it?
thanks by any idea.

i think i have to go for two cursors Intially i have written like the below codeThis requirement merely made me think of a pure SQL solution - something interesting...
As I mentioned, you likely should be using ref cursors as typically this requirement extends to a client that wants to make a call to Oracle without needing to know SQL or table names, pass parameters, and get a dynamic "+result set+" in response.
In Oracle. this is done using ref cursors. The code will look something like this"
{code}
create or replace procedure FooProc( someVar1 varchar2, someVar2 number, curResult OUT sys_refcursor ) is
begin
case
when someVar1 = someValueA then
open curResult for select * from emp;
when someVar1 = someValueB then
open curResult for select * from emp where empid = someVar2;
.. etc ..
end case;
end;
{code}
This is pretty straight forward stuff - and well explained with examples in the Oracle® Database PL/SQL User's Guide and Reference (http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref139)
You procedure it a tad different in output parameters (and not what one typically would get in a production system), but the concept is the same. If the SQL projection is the same for each cursor, you can use a ref cursor as above - and then simply code a single fetch to get the row's columns, close the cursor, and then return that column values as output parameters.
Edited by: Billy Verreynne to fix the broken Jive s/w that does not understand how to parse a link and show it correctly.. (am getting more and more peeved at the crappiness factor of the new forum s/w)

Similar Messages

  • Select and Cursor doubt

    Dear All,
    I got a doubt b/n select and cursor.
    I read in one oracle book that select into clause will actually tries to get the data twice, Whereas the cursor will query only ones.
    Is this the case in Oracle 10g or both the select and cursor will fetch the data only ones.
    Ex
    select sal into v_sal from emp where empno = 7788 --> Ones it hit the data, oracle will again scan the entire set of records in the emp table for another match.
    Whereas
    Cursor c_sal is select sal from emp where empno = 7788; --> This will do the fetch operation only ones.
    Is this the case still True in Oracle 10g or 11i.
    Appreciate your help.
    Thankyou very much
    Madhu K

    the query is processed as follows (this is from ora doc)
    Parse:
    – Search for identical statement
    – Check syntax, object names, and privileges
    – Lock objects used during parse
    – Create and store execution plan
    Execute: Identify rows selected
    Fetch: Return rows to user process
    for cursor also same things are performed, but cursor is private sql area in which you can processes one row at a time, you can use cursor in your pl/sql program and access one row a time,
    so if you say,
    cursor c1 is select * from emp;
    c1 is private sql area where you can processes single row of emp , make comparisons, calculations etc,
    once you close the cursor this area is released and can be used by another cursor,
    the basic query processing rules remains the same,

  • Select and cursor statement

    Hi all,
    Given the following code :
         TYPE option_rec IS RECORD
            value varchar2(3),
            label varchar2(255)
    TYPE option_list_t IS TABLE OF option_rec;
    FUNCTION get_object_list
        RETURN option_list_t
        PIPELINED
        DETERMINISTIC
      IS
            tmp option_rec;
      BEGIN
            tmp.value:='1';
            tmp.label:='foo';
            PIPE ROW(tmp);
            tmp.value:='2';
            tmp.label:='bar';
            PIPE ROW(tmp);
           RETURN;
      END get_object_list;
      FUNCTION generate_select(selected_value in varchar2)
        RETURN sys_refcursor
      IS
         ret sys_refcursor;
      BEGIN
        open ret for
             select value as value,
                    '(' || value || ') ' || label as label,
                    case value
                       when selected_value then
                          'selected'
                       else
                    end as selected
               from table(get_object_list);
        return ret;
      END generate_select;
    I can't succeed in runnig this query :
    select *
    from cursor(generate_select('2'))I have the following error :
    ORA-00933: "SQL command not properly ended"What is wrong ?
    I run on Oracle 10gR2

    Having a pipelined function defined search documentation for TABLE operator
    You must select from (TABLE(get_object_list()) where ...
    Regards
    Etbin
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2351
    Edited by: Etbin on Apr 27, 2009 7:09 PM

  • What is a good way to check if sql select basd cursor return anything

    Hello everyone,
    I am trying to find a good way to identify that a SQL select based cursor return nothing.
    I know that or we use exception when no data found, or count(*) to check how many rows are returned.
    I have a cursor based on quite a long select statement.
    Like
    CREATE OR REPLACE PROCEDURE aaa (v_input IN NUMBER, v_output OUT VARCHAR2)
         CURSOR long_cursor IS
              --long select statement(with input variable) ;
    BEGIN
         Select count(*)
         Into v_count
      From
      -- a long select statment with input again ;
      IF v_count > 0 then
        For record in long_cursor loop
         --Get information from cursor
            --other processing for output
        End loop;
      END IF;
    END;Is there any other way than the above ?
    I would love to reduce the amount of typing. I know that repetition in code is not good.
    Thanks in advance,
    Ann
    Edited by: Ann586341 on Feb 28, 2013 2:29 PM

    >
    Not sure I understand your point. I am still a new bie here.
    >
    A flag is just a piece of data. By itself it doesn't prevent anyone from changing the data. And in a multiuser system anything you try to check is based on the COMMITTED data in the system. Two users can be changing two different rows at the same time but neither user will see the other change.
    So if you try to count how many rows meet a particular condition you may get a count of 8 but after the other user commits the count might be 7 or 9. So if you use 8 it may not be valid for very long.
    >
    But the app we use is Oracle Application Express 4.0.
    I assume when the data is read, there will be some kind of lock on these rows so other users cannot change it, right ?
    Or should I use SELECT for update even I do not update anything here.
    >
    I can't help you with that one. That would be a question for the application express forum.
    Oracle Application Express (APEX)
    You don't need to use FOR UPDATE if you don't plan to change the data. But, as explained above, you can't rely on any data you query being the same because another user could be changing it while you are looking at it.

  • Selecting one cursor at a time and then reading its value

    I am a novice LabView user. I am trying to develop a program in which I have to select portions of a waveform and delete the outliers.  The problems I run into is selecting cursors at a time and then reading its value. I was using Active Cursor. Ideally what I need is to read read values of the first two cursors, cursor0 and cursor1 and remove outliers in the region and then move to region between cursor1 and cursor2 and so on. Is there a way to control which cursors are active, read its value and then move to the next set.

    Hi binc,
    I have attached a VI that should remove outliers. This may not be the best way to do it, but it is one possibility.
    Thanks,
    Paul B.
    Motion Control R&D
    Attachments:
    Remove_outliers.vi ‏20 KB

  • Select on Cursor in oracle 10g

    Hi Experts ,
    I have a cursor which selects the data from another source.
    Now I am having a problem with this cursor because i cannot put any where condition as it takes huge time to retrive the data (data's are retrived from views)
    The "select *  from Source" works fine as it takes less  time.
    Now how can I filter the cursor  (select *  from Source ) and load the data into table ?
    can I use "select col from curosr where  cond= 'something' ?"

    You don't understand what a cursor is.
    You do not 'get data into a cursor'.  A cursor is not a result set of data.  A cursor is just a pointer to a query that data is fetched through.
    What you have shown there is a PL/SQL cursor declaration.  At that point is has not done anything except declare the definition of the cursor.  It hasn't even been opened or executed against the database, let alone any data fetched.
    How are you measuring that the query is 'fast' when you query it without conditions compared to 'slow' when you query it with conditions.
    It's possible that you don't have the correct indexes for your query filtering conditions etc. but as we don't have your database version, tables, data etc. we cannot see to help.
    I see you obviously didn't read the first FAQ about how to post your information.
    Maybe you'll bother to read this FAQ instead:  Re: 3. How to improve the performance of my query? / My query is running slow.
    which links to two threads describing what information you need to provide for tuning help.
    I can't see how you would improve performance by trying to filter your data after querying more than you need, so I think you're looking for a solution before you even know what the problem is.

  • Selection tablerow cursor

    Hi,
    When selecting another row, there is a delay on the selection.
    The program is putting the cursor in the selected row, before you can enter a value
    Any idea to solve it that the user can just enter a value without waiting for the cursor.

    hi Tim,
    as already specified please do parameter mapping for the table , then you will get the current element , like in
    wdModifyview method of the view in which this table is present add this code ....
    IWDLinkToAction indTransLevelLink = (IWDLinkToAction) view.getElement("LinkToAction");             
       indTransLevelLink.mappingOfOnAction().addSourceMapping("nodeElement","selectedElement");
    here LinkToAction is the id of the linktoaction in the table if present , and then you have an action
    onActionBBB(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement selectedElement
    IPrivate*******View.ITableNodeElement element = (IPrivate*******View.ITableNodeElement)selectedElement;
    element.getafb (); -- //this will give you the current elements afb details , this afb is reference to above //table shown by you
    here wdEvent is by default available and you have to create parameter selectedElement for this action  ,
    so any action you have where you are refering the current element just use the above code .
    for better understanding read links below
    http://help.sap.com/saphelp_dm40/helpdata/en/60/1f1f056f057d4d962375efd3c92ed0/content.htm
    Please close the thread if your problem is solved.
    Regards
    Govardan

  • Union select as cursor in procedure

    Hi!
    With ref. to an earlier post from Sept. 11, 2009, I am facing the following problem:
    In my procedure I have this statement as a cursor:
    SELECT a.carrier_code, a.flight_no, a.from_city, a.origin, a.dept_time, a.to_city, a.destination, a.arr_time, a.flight_date,
    a.aircraft_type, a.booking_class, a.service_class, a.num_of_seats, a.checked_bag, a.fare_basis, a.fare_type, a.currency, a.rt_net_fare, a.tax, a.surcharges, a.fare_total
    FROM favailability a, main_related_flight b
    WHERE a.flight_leg_id = b.flight_leg_id_1
    AND a.from_city = 'London'
    AND a.service_class = 'Business'
    AND a.fare_type = 'Business Saver'
    AND a.flight_date = '27.09.09'
    UNION
    SELECT d.carrier_code, d.flight_no, d.from_city, d.origin, d.dept_time, d.to_city, d.destination, d.arr_time, d.flight_date,
    d.aircraft_type, d.booking_class, d.service_class, d.num_of_seats, d.checked_bag, d.fare_basis, d.fare_type, d.currency, d.rt_net_fare, d.tax, d.surcharges, d.fare_total
    FROM favailability d, main_related_flight e
    WHERE d.flight_leg_id = e.flight_leg_id_2
    AND d.from_city = 'Zurich'
    AND d.service_class = 'Business'
    AND d.fare_type = 'Business Flex'
    AND d.flight_date = '03.10.09'
    ORDER BY flight_date;
    ARRIER_CODE FLIGHT_NO              FROM_CITY                                                              ORIGIN DEPT_TIME TO_CITY                                                                DESTINATION ARR_TIME FLIGHT_DATE               AIRCRAFT_TYPE                            BOOKING_CLASS SERVICE_CLASS                  NUM_OF_SEATS           CHECKED_BAG          FARE_BASIS FARE_TYPE                      CURRENCY RT_NET_FARE            TAX                    SURCHARGES             FARE_TOTAL            
    LX           345                    London                                                                 LHR    06:00     Zurich                                                                 ZRH         08:40    27.09.09                  Airbus A320                              J             Business                       64                     30 kg                LXJ        Business Saver                 EUR      337                    30,01                  35,24                  402,25                
    LX           450                    Zurich                                                                 ZRH    07:00     London                                                                 LCY         07:35    03.10.09                  AVRO RJ100                               Z             Business                       37                     30 kg                LXZ        Business Flex                  EUR      740                    30,01                  21,24                  791,25                
    2 rows selectedworks fine when running the statement alone. However, when running the procedure, my exception appears:
    ORA-20022: Fare not found for flight from London to Zurich on 27-Sep-2009
    Please note that the fare type can be different for inbound and outbound flights.
    PROCEDURE  FLIGHT (p_ptc_adult IN NUMBER,
                      p_ptc_adult_rt       IN NUMBER,
                      p_ptc_adult_add      IN NUMBER,
                      p_ptc_adult_add_rt   IN NUMBER,
                      p_city_o             IN favailability.from_city%TYPE,
                      p_city_d             IN favailability.to_city%TYPE,
                      p_service_class      IN favailability.service_class%TYPE,
                      p_fare_type          IN favailability.fare_type%TYPE,
                      p_fare_type_rt       IN favailability.fare_type%TYPE,
                      p_flightdate         IN favailability.flight_date%TYPE,
                      p_flightdate_rt      IN favailability.flight_date%TYPE,
                      p_username           IN users.username%TYPE,
                      p_password           IN users.password%TYPE,
                      p_card_type          IN users_cc.card_type%TYPE,
                      p_creditcardnumber   IN VARCHAR2,
                      p_expiry_date        IN DATE,
                      p_first_name_add     IN VARCHAR2,
                      p_last_name_add      IN VARCHAR2) IS
    CURSOR c1 IS
    SELECT a.carrier_code, a.flight_no, a.from_city, a.origin, a.dept_time, a.to_city, a.destination, a.arr_time, a.flight_date,
    a.aircraft_type, a.booking_class, a.service_class, a.num_of_seats, a.checked_bag, a.fare_basis, a.fare_type, a.currency, a.rt_net_fare, a.tax, a.surcharges, a.fare_total
    FROM favailability a, main_related_flight b
    WHERE a.flight_leg_id = b.flight_leg_id_1
    AND a.from_city = p_city_o
    AND a.service_class = p_service_class
    AND a.fare_type = p_fare_type
    AND a.flight_date = p_flightdate
    UNION
    SELECT d.carrier_code, d.flight_no, d.from_city, d.origin, d.dept_time, d.to_city, d.destination, d.arr_time, d.flight_date,
    d.aircraft_type, d.booking_class, d.service_class, d.num_of_seats, d.checked_bag, d.fare_basis, d.fare_type, d.currency, d.rt_net_fare, d.tax, d.surcharges, d.fare_total
    FROM favailability d, main_related_flight e
    WHERE d.flight_leg_id = e.flight_leg_id_2
    AND d.from_city = p_city_d
    AND d.service_class = p_service_class
    AND d.fare_type = p_fare_type_rt
    AND d.flight_date = p_flightdate_rt
    ORDER BY flight_date;
    f_rec                 c1%ROWTYPE;
    v_num_of_seats        favailability.num_of_seats%TYPE;
    v_fare_type           favailability.fare_type%TYPE;
    v_fare_type_rt        favailability.fare_type%TYPE;
    v_net_fare            favailability.rt_net_fare%TYPE;
    v_currency            fl_itinerary_t.currency_t%TYPE;
    v_rid                 fl_itinerary_t.rid%TYPE;
    v_status              fl_itinerary_t.status%TYPE;
    v_ptc_adult           NUMBER;
    v_ptc_adult_rt        NUMBER;
    v_ptc_adult_add       NUMBER;
    v_ptc_adult_add_rt    NUMBER;
    e_no_passenger        EXCEPTION;
    e_no_available_fares  EXCEPTION;
    e_no_user             EXCEPTION;
    e_credit_card_expired EXCEPTION;
    v_error_code          error_log.err_code%TYPE;
    v_error_message       error_log.err_message%TYPE;
    v_error_date          error_log.err_date%TYPE;
    v_user_name           users.username%TYPE;
    v_password            users.password%TYPE;
    v_user_id             users.user_id%TYPE;
    v_first_name          users.first_name%TYPE;
    v_last_name           users.last_name%TYPE;
    v_dob                 users.dob%TYPE;
    v_country_code        users.country_code%TYPE;
    v_prefix              users.prefix%TYPE;
    v_mobile_phone        users.mobile_phone%TYPE;
    v_card_type           users_cc.card_type%TYPE;
    v_creditcardnumber    users_cc.card_number%TYPE;
    v_expiry_date         DATE;
    v_grand_total         NUMBER(10,2);
    v_first_name_add      VARCHAR2(40);
    v_last_name_add       VARCHAR2(40);
    v_booking_code        VARCHAR2(6);
    v_result              VARCHAR2(32);
    BEGIN
    v_ptc_adult        := p_ptc_adult;
    v_ptc_adult_rt     := p_ptc_adult_rt;
    v_ptc_adult_add    := p_ptc_adult_add;
    v_ptc_adult_add_rt := p_ptc_adult_add_rt;
    -- Check user input
        IF p_city_o = p_city_d THEN
         dbms_output.put_line ('Departure city cannot be arrival city!');
        ELSIF p_flightdate = p_flightdate_rt THEN
         dbms_output.put_line ('Departure date cannot be arrival date!');
        ELSIF p_flightdate > p_flightdate_rt THEN
         dbms_output.put_line ('Departure date cannot be after arrival date!');
        ELSIF p_flightdate < sysdate OR p_flightdate_rt < sysdate THEN
         dbms_output.put_line ('Departure and arrival date cannot be in the past!');
        ELSE
        IF nvl(trunc(p_ptc_adult), 0) = 0
        OR nvl(trunc(p_ptc_adult_rt), 0) = 0
        THEN
            RAISE e_no_passenger;
        END IF;
    -- Check outbound availability
        SELECT num_of_seats INTO v_num_of_seats
        FROM favailability
        WHERE v_ptc_adult = p_ptc_adult
        AND v_ptc_adult_add = p_ptc_adult_add
        AND from_city = p_city_o
        AND to_city = p_city_d
        AND service_class = p_service_class
        AND fare_type = p_fare_type
        AND fare_type = p_fare_type_rt
        AND flight_date = p_flightdate;
        IF p_ptc_adult > v_num_of_seats
         OR v_num_of_seats < 2 THEN
          dbms_output.put_line ('No seats available!');
        ELSE
         UPDATE favailability SET num_of_seats = num_of_seats - p_ptc_adult
         WHERE v_ptc_adult = p_ptc_adult
         AND from_city = p_city_o
         AND to_city = p_city_d
         AND service_class = p_service_class
         AND fare_type = p_fare_type
         AND fare_type = p_fare_type_rt
         AND flight_date = p_flightdate;
        END IF;
        IF p_ptc_adult_add > v_num_of_seats
         OR v_num_of_seats < 2 THEN
          dbms_output.put_line ('No seats available!');
        ELSE
         UPDATE favailability SET num_of_seats = num_of_seats - p_ptc_adult_add
         WHERE v_ptc_adult_add = p_ptc_adult_add
         AND from_city = p_city_o
         AND to_city = p_city_d
         AND service_class = p_service_class
         AND fare_type = p_fare_type
         AND fare_type = p_fare_type_rt
         AND flight_date = p_flightdate;
        END IF;
    -- Check inbound availability
        SELECT num_of_seats INTO v_num_of_seats
        FROM favailability
        WHERE v_ptc_adult_rt = p_ptc_adult_rt
        AND v_ptc_adult_add_rt = p_ptc_adult_add_rt
        AND from_city = p_city_d
        AND to_city = p_city_o
        AND service_class = p_service_class
        AND fare_type = p_fare_type_rt
        AND fare_type = p_fare_type
        AND flight_date = p_flightdate_rt;
        IF p_ptc_adult_rt > v_num_of_seats
         OR v_num_of_seats < 2 THEN
         dbms_output.put_line ('No seats available!');
        ELSE
         UPDATE favailability SET num_of_seats = num_of_seats - p_ptc_adult_rt
         WHERE v_ptc_adult_rt = p_ptc_adult_rt
         AND from_city = p_city_d
         AND to_city = p_city_o
         AND service_class = p_service_class
         AND fare_type = p_fare_type_rt
         AND fare_type = p_fare_type
         AND flight_date = p_flightdate_rt;
        END IF;
        IF p_ptc_adult_add_rt > v_num_of_seats
         OR v_num_of_seats < 2 THEN
         dbms_output.put_line ('No seats available!');
        ELSE
         UPDATE favailability SET num_of_seats = num_of_seats - p_ptc_adult_add_rt
         WHERE v_ptc_adult_add_rt = p_ptc_adult_add_rt
         AND from_city = p_city_d
         AND to_city = p_city_o
         AND service_class = p_service_class
         AND fare_type = p_fare_type_rt
         AND fare_type = p_fare_type
         AND flight_date = p_flightdate_rt;
        END IF;
      -- get credit info
        SELECT u.user_id, u.first_name, u.last_name, u.dob, u.country_code, u.prefix, u.mobile_phone, p_card_type, p_creditcardnumber, p_expiry_date
           INTO   v_user_id, v_first_name, v_last_name, v_dob, v_country_code, v_prefix, v_mobile_phone, v_card_type, v_creditcardnumber, v_expiry_date
           FROM   dual, users u, users_cc c
           WHERE  u.user_id = c.user_id
           AND u.username = p_username
           AND u.password = p_password
           AND c.card_type = p_card_type
           AND c.card_number = p_creditcardnumber
           AND c.expiry_date = p_expiry_date;
           IF SQL%ROWCOUNT = 0 THEN
                              RAISE e_no_user;
           END IF;
           IF p_expiry_date < sysdate THEN
                  RAISE e_credit_card_expired;
           END IF;
        v_result := booking_pkg.validatecreditcard(p_creditcardnumber);
    -- open cursor
    OPEN c1;
    LOOP
        FETCH c1 INTO f_rec;
        EXIT WHEN c1%notfound;
    -- insert records    
         INSERT INTO fl_itinerary_t (rid, carrier_t, fno_t, from_city_t, origin_t, dept_t, to_city_t, destination_t, arr_t, fdate_t, aircraft_type_t, booking_class_t, service_class_t,
                                     num_of_seats_t, checked_bag_t, fare_basis_t, fare_type_t, currency_t, fare_t, tax_t, surcharges_t, fare_total_t, grand_total_t, trans_date,
                                     status, user_id, first_name, last_name, dob, country_code, prefix, mobile_phone)
         VALUES (new_res_seq.nextval, f_rec.carrier_code, f_rec.flight_no, f_rec.from_city, f_rec.origin, f_rec.dept_time, f_rec.to_city, f_rec.destination, f_rec.arr_time, f_rec.flight_date, f_rec.aircraft_type, f_rec.booking_class,
                 f_rec.service_class, p_ptc_adult + p_ptc_adult_add, f_rec.checked_bag, f_rec.fare_basis, f_rec.fare_type, f_rec.currency, f_rec.rt_net_fare, f_rec.tax, f_rec.surcharges, f_rec.fare_total, f_rec.fare_total * (p_ptc_adult + p_ptc_adult_add), sysdate,
                 'Confirmed', v_user_id, v_first_name, v_last_name, v_dob, v_country_code, v_prefix, v_mobile_phone);
      -- additional traveller
         SELECT p_first_name_add, p_last_name_add
         INTO v_first_name_add, v_last_name_add
         FROM dual;
         IF v_ptc_adult_add = p_ptc_adult_add
         AND v_ptc_adult_add_rt = p_ptc_adult_add_rt
         AND v_first_name_add = p_first_name_add
         AND v_last_name_add = p_last_name_add
         THEN
           INSERT INTO fl_itinerary_add (trans_id, carrier, fno, from_city, to_city, fdate, first_name_2, last_name_2, dob_2, main_user_id, trans_date, status)
           VALUES (new_trans_seq.nextval, f_rec.carrier_code, f_rec.flight_no, f_rec.from_city, f_rec.to_city, f_rec.flight_date, v_first_name_add, v_last_name_add, null, v_user_id, sysdate, 'Confirmed');
         END IF;
      COMMIT;  
    END LOOP;
    CLOSE c1;
         -- show itinerary for main traveller
           dbms_output.put_line ('Itinerary completed!');
           dbms_output.put_line (v_ptc_adult || ' seat(s) reserved for ' || v_first_name ||', ' || v_last_name);
           dbms_output.put_line (v_ptc_adult_rt || ' seat(s) reserved for ' || v_first_name ||', ' || v_last_name);
         -- show itinerary for 2.traveller
           dbms_output.put_line (v_ptc_adult_add || ' seat(s) reserved for ' || v_first_name_add ||', ' || v_last_name_add);
           dbms_output.put_line (v_ptc_adult_add_rt || ' seat(s) reserved for ' || v_first_name_add ||', ' || v_last_name_add); 
    END IF;
           -- Create new booking
           INSERT INTO booking (booking_id,
                                rid,
                                e_ticket_no,
                                booking_code,
                                user_id,
                                first_name,
                                last_name,
                                dob,
                                credit_card_type,
                                credit_card_number,
                                currency, 
                                booking_date,
                                status)
           VALUES (new_booking_seq.nextval,
                   new_res_seq.currval,
                   dbms_random.value(1000000000000, 9999999999999),
                   dbms_random.string('X', 6), 
                   v_user_id,
                   v_first_name,
                   v_last_name,
                   v_dob,
                   v_card_type,
                   'xxxx-xxxx-xxxx-'||substr(v_creditcardnumber,-4),
                   f_rec.currency,
                   SYSDATE, 'Confirmed');
            SELECT booking_code
            INTO v_booking_code
            FROM booking;
             dbms_output.put_line ('Booking code: ' || v_booking_code);
    EXCEPTION
        WHEN e_no_available_fares THEN
          RAISE_APPLICATION_ERROR (-20021, 'There are no fares available for flight'||
                                           ' from '|| p_city_o||' to '|| p_city_d||' on '||TO_CHAR(p_flightdate, 'dd-Mon-yyyy'));
        WHEN no_data_found THEN
          RAISE_APPLICATION_ERROR (-20022, 'Fare not found for flight from '|| p_city_o||
                                           ' to '|| p_city_d||' on '||TO_CHAR(p_flightdate, 'dd-Mon-yyyy'));
        WHEN too_many_rows THEN
          RAISE_APPLICATION_ERROR (-20023, 'More than one fare found for flight from '||
                                            p_city_o||' to '|| p_city_d||' on '||
                                            TO_CHAR(p_flightdate, 'dd-Mon-yyyy'));
        WHEN e_no_passenger THEN
          RAISE_APPLICATION_ERROR(-20001, 'Please enter a valid number of travelers!');
        WHEN e_no_user THEN
          RAISE_APPLICATION_ERROR(-20002, 'User not found!');
        WHEN e_credit_card_expired THEN
          RAISE_APPLICATION_ERROR(-20003, 'Credit card has expired!');
        --WHEN OTHERS THEN
        --  v_error_code := SQLCODE;
        --  v_error_message := SUBSTR(SQLERRM, 1, 200);
         -- INSERT INTO error_log (err_code, err_message, err_date) VALUES
          --  (v_error_code, v_error_message, sysdate);
    END FLIGHT;Furthermore, only 1 booking can be inserted into the booking table.

    Hi!
    Thanks for the tip! Now inserting into the booking table works! Sorry for bothering again. In my package I have this function that should check the
    credit card number. Works alone, but not within the package (procedure). Please see above procedure too.
    FUNCTION VALIDATECREDITCARD (p_creditcardnumber IN VARCHAR2)
       RETURN VARCHAR2
    IS
       creditcardnumber    VARCHAR2 (32);
                --:= nosymbols (p_CreditCardNumber, LENGTH (p_CreditCardNumber));
       creditcardlength    NUMBER         := LENGTH (p_creditcardnumber);
       subtotal            NUMBER         := 0;
       t_value             NUMBER         := 0;
       c1                  NUMBER;
       c2                  NUMBER;
       c3                  NUMBER;
       c4                  NUMBER;
       cardtype            VARCHAR2 (160) := 'CARD';
       calculationmethod   VARCHAR2 (160) := 'UNKNOWN';
       RESULT              VARCHAR2 (160);
       v_expiry_date       DATE;
    BEGIN
       creditcardnumber := LTRIM(RTRIM(p_creditcardnumber));
       creditcardnumber := REPLACE(creditcardnumber, '-');
       creditcardnumber := REPLACE(creditcardnumber, '.');
    -- IF isnumber (CreditCardNumber) = 0 THEN
       c1 := TO_NUMBER (SUBSTR (creditcardnumber, 1, 1));
       c2 := TO_NUMBER (SUBSTR (creditcardnumber, 1, 2));
       c3 := TO_NUMBER (SUBSTR (creditcardnumber, 1, 3));
       c4 := TO_NUMBER (SUBSTR (creditcardnumber, 1, 4));
       IF creditcardlength = 13
       THEN
          IF c1 IN (4)
          THEN
             cardtype := 'VISA';
             calculationmethod := 'MOD10';
          END IF;
       ELSIF creditcardlength = 14
       THEN
          IF c2 IN (36, 38)
          THEN
             cardtype := 'DINERS CLUB';
             calculationmethod := 'MOD10';
          ELSIF c3 IN (300, 301, 302, 303, 304, 305)
          THEN
             cardtype := 'DINERS CLUB';
             calculationmethod := 'MOD10';
          END IF;
       ELSIF creditcardlength = 15
       THEN
          IF c2 IN (34, 37)
          THEN
             cardtype := 'AMEX';
             calculationmethod := 'MOD10';
          ELSIF c4 IN (2014, 2149)
          THEN
             cardtype := 'enROUTE';
             calculationmethod := 'ANY';
          ELSIF c4 IN (2131, 1800)
          THEN
             cardtype := 'JBC';
             calculationmethod := 'MOD10';
          END IF;
       ELSIF creditcardlength = 16
       THEN
          IF c1 IN (4)
          THEN
             cardtype := 'VISA';
             calculationmethod := 'MOD10';
          ELSIF c1 IN (3)
          THEN
             cardtype := 'JBC';
             calculationmethod := 'MOD10';
          ELSIF c2 IN (51, 52, 53, 54, 55)
          THEN
             cardtype := 'MASTERCARD';
             calculationmethod := 'MOD10';
          ELSIF c4 IN (6011)
          THEN
             cardtype := 'DISCOVER';
             calculationmethod := 'MOD10';
          END IF;
       END IF;
       IF calculationmethod = 'MOD10'
       THEN
          FOR i IN REVERSE 1 .. LENGTH (creditcardnumber)
          LOOP
                 IF cardtype = 'AMEX'
             THEN
                IF (TO_NUMBER (SUBSTR (TO_CHAR (i), LENGTH (i), 1)) NOT IN  (1, 3, 5, 7, 9))
                THEN
                   t_value := SUBSTR (creditcardnumber, i, 1) * 2;
                   subtotal := subtotal + SUBSTR (t_value, 1, 1);
                   subtotal := subtotal + NVL (SUBSTR (t_value, 2, 1), 0);
                ELSE
                   subtotal := subtotal + SUBSTR (creditcardnumber, i, 1);
                END IF;                       
             ELSE          
                IF (TO_NUMBER (SUBSTR (TO_CHAR (i), LENGTH (i), 1)) IN  (1, 3, 5, 7, 9))
                THEN
                   t_value := SUBSTR (creditcardnumber, i, 1) * 2;
                   subtotal := subtotal + SUBSTR (t_value, 1, 1);
                   subtotal := subtotal + NVL (SUBSTR (t_value, 2, 1), 0);
                ELSE
                   subtotal := subtotal + SUBSTR (creditcardnumber, i, 1);
                END IF;                       
             END IF;
          END LOOP;
          IF MOD (subtotal, 10) = 0
          THEN
             RESULT := 'VALID';
          ELSE
             RESULT := 'INVALID';
          END IF;
       ELSIF calculationmethod = 'ANY'
       THEN
          RESULT := 'VALID';
       ELSE
          RESULT := 'UNKNOWN';
       END IF;
       RESULT := RESULT || ', ' || cardtype;
       RETURN (RESULT);
    END VALIDATECREDITCARD;
    create or replace PACKAGE        "BOOKING_PKG"
    AS
      PROCEDURE  FLIGHT (p_ptc_adult IN NUMBER,
                      p_ptc_adult_rt       IN NUMBER,
                      p_ptc_adult_add      IN NUMBER,
                      p_ptc_adult_add_rt   IN NUMBER,
                      p_city_o             IN favailability.from_city%TYPE,
                      p_city_d             IN favailability.to_city%TYPE,
                      p_service_class      IN favailability.service_class%TYPE,
                      p_fare_type          IN favailability.fare_type%TYPE,
                      p_fare_type_rt       IN favailability.fare_type%TYPE,
                      p_flightdate         IN favailability.flight_date%TYPE,
                      p_flightdate_rt      IN favailability.flight_date%TYPE,
                      p_username           IN users.username%TYPE,
                      p_password           IN users.password%TYPE,
                      p_card_type          IN users_cc.card_type%TYPE,
                      p_creditcardnumber   IN VARCHAR2,
                      p_expiry_date        IN DATE,
                      p_first_name_add     IN VARCHAR2,
                      p_last_name_add      IN VARCHAR2);
      PROCEDURE  NEW_USER (p_username      IN users.username%TYPE,
                           p_password      IN users.password%TYPE,
                           p_salutation       users.salutation%TYPE,
                           p_academic_title   users.academic_title%TYPE,
                           p_first_name       users.first_name%TYPE,
                           p_last_name        users.last_name%TYPE,
                           p_dob              users.dob%TYPE,
                           p_street_address   users.street_address%TYPE,
                           p_company_name     users.company_name%TYPE,
                           p_street_address_2 users.street_address_2%TYPE,
                           p_country          users.country%TYPE,
                           p_postal_code      users.postal_code%TYPE,
                           p_city             users.city%TYPE,
                           p_e_mail_address   users.e_mail_address%TYPE,
                           p_country_code     users.country_code%TYPE,
                           p_prefix           users.prefix%TYPE,
                           p_mobile_phone     users.mobile_phone%TYPE,
                           p_home_phone       users.home_phone%TYPE,
                           p_language         users.language%TYPE,
                           p_newsletter       users.newsletter%TYPE,
                           p_specials         users.specials%TYPE,
                           p_membership       users.membership%TYPE,
                           p_remarks          users.remarks%TYPE);
      FUNCTION  VALIDATECREDITCARD (p_creditcardnumber IN VARCHAR2) RETURN VARCHAR2;
    END BOOKING_PKG;Thanks for your help!

  • At line Selection & get cursor field

    Hi friends,
    Could any one of u please explain about<b> at line selection</b> and <b>GET CURSOR FIELD</b> ( GET CURSOR FIELD FNAM VALUE FVAL) with sample program.
    Jai.

    Hello,
    AT - Events in lists
    Variants:
    1. AT LINE-SELECTION.
    2. AT USER-COMMAND.
    3. AT PFn.
    Variant 1
    AT LINE-SELECTION.
    Effect
    Event in interactive reporting
    This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.
    The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.
    In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.
    Note
    You can choose a line and start new processing even in the details lists.
    The following system fields are useful for orientation purposes, since their values change with each interactive event executed.
    SY-LSIND
    Index of list created by current event (basic list = 0, 1st details list = 1, ...)
    SY-PFKEY
    Status of displayed list (SET PF-STATUS)
    SY-LISEL
    Contents of selected line
    SY-LILLI
    Absolute number of this line in the displayed list
    SY-LISTI
    Index of this list - usually SY-LSIND - 1 (READ LINE)
    SY-CUROW
    Last cursor position: Line in window
    SY-CUCOL
    Last cursor position: Column in window (GET CURSOR)
    SY-CPAGE
    1st displayed page of displayed list
    SY-STARO
    1st displayed line of this page of displayed list
    SY-STACO
    1st displayed column of displayed list (SCROLL LIST)
    The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0).
    System field for interactive reporting are also contained in the System Fields for Lists documentation.
    Example
    DATA TEXT(20).
    START-OF-SELECTION.
      PERFORM WRITE_AND_HIDE USING SPACE SPACE.
    AT LINE-SELECTION.
      CASE TEXT.
        WHEN 'List index'.
          PERFORM WRITE_AND_HIDE USING 'X' SPACE.
        WHEN 'User command'.
          PERFORM WRITE_AND_HIDE USING SPACE 'X'.
        WHEN OTHERS.
          SUBTRACT 2 FROM SY-LSIND.
          PERFORM WRITE_AND_HIDE USING SPACE SPACE.
      ENDCASE.
      CLEAR TEXT.
    FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.
      WRITE / 'SY-LSIND:'.
      PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.
      TEXT = 'List index'.
      HIDE TEXT.
      WRITE / 'SY-UCOMM:'.
      PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.
      TEXT = 'User command'.
      HIDE TEXT.
      IF SY-LSIND > 0.
        WRITE / 'PICK here to go back one list level'.
      ENDIF.
    ENDFORM.
    FORM WRITE_WITH_COLOR USING P_VALUE
                                P_FLAG_POSITIVE.
      IF P_FLAG_POSITIVE = SPACE.
        WRITE P_VALUE COLOR COL_NORMAL.
      ELSE.
        WRITE P_VALUE COLOR COL_POSITIVE.
      ENDIF.
    ENDFORM.
    Depending on whether you choose the line at SY-LSIND or SY-UCOMM, the next details list contains the corresponding value with the color "positive". If the line is chosen without HIDE information, the list level is reduced.
    Variant 2
    AT USER-COMMAND.
    Effect
    Event in interactive reporting
    This event is executed whenever the user presses a function key in the list or makes an entry in the command field.
    Some functions are executed directly by the system and thus cannot be processed by programs. These include:
    PICK
    See variant AT LINE-SELECTION
    PFn
    See variant AT PFn
    System command
    System command
    PRI
    Print
    BACK
    Back
    RW
    Cancel
    P...
    Scroll function (e.g.: P+ , P- , PP+3, PS-- etc.)
    Instead of this functions, you can use the SCROLL statement in programs.
    Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.
    Otherwise, the effect is as for AT LINE-SELECTION; also, the current function code is stored in the system field SY-UCOMM.
    Example
    DATA: NUMBER1 TYPE I VALUE 20,
          NUMBER2 TYPE I VALUE  5,
          RESULT  TYPE I.
    START-OF-SELECTION.
      WRITE: / NUMBER1, '?', NUMBER2.
    AT USER-COMMAND.
      CASE SY-UCOMM.
        WHEN 'ADD'.
          RESULT = NUMBER1 + NUMBER2.
        WHEN 'SUBT'.
          RESULT = NUMBER1 - NUMBER2.
        WHEN 'MULT'.
          RESULT = NUMBER1 * NUMBER2.
        WHEN 'DIVI'.
          RESULT = NUMBER1 / NUMBER2.
        WHEN OTHERS.
          WRITE 'Unknown function code'.
          EXIT.
      ENDCASE.
      WRITE: / 'Result:', RESULT.
    After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.
    Variant 3
    AT PFn.
    Effect
    Event in interactive reporting
    Here, n stands for a numeric value between 0 and 99.
    This event is executed whenever the user presses a function key that contains the function code PFn in the interface definition. The default status for lists contains some of these functions.
    Otherwise, the effect is as for the variant AT LINE-SELECTION. The cursor can be on any line.
    Notes
    To ensure that the chosen function is executed only for valid lines, you can check the current HIDE information.
    This variant should be used only for test or prototyping purposes, since the default status is not normally used. Instead, you should set a program-specific status with SET PF-STATUS. This should not contain any function codes beginning with "PF".
    Example
    DATA NUMBER LIKE SY-INDEX.
    START-OF-SELECTION.
      DO 9 TIMES.
        WRITE: / 'Row', (2) SY-INDEX.
        NUMBER = SY-INDEX.
        HIDE NUMBER.
      ENDDO.
    AT PF8.
      CHECK NOT NUMBER IS INITIAL.
      WRITE: / 'Cursor was in row', (2) NUMBER.
      CLEAR NUMBER.
    Additional help
    User Action on Detail Lists
    GET
    Basic form 2 GET CURSOR. ...
    Variants:
    1. GET CURSOR FIELD f.
    2. GET CURSOR LINE line.
    Variant 1
    GET CURSOR FIELD f.
    Additions:
    1. ... OFFSET off
    2. ... LINE line
    3. ... VALUE g
    4. ... LENGTH len
    5. ... AREA
    Effect
    Transfers the name of the field at the cursor position to the field f.
    The return code is set as follows:
    SY-SUBRC = 0:
    Cursor was positioned on a field.
    SY-SUBRC = 4:
    Cursor was not positioned on a field.
    Note
    Unlike screen processing, list processing allows you to output literals, field symbols, parameters and local variables of subroutines. Literals, local variables and VALUE parameters of subroutines are treated like fields without names (field name SPACE, return value 0).
    Otherwise, GET CURSOR FIELD returns only names of global fields, regardless of whether they are addressed directly (i.e. by "WRITE"), by field symbols or by reference parameters.
    Example
    DATA: CURSORFIELD(20),
          GLOB_FIELD(20)    VALUE 'global field',
          REF_PARAMETER(30) VALUE 'parameter by reference',
          VAL_PARAMETER(30) VALUE 'parameter by value',
          FIELD_SYMBOL(20)  VALUE 'field symbol'.
    FIELD-SYMBOLS: <F> TYPE ANY.
    PERFORM WRITE_LIST USING REF_PARAMETER VAL_PARAMETER.
    ASSIGN GLOB_FIELD TO <F>.
    AT LINE-SELECTION.
      GET CURSOR FIELD CURSORFIELD.
      WRITE: /   CURSORFIELD, SY-SUBRC.
    FORM WRITE_LIST USING RP VALUE(VP).
      DATA: LOK_FIELD(20)  VALUE 'local field'.
      ASSIGN FIELD_SYMBOL TO <F>.
      WRITE: /  GLOB_FIELD,  /  LOC_FIELD,
             /  RP,          /  VP,
             /  'literal',   /  FIELD_SYMBOL.
    ENDFORM.
    When you double-click the word " global field", CURSORFIELD contains the field name GLOB_FIELD, on "parameter by reference" the field name REF_PARAMETER, on " field symbol" the field name FIELD_SYMBOL, and on "local field", "parameter by value" and "literal" the value SPACE.
    Addition 1
    ... OFFSET off
    Effect
    Copies the position of the cursor within the field to the field off (1st column = 0).
    If the cursor is not somewhere within a field (SY-SUBRC = 4), the offset value is set to 0.
    Addition 2
    ... LINE line
    Effect
    With step loops, lin contains the number of the loop line where the cursor stands. In list processing, this is the absolute line number (as stored in the system field SY-LILLI).
    Addition 3
    ... VALUE g
    Effect
    g contains the value of the field where the cursor stands, always in output format (character display).
    Addition 4
    ... LENGTH len
    Effect
    len contains the output length of the field where the cursor stands.
    Addition 5
    ... AREA a
    Effect
    If the cursor is positioned on the field of a table view control, the name of the control is placed in the field a.
    Variant 2
    GET CURSOR LINE line.
    Additions:
    1. ... OFFSET off
    2. ... VALUE  g
    3. ... LENGTH len
    Effect
    As for variant 1 with addition LINE, except that there are differences with the return code and the effect of the additions.
    The return code is set as follows:
    SY-SUBRC = 0:
    The cursor is on one of the list lines (list processing) or on a loop line (step loop).
    SY-SUBRC = 4:
    The cursor is not on one of the list or loop lines.
    Addition 1
    ... OFFSET off
    Effect
    Applies to list processing only. The field off contains the position of the cursor relative to the beginning of the list line (1st column = 0). With horizontally shifted lists, the offset value can thus be greater than 0, even if the cursor is positioned on the extreme left of the window.
    Addition 2
    ... VALUE g
    Effect
    List processing only. The field g contains the list line where the cursor is positioned.
    Addition 3
    ... LENGTH len
    Effect
    List processing only. len contains the length of the line (LINE-SIZE).
    Related
    SET CURSOR
    Additional help
    Setting the Cursor Position
    Reading Lists at the Cursor Position
    Vasanth

  • Why does Firefox not scroll the page when selecting & the cursor reaches the bottom of the screen

    When selecting text on a screen page, when the cursor reached the bottom edge of the screen Firefox (9.0.1) does not scroll. Other programs (including IE) do so, so it does not appear to be a local computer problem.
    I cannot see a setting on the options page that enables/disables this so what is the solution?

    Enable the Add-ons bar (Firefox > Options or View > Toolbars; Ctrl+/) or the Find bar (Ctrl+F) to make Firefox scroll the page while selecting text.

  • Help with creating a cursor select form

    Hey guys i need some help, I have a client who would like a menu on her website that allows users to select differnt cursors, I have never done anything like this before hand, Can anyone help out or point me in the direction of a tutorial for this sort of thing, thanks

    Hi,
    as I know, you can change your cursors by system software or/and browser. On the other hand you can use programs "outside" of your DW. I suggest to "Google" for them, as I did, and found for example this:
    http://www.google.de/#hl=de&xhr=t&q=create+cursor&cp=13&pf=p&sclient=psy&site=&source=hp&a q=0&aqi=g2&aql=&oq=create+cursor&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=e8c6fad3e718b799&biw=1280 &bih=785
    or http://www.cursors-4u.com/ and while examining this website my cursor changed immediately.
    Hans-Günter

  • Cursor Expression Select Statement

    SELECT DNAME, CURSOR(SELECT SAL,COMM FROM EMP E WHERE E.DEPTNO = D.DEPTNO) FROM DEPT D
    DNAME CURSOR(SELECTSAL,COM
    ACCOUNTING CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    SAL COMM
    2450
    5000
    1300
    RESEARCH CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    SAL COMM
    800
    2975
    3000
    1100
    3000
    SALES CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    SAL COMM
    1600 300
    1250 500
    1250 1400
    2850
    1500 0
    950
    6 rows selected.
    OPERATIONS CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selected
    Can we get rid of "CURSOR STATEMENT : 2"(Also I don't know what is its
    significance there) from the output so that the output is in a readable format.
    Thanks,
    Neeraj Goel

    I want Data in the Format Like
    deptno cnt1
    cnt2
    cntN
    deptno cnt1
    cntM
    when you have a parent table (dept) and you sometimes
    want to see the child rows (emp) but "on demand". For example, you fetch
    "select deptno, cursor( from emp ) from dept" and the user says "hmmm, I'd like
    to see the emps in deptno 20" -- great, you just fetch that cursor and display
    them -- you didn't have to bring everyone else back with that query.
    Also useful when you have more then 1:M relationship in a query
    Now you can get a result set like:
    deptno Sal Comm
    Sal Comm
    Sal
    3 Sal, 2 Comm items and one deptno -- in one "row"
    Thats why i used cursor Expression.
    Thanks
    Neeraj Goel

  • More on "maximum open cursors exceeded"

    It seems a lot of people have been seeing this error message, but reading through the posts on the topic hasn't given me any new insight on the problem. Here's an account of my particular situation:
    I am using the XSQL servlet, v.1.0.0.0 with the thin jdbc driver v.1.x. The servlet is running within an Apache server (1.3.12) on a Linux box, and the Oracle database (8.1.5) is located on a Solaris 2.6 machine.
    The servlet accepts HTTP connections, performs the corresponding SQL queries and returns the output from the database to the HTTP client. Here's a simple example:
    (Sorry about potential bad line breaks.)
    client request:
    % telnet xsql-host.some.domain 80
    Trying xxx.xxx.xxx.xxx
    Connected to xsql-host.some.domain.
    GET /xsql/test/listall.xsql
    <server response here>
    listall.xsql:
    <?xml version="1.0"?>
    <page connection="boss" xmlns:xsql="urn:oracle-xsql">
    <accounts>
    <xsql:query tag-case="lower" rowset-element="" row-element="accountinfo">
    select * from test
    </xsql:query>
    </accounts>
    </page>
    Very simple stuff indeed. Now, this has worked perfectly for 3 weeks or so. During this period, the xsql servlet has been stopped and restarted numerous times and the machine hosting the database has been rebooted at least three times. Then, for no apparent reason (as nothing had changed in the setup described above), I started getting "maximum open cursors exceeded" on every request. Since then, I have been unable to get the system working as it had up until now. I haven't restarted the database and I would like to avoid doing so, because that would not be a valid solution for us if the problem reappeared in production. The maximum open cursors setting in Oracle should be correct, since things were running smoothly before.
    From what I can see, the problem could be with the servlet not closing its cursors. One post mentioned that it did, but I would appreciate it if this could be double-checked. Considering the database is the only portion of the system which has been kept running for extended periods of time, it seems to me that this might indeed be the problem.
    Confirmation, workarounds, suggestions, patches, or a consolation box of chocolates would all be appreciated.
    Thanks,
    - Fad
    ([email protected])
    null

    Check which process is making all the cursors on which database. If it is your procedure, try explicitly closing the cursors. I think the cursors are only implicitely closed after the transaction is ended. If you loop and open a cursor within the loop, that might be the problem.
    I also had this problem with Java working over a JDBC connection some time ago on a 815 database. If I recall correctly, that was caused by the JDBC driver and fixed by replacing it with a JDBC driver of 9i.
    The following script is what I used previously in a program that can draw a graph from the results. It is ugly, but does the job.
    Hope this helps,
    L.
    select
      'max cursors',
      to_number(value)
    from
      v$parameter
    where
      name = 'open_cursors'
    union
    select
      substr(lower(username),1,10)||'('||substr(to_char(ses.sid)||','
      ||to_char(serial#),1,9)||')',
      s.value
    from
      v$sesstat s,
      v$statname n,
      v$session ses
    where
    s.statistic#=n.statistic#
    and ses.sid=s.sid
    and n.name like '%cursor%'
    and n.name like '%current%'
    and not (ses.sid between 1 and 6)

  • How to get highest number of open cursors within the current calendar day

    Hi all ,
    i need to know how to get the highest number of open cursors within the current calendar day.
    Thanks ,

    823030 wrote:
    the issue is my customer is getting the error ORA-01000: maximum open cursors exceeded and we need an sql statment that gets the following values :
    -highest number of open cursors experienced in the current calendar day.
    -current open cursors
    -and maximum open cursorsThis error is rare. It happens when
    a) the value of the open cursor parameter is set extremly low (default is something like 1000). Low would be something like 10.
    b) <strike>you have many concurrent users(=sessions) and </strike>the application does not use bind values
    In this case each select will open a new cursor, instead of reusing it.
    c) you have a select that opens a cursor for each line. This can happen with a statement where you have the CURSOR keyword somewhere in the select or where clause. Those cursors will be closed when the select is finished. But during the run time of the select, all cursors stay open.
    To track the number of "open cursors" during the day you would need to implement some monitoring. Maybe based on the view that was already mentioned.
    Edited by: Sven W. on May 16, 2011 2:30 PM - since the parameter is on session level, other open cursors should not influence it much.

  • Maximum open cursors exceeded when inserting to a remote db

    I receive the error:
    ORA-01000: maximum open cursors exceeded
    ORA-02063: preceding line
    from ONTARIO
    (where ONTARIO is my remote db) when I am performing inserts from a pl/sql procedure to the remote db. I am performing two inserts from inside pl/sql and then issuing an explicit commit. I checked the open_cursors init param on both the local db and remote db and it was set to 300. I bumped up the remote db init param to 600. I was able to perform more inserts but still received this error.
    I thought implicit cursors close themselves, especially after a commit. Do I need to do something special to close the cursors on the remote machine?
    Thanks for your time...

    Check which process is making all the cursors on which database. If it is your procedure, try explicitly closing the cursors. I think the cursors are only implicitely closed after the transaction is ended. If you loop and open a cursor within the loop, that might be the problem.
    I also had this problem with Java working over a JDBC connection some time ago on a 815 database. If I recall correctly, that was caused by the JDBC driver and fixed by replacing it with a JDBC driver of 9i.
    The following script is what I used previously in a program that can draw a graph from the results. It is ugly, but does the job.
    Hope this helps,
    L.
    select
      'max cursors',
      to_number(value)
    from
      v$parameter
    where
      name = 'open_cursors'
    union
    select
      substr(lower(username),1,10)||'('||substr(to_char(ses.sid)||','
      ||to_char(serial#),1,9)||')',
      s.value
    from
      v$sesstat s,
      v$statname n,
      v$session ses
    where
    s.statistic#=n.statistic#
    and ses.sid=s.sid
    and n.name like '%cursor%'
    and n.name like '%current%'
    and not (ses.sid between 1 and 6)

Maybe you are looking for