More than 1 SQL query with checkbox and error invalid number report

Hi all

I have two SQL query reports that each has an apex_item.checkbox and two processes for each report.  A report/process works very well.  It gives me an error of invalid number.

In addition, another query SQL (editable report) gives me the following error when using the Multi line process, delete.

ORA-06502: PL/SQL: digital or value error: character number conversion
error ORA-06502: PL/SQL: digital or value error: character number conversion
error
Ok

When I got a report from SQL query (with box and a process) and the query SQL (editable report) everything worked.  It stopped working when I added another SQL query report (with box and a process).

A SQL query has the following in my query: apex_item.checkbox(3,email_id,'UNCHECKED') ""

The other SQL query has the following: apex_item.checkbox(2,b.file_id,'UNCHECKED') ""

Any help will be greatly appreciated,

Sylvia

Hi Reema,

I've recreated the region and now it works!

Thank you for this, looking at

Sylvia

Tags: Database

Similar Questions

  • SQL query with terms and calculations?

    Hello
    How do I create a query with terms and calculations?
    For example, I have this table


    Start | End |     At work |     Mandatory
    ------------------------------------------------------------------------------------
    1ST JANUARY 13 | JANUARY 11, 13.     Office |          1
    JANUARY 14, 13. 25 JANUARY 13 |     Ministry of the Interior.     0
    04-MRZ-13 | 15-MRZ-13 |     Office |          0
    FEBRUARY 11, 13. FEBRUARY 22, 13.     Office |          1


    Now, if the workplace of the column = office and required column = 0
    the new 'price' column should calculate: (end-start) * $25.00
    and if workplace = Office and required column = 1
    the 'price' column must calculate: (end-start) * $20.60
    any other $0.00

    I tried with the case statement, but I didn't know how
    to calculate my values and display in the virtual column 'price '.

    Something like
    case
    When Working_Place = 'Office' and mandatory = 1
    then...
    else ' 0.00'. "
    end PRICE
    ?????


    Or is that not possible?

    Published by: DB2000 on 12.03.2013 05:09

    Use CASE:

    select  start_dt,
            end_dt,
            working_place,
            mandatory,
            case
              when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
              when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
              else 0
            end price
      from  tbl
    /
    
    START_DT  END_DT    WORKING_PLA  MANDATORY      PRICE
    --------- --------- ----------- ---------- ----------
    01-JAN-13 11-JAN-13 Office               1        206
    14-JAN-13 25-JAN-13 Home Office          0          0
    04-MAR-13 15-MAR-13 Office               0        275
    11-FEB-13 22-FEB-13 Office               1      226.6
    
    SQL> 
    

    SY.

  • Write a SQL query with lines in columns

    All the

    I need help in writing a SQL query with lines in columns, let give u an example...

    drop table activity;

    CREATE TABLE 'ACTIVITY '.

    (

    "PROJECT_WID" NUMBER (22.0) NOT NULL,

    VARCHAR2 (150 CHAR) "PROJECT_NO."

    VARCHAR2 (800 CHAR) 'NAME '.

    );

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1683691, '10007', 12-121');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1684994, '10008', 12-122');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1686296, '10009', 12-123');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (2225222, '9040', 12-124');

    drop table lonet;

    CREATE TABLE 'LONET.

    (

    VARCHAR2 (150 CHAR) "NAME."

    NUMBER OF THE "ROOT."

    VARCHAR2 (150 CHAR) "ENTRYVALUE".

    );

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1683691, "LDE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1683691, 'LME');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1683691, 'ICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1683691, 'IKE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1686291, "QTY");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1686291, 'MAX');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1684994, "MTE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1684994, 'MAC');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMT', 1684994, 'NICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMR', 1684994, 'RAY');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1686296, "CAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("PAP", 1686296, "QAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("VANESSA", 1686296, "THEW");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("ANDR", 1686296, "REYL");

    commit;

    Link: activity.project_wid = lonet.root

    look like output

    Project_wid Project_no NAME GAC NAM BAG RAC
    16836911000712-121LDELMELCELKE
    16849941000812-122MTEnullnullMAC
    16862961000912-123nullnullCAQQAQ
    2225222904012-124nullnullnullnull

    two problems, in that I am running

    1. I dono how simply we can convert rows to columns

    2. for root = 1683691, there are double NAM and RAC in lonet table... ideally these data should not be there, but since its here, we can take a MAX so that it returns a value

    3. There are undesirables who should be ignored

    Once again my thought process is that we join the activity and 4 alias table lonet.

    ask for your help in this

    Thank you

    Hello

    This is called pivoting.

    Here's a way to do it:

    WITH relevant_data AS

    (

    SELECT a.project_wid, a.project_no, b.SID

    , l.name AS lonet_name, l.entryvalue

    Activity one

    LEFT OUTER JOIN lonet l.root = a.project_wid l

    )

    SELECT *.

    OF relevant_data

    PIVOT (MAX (entryvalue)

    FOR lonet_name IN ("GAC" IN the gac

    "NAM" AS nam

    'BAG' IN the bag

    "RAC" AS cars

    )

    )

    ORDER BY project_wid

    ;

    Output:

    PROJECT_WID PROJECT_NO GAC NAM BAG RAC NAME

    ----------- ---------- ---------- ---------- ---------- ---------- ----------

    1683691 12 - 10007 121 LDE LME LCE LKE

    1684994 MAC MTE 10008 12-122

    1686296 12 - 10009 123 QAC QAQ

    2225222 9040 12 - 124

    To learn more about swivel, see the FAQ in the Forum: Re: 4. How can I convert rows to columns?

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

  • Report of update SQL query with line selector. Update process.

    I have a report of update SQL query with the selectors in line.
    How to identify line selector in a process update on the page.

    I want to update some columns with a value of an area of selection on the page.

    With the help of the base:

    UPDATE table_name
    SET Column1 = value
    WHERE some_column = some_value

    I would need to do:

    UPDATE table_name
    SET column1 =: P1_select
    WHERE [line selector] =?

    Now sure how to identify [line selector] and/or validate it is checked.
    Thank you
    Bob

    Identify the name of the checkbox of the source of the page element, it should be of the fxx format (f01, f02... f50).
    Suppose that we f01.

    for i in 1 .. apex_application.g_f01.count
    loop
      UPDATE CONTRACTS
      SET SIP_LOAD_FLAG = :P16_STATUS
      where  =  apex_application.g_f01(i); --i'th checked record' primary key
    end loop;
    
  • Can I connect more than one headset bluetooth with Apple TV 4?

    Can I connect more than one headset bluetooth with Apple TV 4?

    No, sorry. This is a limitation for all devices Bluetooth headset.

  • My music player has more than one entry for a song and when I buy a song or download to the reader I'm going to finish with three entrances.

    Original title: getting copied songs and resumes somehow

    Because of the settings or something my music player has more than one entry for a song... so when I buy a song or download from my phone to the player so I'll finish with three entries... on an album of 10 songs I get 30.  3 of each song... even with pictures... is it a setting or is there a way to automatically set the drive remove the redundant songs and photos?

    Hello

    1 Windows operating system you are using?

    2 are you facing issue with Windows media player?

    If you are facing the issue with Windows Media Player, you can try the following steps and check if it helps:

    Method 1:

    You can delete the Windows Media Player database and check if the problem persists.

    Step 1:

    a. exit Windows Media Player.

    b. click Start, click Run, type %userprofile%\Local Settings\Application Data\Microsoft\Media Player in start searchand then click OK.

    c. Select all files in the folder, and then click delete on the file menu.

    Note: you don't have to remove the folders that are in this folder.

    d. restart Windows Media Player.

    Note: Windows Media Player automatically rebuilds the database.

    If this does not resolve the problem, disable the Windows Media Player database cache files. To do this, follow these steps:

    Step 2:

    a. exit Windows Media Player.

    b. click Start, click Run, type %LOCALAPPDATA%\Microsoftand then click OK.

    c. Select the folder Media Playerand then click delete on the file menu.

    d. restart Windows Media Player.

    Note: Windows Media Player automatically rebuilds the database.

    For more information, see the article:

    Method 2:

    If you are using Windows 7, you can also try to launch Windows Media Player convenience stores on the library and check if it helps.
    Convenience store open in Windows Media Player library

    Method 3: How to prevent duplicateor entered invalid frombeing added to mylibrary during playback of music files?

    When you move digital media files on your computer, the file name and file path information remain unchanged in your library. Then when you select a file to play to its new location, a new entry is created in your library if you select the option automatically added to your library when played. As a result, your library can quickly contain a large number of entries, duplicate or invalid.

    To prevent it be automatically added to your library of music files
    a. in Windows Media Player, on the Tools menu, click on Options.
    b. on the Player tab, clear music to add to the library when played check box.
    Now, when you play music on your computer or the Internet, the file will not be added automatically to your library.

  • Apex 4 and more then a SQL query on a page update

    We know if 4 Apex has eliminated the restriction more then an update SQL query on a page?

    If you mean tabular forms, you can have one per page.

    -Sharon

  • Help setting up a SQL query with poor performance

    Hi all

    Database version: 10.2.0.5

    I'm working on a new report to view the top users by the number of calls. The table is truncated and filled again every month with records for the previous month; It contains approximately 400 000 records.

    I created a view with the columns needed for the report; also, the two functions of view calls to determine if a phone number is assigned to multiple staffs or several departments.

    It's full again table every month:

     CREATE TABLE "VOIP"."MONTHLY_BILLING_DETAILS" 
       (    "ID" NUMBER NOT NULL ENABLE, 
        "CDRRECORDTYPE" NUMBER, 
        "G_CALLMANAGERID" NUMBER, 
        "G_CALLID" NUMBER, 
        "O_LEGCALLIDENTIFIER" NUMBER, 
        "DATETIMEORIGINATION" NUMBER, 
        "O_NODEID" NUMBER, 
        "O_SPAN" NUMBER, 
        "O_IPADDR" NUMBER, 
        "CALLINGPARTYNUMBER" VARCHAR2(50 BYTE) NOT NULL ENABLE, 
        "CALLINGPARTY_USERID" VARCHAR2(128 BYTE), 
        "O_CAUSE_LOCATION" NUMBER, 
        "O_CAUSE_VALUE" NUMBER, 
        "O_PRECEDENCELEVEL" NUMBER, 
        "O_MEDIATRANSPORTADDR_IP" NUMBER, 
        "O_MEDIATRANSPORTADDR_PORT" NUMBER, 
        "O_MCAP_PAYLOADCAPABILITY" NUMBER, 
        "O_MCAP_MAXFRAMESPERPACKET" NUMBER, 
        "O_MCAP_G723BITRATE" NUMBER, 
        "O_VCAP_CODEC" NUMBER, 
        "O_VCAP_BANDWIDTH" NUMBER, 
        "O_VCAP_RESOLUTION" NUMBER, 
        "O_VIDEOTRANSPORTADDR_IP" NUMBER, 
        "O_VIDEOTRANSPORTADDR_PORT" NUMBER, 
        "O_RSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "O_RSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DESTLEGIDENTIFIER" NUMBER, 
        "DESTNODEID" NUMBER, 
        "DESTSPAN" NUMBER, 
        "DESTIPADDR" NUMBER, 
        "ORIGINALCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTY_USERID" VARCHAR2(128 BYTE), 
        "DESTCAUSE_LOCATION" NUMBER, 
        "DESTCAUSE_VALUE" NUMBER, 
        "DESTPRECEDENCELEVEL" NUMBER, 
        "DESTMEDIATRANSPORTADDR_IP" NUMBER, 
        "DESTMEDIATRANSPORTADDR_PORT" NUMBER, 
        "DESTMCAP_PAYLOADCAPABILITY" NUMBER, 
        "DESTMCAP_MAXFRAMESPERPACKET" NUMBER, 
        "DESTMCAP_G723BITRATE" NUMBER, 
        "DV_CAP_CODEC" NUMBER, 
        "DV_CAP_BANDWIDTH" NUMBER, 
        "DV_CAP_RESOLUTION" NUMBER, 
        "DV_TRANSPORTADDR_IP" NUMBER, 
        "DV_TRANSPORTADDR_PORT" NUMBER, 
        "DESTRSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "DESTRSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DATETIMECONNECT" NUMBER, 
        "DATETIMEDISCONNECT" NUMBER, 
        "LASTREDIRECTDN" VARCHAR2(50 BYTE), 
        "PKID" VARCHAR2(4000 BYTE), 
        "O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "CALLINGPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "LASTREDIRECTDNPARTITION" VARCHAR2(50 BYTE), 
        "DURATION" NUMBER, 
        "O_DEVICENAME" VARCHAR2(129 BYTE), 
        "DESTDEVICENAME" VARCHAR2(129 BYTE), 
        "O_CALLTERMINATION_BEHALF" NUMBER, 
        "DESTCALLTERMINATION_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECT_BEHALF" NUMBER, 
        "LASTREDIRECTREDIRECT_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECTREASON" NUMBER, 
        "LASTREDIRECTREDIRECTREASON" NUMBER, 
        "DESTCONVERSATIONID" NUMBER, 
        "G_CALLID_CLUSTERID" VARCHAR2(50 BYTE), 
        "JOIN_BEHALF" NUMBER, 
        "COMMENTS" VARCHAR2(2048 BYTE), 
        "AUTHCODEDESCRIPTION" VARCHAR2(50 BYTE), 
        "AUTHORIZATIONLEVEL" NUMBER, 
        "CLIENTMATTERCODE" VARCHAR2(32 BYTE), 
        "O_DTMFMETHOD" NUMBER, 
        "DESTDTMFMETHOD" NUMBER, 
        "CALLSECUREDSTATUS" NUMBER, 
        "O_CONVERSATIONID" NUMBER, 
        "O_MCAP_BANDWIDTH" NUMBER, 
        "DESTMCAP_BANDWIDTH" NUMBER, 
        "AUTHORIZATIONCODEVALUE" VARCHAR2(32 BYTE), 
        "OUTPULSEDCALLINGPARTYNUMBER" VARCHAR2(50 BYTE), 
        "OUTPULSEDCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "O_IPV4V6ADDR" VARCHAR2(64 BYTE), 
        "DESTIPV4V6ADDR" VARCHAR2(64 BYTE), 
        "O_VCAP_CODEC_CHAN2" NUMBER, 
        "O_VCAP_BANDWIDTH_CHAN2" NUMBER, 
        "O_VCAP_RESOLUTION_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "O_V_OCHANNEL_ROLE_CHAN2" NUMBER, 
        "DV_CAP_CODEC_CHAN2" NUMBER, 
        "DV_CAP_BANDWIDTH_CHAN2" NUMBER, 
        "DV_CAP_RESOLUTION_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "DV_CHANNEL_ROLE_CHAN2" NUMBER, 
        "DATE_CREATED" DATE, 
        "DATETIME_CONNECT" DATE, 
        "DATETIME_DISCONNECT" DATE, 
        "USERID_EMAIL_ADDRESS" VARCHAR2(100 BYTE), 
        "FROM_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "TO_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "FROM_EXCHANGE" VARCHAR2(7 BYTE), 
        "TO_EXCHANGE" VARCHAR2(20 BYTE), 
        "FROM_CITY" VARCHAR2(200 BYTE), 
        "FROM_STATE" VARCHAR2(2 BYTE), 
        "TO_CITY" VARCHAR2(200 BYTE), 
        "TO_STATE" VARCHAR2(2 BYTE), 
        "CALL_TYPE" VARCHAR2(10 BYTE), 
         CONSTRAINT "MONTHLY_BILLING_PK" PRIMARY KEY ("ID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 75497472 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX1" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX10" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("CALL_TYPE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX2" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX3" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_FULL_TELEPHONE", TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX4" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX5" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("TO_FULL_TELEPHONE","ORIGINALCALLEDPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX6" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TO_CHAR("DATETIME_CONNECT",'fmMONTH YYYY')) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX7" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("TO_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX8" ON "VOIP"."MONTHLY_BILLING_DETAILS" (NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX9" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    

    These are the functions to determine if a phone number is assigned to multiple staffs or departments:

    FUNCTION GET_EMPLOYEE_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_NAME EMPLOYEES.NAME%TYPE;
    BEGIN
      SELECT NAME
      INTO L_NAME
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_NAME;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_NAME := 'Multiple Employees';
        RETURN L_NAME;
      WHEN NO_DATA_FOUND THEN
        L_NAME := 'No Employee Assigned';
        RETURN L_NAME;
      WHEN OTHERS THEN
        NULL;
    END;
    

    FUNCTION GET_DEPARTMENT_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_DEPT_DESCR EMPLOYEES.DEPT_DESCR%TYPE;
    BEGIN
      SELECT DEPT_DESCR
      INTO L_DEPT_DESCR
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_DEPT_DESCR;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_DEPT_DESCR := 'Multiple Departments';
        RETURN L_DEPT_DESCR;
      WHEN NO_DATA_FOUND THEN
        L_DEPT_DESCR := 'No Department Assigned';
        RETURN L_DEPT_DESCR;
      WHEN OTHERS THEN
        NULL;
    END;
    

    This is the point of view that I'll use in the report:

    CREATE OR REPLACE FORCE VIEW "VOIP"."TOP_USERS_BY_CALLS_V" ("TOP_NO", "EMPLOYEE_NAME", "EMPLOYEE_DEPARTMENT", "PHONE_NUMBER", "QUANTITY_CALLS") AS 
      SELECT
      ROWNUM,
      VOIP_PKG.GET_EMPLOYEE_NAME(FROM_FULL_TELEPHONE),
      VOIP_PKG.GET_DEPARTMENT_NAME(FROM_FULL_TELEPHONE),
      FROM_FULL_TELEPHONE,
      QUANTITY_CALLS
    FROM (
    SELECT
      MBD.FROM_FULL_TELEPHONE,
      COUNT(1) QUANTITY_CALLS
    FROM
      MONTHLY_BILLING_DETAILS MBD
    WHERE
      MBD.FROM_FULL_TELEPHONE IS NOT NULL                                     AND
      MBD.FROM_FULL_TELEPHONE <> '000-000-0000'                               AND
      LENGTH(MBD.FROM_FULL_TELEPHONE) = 12                                    AND
      LENGTH(MBD.TO_FULL_TELEPHONE) = 12                                      AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN (SELECT AREA_CODE
                                                FROM NYNJ_METRO_AREA_CODES)   AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN ('800','822','833','844',
                                                '855','866','877','888')
    GROUP BY
      MBD.FROM_FULL_TELEPHONE
    ORDER BY
      QUANTITY_CALLS DESC
    )
    WHERE ROWNUM <= 100;
    

    Explain Plan output and Extended SQL Trace:


    SQL> 
    SQL> show parameter user_dump_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    user_dump_dest                       string      D:\ORACLEHOMES\ADMIN\RTS9\UDUM
                                                     P
    SQL> 
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     16
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2  sname
      3  , pname
      4  , pval1
      5  , pval2
      6  from
      7  sys.aux_stats$;
    
    SNAME                PNAME                     PVAL1 PVAL2
    -------------------- -------------------- ---------- --------------------
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          02-09-2009 15:46
    SYSSTATS_INFO        DSTOP                           02-09-2009 15:46
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW            1259.6206
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> explain plan for
      2  SELECT
      3    TOP_NO,
      4    EMPLOYEE_NAME,
      5    EMPLOYEE_DEPARTMENT,
      6    PHONE_NUMBER,
      7    QUANTITY_CALLS
      8  FROM
      9    TOP_USERS_BY_CALLS_V
     10  ORDER BY
     11    QUANTITY_CALLS DESC;
    
    Explained.
    
    Elapsed: 00:00:00.18
    SQL> 
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    33 rows selected.
    
    Elapsed: 00:00:00.82
    SQL> 
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.00
    SQL> 
    SQL> set autotrace traceonly arraysize 100
    SQL> 
    SQL> alter session set tracefile_identifier = 'mytrace1';
    
    Session altered.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> alter session set events '10046 trace name context forever, level 8';
    
    Session altered.
    
    Elapsed: 00:00:00.15
    SQL> 
    SQL> SELECT
      2    TOP_NO,
      3    EMPLOYEE_NAME,
      4    EMPLOYEE_DEPARTMENT,
      5    PHONE_NUMBER,
      6    QUANTITY_CALLS
      7  FROM
      8    TOP_USERS_BY_CALLS_V
      9  ORDER BY
     10    QUANTITY_CALLS DESC;
    
    100 rows selected.
    
    Elapsed: 00:10:37.68
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    Statistics
    ----------------------------------------------------------
            365  recursive calls
              0  db block gets
         689543  consistent gets
         212906  physical reads
              0  redo size
           5984  bytes sent via SQL*Net to client
            400  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    SQL> 
    SQL> disconnect
    

    Part of the automatic trace output:

    SELECT
      TOP_NO,
      EMPLOYEE_NAME,
      EMPLOYEE_DEPARTMENT,
      PHONE_NUMBER,
      QUANTITY_CALLS
    FROM
      TOP_USERS_BY_CALLS_V
    ORDER BY
      QUANTITY_CALLS DESC
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.43          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     24.70     635.81     212587     631823          0         100
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     24.70     636.25     212587     631823          0         100
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 148  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
        100  SORT ORDER BY (cr=689531 pr=212900 pw=0 time=636823070 us)
        100   VIEW  TOP_USERS_BY_CALLS_V (cr=689531 pr=212900 pw=0 time=642681672 us)
        100    COUNT STOPKEY (cr=631823 pr=212587 pw=0 time=635667026 us)
        100     VIEW  (cr=631823 pr=212587 pw=0 time=635666810 us)
        100      SORT ORDER BY STOPKEY (cr=631823 pr=212587 pw=0 time=635666493 us)
       2512       HASH GROUP BY (cr=631823 pr=212587 pw=0 time=635666125 us)
      27112        FILTER  (cr=631823 pr=212587 pw=0 time=519230237 us)
     315563         TABLE ACCESS BY INDEX ROWID MONTHLY_BILLING_DETAILS (cr=381523 pr=212587 pw=0 time=580209555 us)
     394473          INDEX FULL SCAN MONTHLY_BILL_INDEX3 (cr=2679 pr=2679 pw=0 time=26793918 us)(object id 206675)
     226627         INDEX FULL SCAN NYNJ_METRO_AREA_CODES_UK1 (cr=250300 pr=0 pw=0 time=3575488 us)(object id 206605)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file sequential read                    212587        0.20        611.67
      SQL*Net message from client                     2        0.00          0.00
      SQL*Net more data to client                     2        0.00          0.00
    ********************************************************************************
    

    DBMS_XPLAN. Output DISPLAY_CURSOR:

    SQL> 
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  1ut636vt58jdw, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */   TOP_NO,   EMPLOYEE_NAME,   EMPLOYEE_DEPARTMENT,   PHONE_NUMBER,   QUANTITY_CALLS FROM   TOP_USERS_BY_CALLS_V
    ORDER BY   QUANTITY_CALLS DESC
    
    Plan hash value: 826236322
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |      1 |        |    100 |00:09:56.06 |     689K|    210K|       |       |          |
    |   1 |  SORT ORDER BY                     |                           |      1 |      1 |    100 |00:09:56.06 |     689K|    210K| 13312 | 13312 |12288  (0)|
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |      1 |      1 |    100 |00:10:04.98 |     689K|    210K|       |       |          |
    |*  3 |    COUNT STOPKEY                   |                           |      1 |        |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |   4 |     VIEW                           |                           |      1 |      1 |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |      1 |      1 |    100 |00:09:54.88 |     631K|    210K|  6144 |  6144 | 6144  (0)|
    |   6 |       HASH GROUP BY                |                           |      1 |      1 |   2512 |00:09:54.88 |     631K|    210K|   821K|   821K| 1153K (0)|
    |*  7 |        FILTER                      |                           |      1 |        |  27112 |00:08:58.57 |     631K|    210K|       |       |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |      1 |      1 |    315K|00:08:57.07 |     381K|    210K|       |       |          |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |      1 |    934 |    394K|00:00:23.02 |    2679 |   2679 |       |       |          |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |    250K|      1 |    226K|00:00:03.47 |     250K|      0 |       |       |          |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( IS NULL)
       8 - filter((LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888'))
       9 - filter((LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000' AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL))
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    35 rows selected.
    
    Elapsed: 00:00:00.50
    SQL> 
    SQL> spool off
    
    

    Any help will be greatly appreciated. Please let me know if you need additional information.

    Thank you

    Erick

    ediazjorge wrote:

    Please let me know if you need additional information or do additional tests.

    Thanks again!

    Erick

    It's to you if you are satisfied or interested in improvements (if possible).

    If so the first thing I would like if you had your refreshed perspective as advised. According to expected area_code table cardinalities I doubt.

    So, if not cool off with dbms_stats.gather_table_stats on two tables, area_codes and MONTHLY_BILLING_DETAILS.

    Bottlenecks are now obviously the full table of MONTHLY_BILLING_DETAILS as well as the ANTI of LOOPS IMBRIQUEES scan.

    At the moment I don't think that an index of MONTHLY_BILLING_DETAILS will help a lot, because most of the lines will pass filter predicates, and because we need some columns in it, I have now I there will be gain a full index scan.

    I was surprissed that the optimizer pushes the substr <> predicates to both tables.

    So depending on your data, you might try

    1 make a factory of subquery select the two MONTHLY_BILLING_DETAILS columns that all directly apply predicates of membership and use it directly in the join instead of the table.

    or

    2. If all subtr to so are part of the table area_code choose in it using a subquery (or inline view) plant excluding these values.

    Both are attempts to get rid of the substr excluding as filters of join predicates.

    In fact, I was expecting a hash join anti as shown in the plan to explain instead of the nested loops anti, I expect to be more effective in this case.

    Perhaps with correct cardinalities the optimizier would understand himself.

    Just to test it, you can try the use_hash hint in the join:

    Select / * + USE_HASH (MBD, one) * /.

    ..

    OF MONTHLY_BILLING_DETAILS MBD,.

    NYNJ_METRO_AREA_CODES one

    (It's a good habit anyway usually use aliases and precede the names of columns. In the, it is easier to read queries are only trivial).

  • Rewrite the query with joins, and group by

    Hello

    It's an interview question.

    Table names: bookshelf_checkout
    virtual library

    And the join condition between these two tables is title

    We need to rewrite under request without using the join condition and group by clause?

    SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
               FROM bookshelf_checkout bc,bookshelf b
               WHERE bc.title(+)=b.title
               GROUP BY b.title;
    When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.

    Kindly help me on this.

    Thank you
    Suri

    Something like that?

      1  WITH books AS (
      2  SELECT 'title 1' title FROM dual UNION ALL
      3  SELECT 'title 2' FROM dual UNION ALL
      4  SELECT 'title 3' FROM dual ),
      5  bookshelf AS (
      6  SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
      7  SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
      8  SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
      9  SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
     10  UNION
     11  (SELECT b.title, NULL FROM books b
     12  MINUS
     13* SELECT bs.title, NULL FROM bookshelf bs)
    SQL> /
    
    TITLE   MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
    ------- ------------------------------------------------------------
    title 1                                                           14
    title 2                                                           44
    title 3
    

    Lukasz

  • Interactive report with checkbox and editable field

    Hello

    For a project I'm working on, I need to create an interactive report in Apex 3.2 with the ability to select rows and change one of the columns in the report.
    To do this, I started by adding these two fields at the request of my IR selection:

    CB apex_item. CheckBox (1, product_number)

    and

    apex_item. Text (2, QTY_TO_ORDER) QTY_TO_ORDER

    CB is the files checkbox and QTY_TO_ORDER is the editable field.

    It worked like a charm and I had my two fields in the report.
    To process the values, I've added this page process, which currently must store only the "product number" and the "QTY_TO_ORDER" fields in a table.

    BEGIN
    BECAUSE me in 1.APEX_APPLICATION. G_F01. Count LOOP
    insert into mytmptable values (APEX_APPLICATION. G_F01 (i), APEX_APPLICATION. G_F02 (i));
    END LOOP;
    commit;
    end;

    However, this does not work as I want it to work. When I check the boxes of the two rows, it will store two numbers of good product lines, but it will take the field QTY_TO_ORDER two albums from the table, regardless of who those are checked. I was able to solve this problem, by adding a rownum in the query and using the rownum as the value for the checkbox control. Because I still need that the areas of product_number and qty_to order I made them two text fields.

    I changed my page process of:

    BEGIN
    BECAUSE me in 1.APEX_APPLICATION. G_F01. Count LOOP
    insert into mytmptable values (APEX_APPLICATION. G_F02 (APEX_APPLICATION. G_F01 (i)),
    APEX_APPLICATION. G_F03 (APEX_APPLICATION. G_F01 (i)));
    END LOOP;
    commit;
    end;

    This seemed to solve the problem, and I have now received the good values in the table, unless I used in the report to sort... As soon as I've sorted the report in a different way from that of rownum, I had bad values in the table. The reason is of course that my insert simply selects the nth line in the table, and my rownums are not dynamic.

    I found a lot of examples on the internet using "#ROWNUM #" in the selection, which is expected to spawn a rownum in the report. It seems to work in normal report, but in interactive reports, literal values "#ROWNUM #" appears.

    Is it possible to fix this?

    Hello

    Try with 3 fields:

    CB apex_item. CheckBox (1, product_number).
    apex_item. Text (2, QTY_TO_ORDER) QTY_TO_ORDER,.
    prod_no apex_item. Hidden (3, product_number)

    The hidden field should be view as a hidden column.

    Then your process can be:

    BEGIN
    BECAUSE me in 1.APEX_APPLICATION. G_F01. Count LOOP
    J in 1.APEX_APPLICATION. G_F03. Count LOOP
    IF APEX_APPLICATION. G_F01 (i) = APEX_APPLICATION. G_F03 (j)) THEN
    insert into mytmptable values (APEX_APPLICATION. G_F01 (i), APEX_APPLICATION. G_F02 (j));
    "exit";
    END IF;
    END LOOP;
    END LOOP;

  • SQL query with the troubleshooting Subselects

    I have a query with the 3 Subselects. Each of the Subselects works very well on its own. I run the query in Oracle SQL Developer and get ORA 933 "sql command not completed successfully" at 47 48 line pass. I am unable to say what is causing the error. The pointers you know sincerely!

    Here is the code:
    SELECT 
      adjud.country,
      adjud.site,
      adjud.prodtype,
      sum(adjud.acount) + sum(denied.dcount) as TotalClosed,
      case when adjud.adtype = 'Paid' then adjud.acount End as NumPaid,
      case when adjud.adtype = 'Paid' then adjud.totalpaid End as AmtPaid,
      count(adjud.contest) + count(denied.contest) + count(pend.contest) as CntContestable,
      sum(pend.pcount) as PendingCount,
      Case when pend.overunder = 'Over' Then count(pend.pcount) End as Over90Count,
      sum(pend.facevalue) as PendingAmount
    From 
    ( select 
        count(clm.clm_nbr) as acount, 
        sum(clm.rsrv_amt) as facevalue,
        sum(clm.tot_pd_amt) as totalpaid,
        clm.prdt_type_nm as prodtype,
        clm.cntsbl_indc as contest,
        case when clm.exam_co_cd in ('107','134')
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        Case when clm.rmk_cd in ('R00', 'R01', 'R02') then 'Denied' Else 'Paid' End as adtype
      from afp_cds.claim_vw clm
      where 
        clm.adjud_dt is not null and 
        clm.adjud_dt > :startDate and
        clm.adjud_dt < :EndDate
      group by 
        clm.prdt_type_nm,
        clm.cntsbl_indc,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        Case when clm.rmk_cd in ('R00', 'R01', 'R02') then 'Denied' Else 'Paid' End
    ) as adjud, 
    ( select 
        count(clm.clm_nbr) as dcount,
        sum(clm.rsrv_amt) as facevalue,
        clm.prdt_type_nm as prodtype,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        clm.cntsbl_indc as contest
      from afp_cds.claim_vw clm
      where 
        clm.deny_dt is not null and
        clm.deny_dt > :startDate and
        clm.deny_dt < :EndDate
      group by
        clm.prdt_type_nm,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        clm.cntsbl_indc
    ) as denied,
    ( select 
        count(clm.clm_nbr) as pcount, 
        sum(clm.rsrv_amt) as facevalue,
        clm.prdt_type_nm as prodtype,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        clm.cntsbl_indc as contest,  
        case when sysdate - clm.regtrtn_dt > 90 then 'Over' else 'Under' End as overunder
      from afp_cds.claim_vw clm
      where
        clm.adjud_dt is null and
        clm.deny_dt is null
      group by
        clm.prdt_type_nm,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        clm.cntsbl_indc,  
        case when sysdate - regtrtn_dt > 90 then 'Over' else 'Under' End
    ) as pend
    
    where
      adjud.prodtype = denied.prodtype and
      adjud.country = denied.country and
      adjud.site = denied.site and
      adjud.contest = denied.contest and
      adjud.prodtype = pend.prodtype and
      adjud.country = pend.country and
      adjud.site = pend.site and
      adjud.contest = pend.contest 
    group by
      adjud.country,
      adjud.site,
      adjud.prodtype,
      case when adjud.adtype = 'Paid' then adjud.acount End,
      case when adjud.adtype = 'Paid' then adjud.totalpaid End,
      Case when pend.overunder = 'Over' Then count(pend.pcount) End

    Do not use "Sub" with the table alias.

    Change this stmt type:

    ) as adjud,
    

    TO

    ) adjud,
    
  • SQL query with dynamic exercise

    Hello

    I wrote this query with static exercise and exercise, I need info on making the dynamic variables

    Exercise: starts from July1st. This year up to June 30 is "2011" and July ' 1's '2012'
    Exercise: July1st his '1' and June ' 1 his '12'

    Query:

    Select distinct o.c_num, o.ac_num, s.sub_ac_num, o.fiscal_year, o.ac_exp_date, s.sub_ac_ind
    of org_account o
    outer join left sub_account s
    on o.c_num = s.c_num and o.ac_num = s.ac_num
    where (o.ac_exp_date > = CURRENT_DATE or o.ac_exp_date is null)
    and o.fiscal_year = * '2011' * -> need to be dynamic
    and o.fiscal_period = * '12' * -> need to be dynamic

    Thank you
    Mano

    Published by: user9332645 on June 2, 2011 18:55

    Hi, Mano,

    Welcome to the forum!

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
    Always tell what version of Oracle you are using.

    Since this is your first thread, I will post some examples of data for you:

    CREATE TABLE     table_x
    (     dt     DATE
    );
    
    INSERT INTO table_x (dt) VALUES (DATE '2010-12-31');
    INSERT INTO table_x (dt) VALUES (DATE '2011-01-01');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-02');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-30');
    INSERT INTO table_x (dt) VALUES (DATE '2011-07-01');
    

    What is the output you can from these data?

    DT          FISCAL_YEAR     FISCAL_PERIOD
    ----------- --------------- ---------------
    31-Dec-2010 2011            06
    01-Jan-2011 2011            07
    02-Jun-2011 2011            12
    30-Jun-2011 2011            12
    01-Jul-2011 2012            01
    

    If so, here's a way to get it:

    SELECT       dt
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'YYYY'
                )     AS fiscal_year
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'MM'
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    Since your exercise begins 6 months prior to the calendar year, you must add 6 months to the actual date for the fiscal year and month.

    The above query produces strings for fiscal_year and fiscal_period. If you prefer to have the numbers, then use EXTRACT instead of TO_CHAR:

    SELECT       dt
    ,       EXTRACT (      YEAR
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_year
    ,       EXTRACT (      MONTH
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    The first query will work in Oracle 6 (and more).
    I don't know when EXTRACT was introduced. Certainly, it works in Oracle 10 and may be available in older versions too.

  • why I can not go back more than once all of a sudden and double letters are not allowed?

    I have to reset the cursor to go back more than once and nothing can hit twice (the second will not be displayed) very very frustrated!

    Hello

    1. You did changes to the computer before the show?
    2. Is - this USB keyboard or wireless?
    3. What is the brand and model of the computer, the mouse and keyboard?
    4. What version of Windows are you using?
    5. The issue is limited to a particular application?

    Please follow the steps below.


    Method 1:
    Run the troubleshooter mentioned in the link below
    Windows Vista http://windows.microsoft.com/en-US/windows-vista/Troubleshoot-keyboard-problems

    Windows 7: http://windows.microsoft.com/en-US/windows7/Open-the-Hardware-and-Devices-troubleshooter

    Method 2: Check the boot issue.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135

    NOTE: After completing the troubleshooting steps, please reset the computer to start as usual (see the STEP 7 of the article mentioned below)

    I hope this helps!

  • View object has more than 2000 lines but with only 500

    Hi all

    I have a view object that has more than 2000 lines. But when I try to see the front end of data, it does is display only 500 records.

    Then when I did some research I discovered that there is a profile option where I need to increase the size.

    before the value in the profile Option (FND: display object Max size Fetch) amounted to 500

    Thus valued at 3000.

    But I wanted to know what will be the impact of the evolution of this profile option on Database/Application.


    Please advice which would be the best way to manage several size maximum extraction on the objects in view.

    Thank you.

    Not really sure what you mean by 'calculations are performed properly"If you are not able to see in the front.

    If you don't even have an option "next/previous" on the table to go to the next round?

    You can paste a screenshot?

    You can try to increase the property records of the region of the table and see what happens?

    Where did you add vo.setMaxFetchSize(-1)?

    Can you try replacing exwcuteQuery() and add the following inside that?

    See you soon

    AJ

  • Cannot download more than 2 MB doc with the af:inputFile component.

    Hi all
    I use af:inputFile to transfer a file.
    Whenever I am trying to load more than 2 MB of document its not allowing me to download the file with
    the document message size is big.

    Please give me some suggestion where should I make changes to the support of more than 2 mb download document.

    Find my code jspx download the doc.


    < af:popup id = "attachmentPopup" autoCancel = "disabled".
    contentDelivery = "lazyUncached".
    >
    < af:dialog title = "#{viewcontrollerBundle.ADD_ATTACHMENTS}" type = 'none' "
    ID = "uploadAttachmentPopupDlg".
    closeIconVisible = "true" >
    < af:panelGroupLayout / >
    < af:panelFormLayout >
    < af:panelGroupLayout partialTriggers = "uploadAttachmentBtn".
    >
    < af:inputFile label = "#{viewcontrollerBundle.FILE} ':" "
    value = "#{TestBean.file1} '"
    rendered = "#{TestBean.uploadAttachmentSuccessFlag} '"

    required = "true" / >
    < af:outputText value = "#{TestBean.validationMessage}" ' renditions = ' #{!} " TestBean.uploadAttachmentSuccessFlag}.
    partialTriggers = "uploadAttachmentBtn" / >
    < / af:panelGroupLayout >
    < / af:panelFormLayout >

    < f: facet name = "buttonBar" >
    < af:panelGroupLayout halign = "center" valign = "middle" partialTriggers = "uploadAttachmentBtn".
    layout = visible = "#{"horizontal"TestBean.uploadAttachmentSuccessFlag}" >
    < af:commandButton text = "#{viewcontrollerBundle.ATTACH_BTN}" = "true" partialSubmit "
    action = "#{TestBean.uploadAttachmentListener} '"
    ID = "uploadAttachmentBtn" / >

    < / af:panelGroupLayout >


    < / f: facet >

    < / af:dialog >
    < / af:popup >

    Thank you
    Arun.

    Set you this up in the web.xml file

      
        
        org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY
        
        512000
      
      
        
        org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE
        
        5120000
      
      
        
        org.apache.myfaces.trinidad.UPLOAD_TEMP_DIR
        
        /tmp/TrinidadUploads/
      
    

    Just put the values you need.

    Pedja

Maybe you are looking for