Oracle 10g - Set Operator Union Causing Timeout Network problem

Purpose is to get all of the customers not contacted given a starting date and current date(sysdate). The problem is a timeout issue because the query is inefficient. Example: A salesman has 6,946 rows returned from the cust table where his salesid =1163. Then the inner query:
‘SELECT count(Customer_ID) FROM cust_info WHERE info_type_id = 32’
returns 225505 rows just based on this info_type_record.
Next, ‘SELECT c.customer_id
  FROM customer c,
    event e
  WHERE c.salesperson_id = 1163
  AND e.eventdate BETWEEN '10-Feb-2010' AND TRUNC(SYSDATE)
  AND c.customer_id = e.customer_id
  GROUP BY c.customer_id’
Returns 231 rows
Finally, ‘SELECT c.customer_id
  FROM customer c,
    note n
  WHERE c.salesperson_id = 1163
  AND n.created_date_time BETWEEN '10-Feb-2010' AND TRUNC(SYSDATE)
  AND n.note_type_id IN (1,3,4)
  AND c.customer_id   = n.pk_id
  AND n.table_name    = 'CUSTOMER'
  GROUP BY c.customer_id’
Returns 399 rows.
How can I improve the structure of this query(see bottom)? The following is a sample data structure:
  CREATE TABLE "CUST "
   (     "CUST_ID" NUMBER,
     "SSN" VARCHAR2(9),
                  "SSN_TYP" NUMBER(1,0),
     "CREATED_DTE_TME" DATE,
     "FULLNAME" VARCHAR2(110),
     "F_NAME" VARCHAR2(35),
     "L_NAME" VARCHAR2(40),
     "BDTE" DATE,
     "DCEASED_DTE" DATE,
     "SALES_ID" NUMBER DEFAULT NULL,
     "BRNCH_ID" NUMBER,
     "HOME_BRNCH_ID" NUMBER,
     "TTL_ASSETS" NUMBER,
     "TTL_ASSETS_DTE" DATE,
     "NO_MAILINGS" NUMBER(1,0),
     "NO_CALLS" NUMBER(1,0) ) ;
  CREATE TABLE "CUST_INFO"
   (     "CUST_INFO_ID" NUMBER,
     "CUST_ID" NUMBER,
     "INFO_TYPE_ID" NUMBER ) ;
CREATE TABLE "EVENT"
   (     "EVENT_ID" NUMBER,
     "EVENTDATE" DATE,
     "CUST_ID" NUMBER,
     "SALES_ID" NUMBER,     
                  "EVENT_INFO" VARCHAR2(4000)  )
ENABLE ROW MOVEMENT ;
CREATE TABLE “NOTE"
   (     "NOTE_ID" NUMBER,
     "NOTE_TYPE_ID" NUMBER DEFAULT 0,
     "TABLE_NAME" VARCHAR2(50),
     "PK_ID" NUMBER,
     "CREATED_DTE_TME" DATE ) ;
INSERT INTO CUST VALUES(20151,'009529433',1,'01-MAY-5','FRENCH','D','M','01-DEC-01', '05-JUN-05',1163,
NULL,0,NULL,NULL,NULL,NULL)
INSERT INTO CUST_INFO VALUES (15,1001,32)
INSERT INTO EVENT VALUES (5,'05-MAY-05',1001,1163,'NONE')
INSERT INTO NOTE VALUES (100,2,'CUST',1001,TRUNC(SYSDATE))
SELECT CUST.CUST_ID,
  SSN,
  F_NAME,
  L_NAME,
  CREATED_DTE_TME ,
  TTL_ASSETS,
  BRNCH_ID,
  SALES_ID ,
  BDTE,
  SSN_TYP,
  FULLNAME,
  Home_BRNCH_ID ,
  No_Mailings,
  No_Calls,
  DCEASED_DTE,
  TTL_ASSETS_DTE
FROM CUST
WHERE SALES_ID          = 1163
AND CUST.CUST_ID NOT IN (
  (SELECT CUST_ID FROM cust_info WHERE info_type_id = 32
UNION
  (SELECT c.CUST_ID
  FROM CUST c,
    event e
  WHERE c.SALES_ID = 1163
  AND e.eventdate BETWEEN '10-Feb-2010' AND TRUNC(SYSDATE)
  AND c.CUST_ID = e.CUST_ID
  GROUP BY c.CUST_ID
UNION
  (SELECT c.CUST_ID
  FROM CUST c,
    note n
  WHERE c.SALES_ID = 1163
  AND n.CREATED_DTE_TME BETWEEN '10-Feb-2010' AND TRUNC(SYSDATE)
  AND n.note_type_id IN (1,3,4)
  AND c.CUST_ID   = n.pk_id
  AND n.table_name    = 'CUST'
  GROUP BY c.CUST_ID
AND CUST.ssn           IS NOT NULL
AND CUST.DCEASED_DTE IS NULL
{code}
Any guidance is appreciated!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

It’s not problem with SET operator. while you are using date field in where clause, U must use date conversion function, otherwise it will stuck there
Here is the right sql, U can try with this
SELECT cust.cust_id, ssn, f_name, l_name, created_dte_tme, ttl_assets,
brnch_id, sales_id, bdte, ssn_typ, fullname, home_brnch_id,
no_mailings, no_calls, dceased_dte, ttl_assets_dte
FROM cust
WHERE sales_id = 1163
AND cust.cust_id NOT IN (
(SELECT cust_id
FROM cust_info
WHERE info_type_id = 32)
UNION
((SELECT c.cust_id
FROM cust c, event e
WHERE c.sales_id = 1163
AND e.eventdate BETWEEN to_date('10-Feb-2010','dd-mon-rrrr') AND TRUNC (SYSDATE)
AND c.cust_id = e.cust_id
GROUP BY c.cust_id)
UNION
(SELECT c.cust_id
FROM cust c, note n
WHERE c.sales_id = 1163
AND n.created_dte_tme BETWEEN to_date('10-Feb-2010','dd-mon-rrrr') AND TRUNC
(SYSDATE)
AND n.note_type_id IN (1, 3, 4)
AND c.cust_id = n.pk_id
AND n.table_name = 'CUST'
GROUP BY c.cust_id)))
AND cust.ssn IS NOT NULL
AND cust.dceased_dte IS NULL;

Similar Messages

  • What cause searching network problem after updating iphone 6 from iOS 8.1.2 TO iOS 8.1.3?

    what cause searching network problem after updating iphone 6 from iOS 8.1.2 TO iOS 8.1.3?

    SSince Apple does not support downgrading the iOS I suggest you start a new question that gives a good title to a specific problem. Then in the body of the thread describe the problem in detail, tell us what steps you have tried so far to correct the problem, what happened, and what error messages you received.

  • Oracle 10g/11g - Operating system support info required

    I want to know all the operating systems supported by oracle 10g and 11g. I searched through oracle tech. center, but failed to find this information.
    I want to know if oracle (10g/11g) is supported on Linux S/390?
    Thanks
    Mac

    Did you go through the certification matrix?
    http://www.oracle.com/technology/support/metalink/index.html

  • [Debian] Oracle 10g Express - init.d start/stop script problem + fix

    I've experienced a problem with the init.d script "oracle xe" which is used to start/stop/reload the 10g server and comes with the debian package from oss.oracle.com.
    I noticed that after installing Oracle 10g in the "Debian" way (via .deb package and an apt-source oss.oracle.com), the start and stop method of the script doesn't do anything.
    It's checking for the value of the "ORACLE_DBENABLED" variable, which is on my installation set to "false", because I answered during installation false to the question "do you want to start Oracle 10g at system boot?".
    In my opinion that's wrong. I should always be able to start/stop the Oracle server trough the init.d script regardless of your choice starting Oracle at boot or not.
    I commented out row 604 and 621 in the file "/etc/init.d/oracle-xe" :
    case "$1" in
      start)
            if test -f "$CONFIGURATION"
            then
                    if test "$ORACLE_DBENABLED" != "true"
                    then
                            echo "exit"
    #                       exit 0
                    fi
            else
            echo "Oracle Database 10g Express Edition is not configured.  You must
                    exit 0
            fi
            start
      configure)
            configure
      stop)
            if test -f "$CONFIGURATION"
            then
                    if test "$ORACLE_DBENABLED" != "true"
                    then
                            echo "exit"
    #                       exit 0
                    fi
            else
            echo "Oracle Database 10g Express Edition is not configured.  You must
                    exit 0
            fi
            stop
            ;;

    Hello,
    I have the same problem on RH9.
    [root@phpsrv init.d]# ./oracle-xe start
    Starting Oracle Net Listener.
    /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/lsnrctl: relocation error: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/../lib/libclntsh.so.10.1: symbol semtimedop, version GLIBC_2.3.3 not defined in file libc.so.6 with link time reference
    Starting Oracle Database 10g Express Edition Instance.
    /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus: relocation error: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/../lib/libclntsh.so.10.1: symbol semtimedop, version GLIBC_2.3.3 not defined in file libc.so.6 with link time reference
    Failed to start Oracle Net Listener using /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/tnslsnr and Oracle Express Database using /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus.
    Regards,
    Pavel Kucera

  • Installing Oracle 10g rac on linux 4 using vmware :problem

    Hi Expert ,
    I'm facing problem on installing oracle 10g rac on centos 4x using vmware, installation is showing errors . The command failed are oifcfg, cluvfy
    on running ./cluvfy stage -post crsinst -n rac1,rac2
    error:
    OCR integrity found invalid for rac1
    OCR integrity found invalid for rac2
    Please advice...
    regards,
    Shaan

    hi Experts,
    orccheck failed for one of the node, can you please suggest what needs to be done now..
    filename :/dev/raw/raw1
    error "device/file integrity check failed"
    error "device not configured"
    Regards
    Message was edited by:
    Shaan_dmp

  • Testing  HTTP URL that causes a network problem

    Hi all,
    I'm developping an applet for multiple unlimited files downloading using HttpConnection .
    i want to implement the following feature :
    In the case of an error occurring due to network problems during file download; the applet must be able to reconnect and resume the data transfer without downloading the entire file(s).
    well i need to test this feature ; so i'm looking for some HTTP URL that can cause network probs so i can catch the error and retry connection etc...
    can someone point me where to find such HTTP files for my test ?
    thanks.

    >
    I can do this with FTP since it has commands to do
    this but I don't know of any using HTTP unless one
    uses a Servlet (or some other agent on the server) to
    process a download request for a file starting at
    some offset.
    Actually i did it only using HttpConnetion class and inputstream using some work arounds to keep track of the offset during download (actually i'm saving the offset to a temporary proprieties file that i'm reading again to get specific offset and resuming the download from last point)
    That is one way. You could also use an HTTP 'tunnel'
    that forwards all requests to an HTTP server but
    within the 'tunnel' you could at random close the
    connection.I will go for throwing exception manually ; but i'm curious to know how an HTTP tunnel works.
    thanks.

  • 10g Report to file causes unix permission problems

    I'm in the process of testing out one of the new options of 10g reports to have a report run from the command line and have the results file sent to a Unix directory for further use.
    Here is a sample of my run:
    http://myserver:port/reports/rwservlet?server=myreport_server+report=myreport.rep+userid=userid/pswd/@db+desformat=pdf+destype=file+desname=/tmp/my_report.pdf
    The results I see in the Unix directory are:
    rw-r--- 1 oracle dba my_report.pdf
    With the Unix permission set to 640, how does a user outside of the owner or group read this file. Is there a setting in a 10g environment variable somewhere to set the permissions to 644 so others can read the file?
    Thanks,
    Tom Vereecke

    Unfortunately i couldn't open your example as i only have LV 6.0, but i looked at the 'Save report to File.vi' in LV 6.0 and it basically only contains a 'Write characters to file.vi' for file handling. In LV 6.0 this vi does contain a 'Close file+.vi' which has an input called 'close when? (now:T)'. Make sure this is wired as True (default) and the file will close, and you should be able to delete the file (as long as the delete event occurs afterwards (make sure it is wired in sequence). In the LV help, it says the reason for the 'Write characters to file.vi' only closing if you tell it to (set as default) or if there is an error is so you can continually use it in a loop, writing characters to file, without closing, and then send a command to close
    it only on the last loop, or if there is an error. Therefore i dont think it is a bug, but i think there should be a wire for it on the 'Write characters to file.vi'.
    I hope this helps you..
    Kim

  • Suse 9 oracle 10g installation DHCP-assigned public IP addresses problem

    Hi,
    I got below error when I have tried to install Oracle 10gR2.
    I have checked # hostname, it is Ok. I setup network to use static Ip.
    I checked /etc/hosts. Does oracle get hostname another file?
    How can I solve my problem.
    Thanks.
    Recommendation: Oracle supports installations on systems with
    DHCP-assigned public IP addresses. However, the primary network
    interface on the system should be configured with a static IP
    address in order for the Oracle Software to function properly.
    See the Installation Guide for more details on installing the
    software on systems configured with DHCP.

    Hostname command should return the fully qualified hostname as shown below:
    % hostname
    hostname.domainname

  • Causing some network problem after connecting the new ASA to my network

    Hi everyone,
    Hope you can help on this issue.... It is strange to me...but may not be to you
    Currently, I have a subnet connects to my primary network. All the internet travel thru a router there in turn thru a pair of ASA failover firewall (ie Subet -> router -> Subnet ASA -> Pirmary network ASA -> Primary network router -> Internet).
    Now we try to setup a internet pipe so the subnet can go to internet by its own. So...for security purpose, we put another new ASA in between.the subnet and the new internet. This will be the first, and the old path to Interent would be the back up route.
    NOW
    I have not even make any route cahgnes on the router yet. What I did was to connect the new ASA to the subnet. Again, I do not change any routes, or any gateway settings on all the computers yet in the subnet!! I just connect the asa. That is it...please remember this.
    However, problem happens. I have a application server in the same subnet.... that keeps kick out users. I also have continuous ping to it... I saw that the server has requesdted time out...it did not come back up until about 10 to 20 seconds later. The server, in fact, is a cluster server. Although I can ping the physical server, I cannot ping the virutal server.
    In order to fix the problem, I really need to unplug the new ASA from the network, and reload the cluster server. Then it starts to work.
    ANother symptom is that...people complaint the log on is obviously slower than usual.
    May I ask why the new ASA will cuase this trouble?? Again, no routes on the router have been change. And all PCs in the subnet are still using old gateway, and did not nkow about the new ASA.
    Any ideas would be great!! Very strange to me. Thank you very much for your help.
    Riderfaiz

    First guest would be proxy ARP.
    Proxy ARP is enabled by default on the ASA. The new ASA might be proxy ARPing for whatever reason.
    OR the new ASA might have been configured with an ip address that belongs to another device by mistake.

  • Set operations usecase

    hi,
    I am a new bee and would like to understand the use of SET operations ( UNION, UNIONALL, MINUS, INTERSECTION) can't we do the same with the use of JOINS ? Am I wrong ? please correct me....and few examples where there is no alternate except using SET operations will help me to understand the thing more clearly...
    Thanks and regards
    mahesh.

    Documentation at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries004.htm#i2054381 might prove useful.

  • Creating Oracle service in Oracle 8i Client for Oracle 10g XE

    Hi all
    We tried Oracle 10g XE on one Machine X - OS Windows XP Professional SP2 , It had earlier Oracle 8i Client. It installed fine. It is wonderful and easy to install.
    Services started automatic for listner as well as OracleXE. We are able to create fresh Oracle Service in Oracle 8i client as well from the same machine X.
    Problem
    We are not able to create Oracle Service from another machine say Y which also has Oracle 8i client with the Oracle 10g XE service. We get TNS Problem error.
    Kindly guide as to how to make oracle service with OracleXE from some other machine. OracleXE does not install networking tools.
    Suresh Bansal

    Oracle XE doesn't install assistants such as dbca or netca, don't expect to find them, XE is a compact and limited oracle edition.
    >> We get TNS Problem error.
    Could you please further detail the tns error you got?
    ~ Madrid

  • How to do automatic start and shut  of Oracle 10g and listerner  on AIX 6

    Hi ,Please help ,how do we do automatic startup and shutdown of Oracle Database and Listener at System Reboot ,I am using Oracle 10G and operating system is AIX 6,Thanks

    Hi,
    Check this
    http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/strt_stp.htm#BGBJBAEI
    for more ref
    http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php
    Edited by: CKPT on Jan 7, 2011 1:11 PM

  • Email parameter for message part in oracle 10g

    hi..
    i m sending email using oracle 10g form , using desname , desformat , subject ,from
    it working successfully now i hv to add message body in that email like
    Dear Sir,
    Please find attachment.
    Thanks & Regards
    ABC
    there is destype ,desname ,desformat ,subject ,from in built parameter to set subject , from , to , format to send email , but i want to write message part is there any parameter in oracle 10g ??
    Thanks..

    Is your problem that you do not know how to send an email from Oracle 10g? If so then you use the UTL_MAIL package.
    Here's an example of calling it as part of a scheduler chain, not strictly what you're asking for but this lets you define success and failure steps and call each one based on the status of previous steps.
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM (
       program_name           =>'prg_Export_Success',
       program_type           =>'PLSQL_BLOCK',
       program_action         =>q'[BEGIN
                                    UTL_MAIL.SEND (
                                       sender      => 'who_its_from',
                                       recipients  => '[email protected]',
                                       subject     => 'subject line',
                                       message     => 'the message',
                                       mime_type   => 'text/plain; charset=us-ascii');
                                    END;]',
       number_of_arguments      => 0,
       enabled                  => TRUE,
       comments                 => 'Email success');
    end;
    BEGIN
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
       chain_name      =>  'Export',
       step_name       =>  'stp_EXPORT_SUCCESS',
       program_name    =>  'PRG_EXPORT_SUCCESS');
    END;
    /... then define appropriate rules.

  • Latest patchset for oracle 10g

    can any one provide me link to download latest patchset for Oracle 10g server

    Post Operating System (OS) name & version for DB server system.
    Post results of
    SELECT * from v$version

  • ORA-29278: SMTP transient error:421 Service not available on oracle 10g

    HIi,
    I am trying to send e-mails by using PL/Sql procedure . I am using UTL_MAIL/UTL_SMTP on oracle 10g R1 database.
    There is no problem in creating procedure,but when i am doing execution i am getting the mention error.
    I am trying to send mail with attachment as excel file.
    ORA-20001: The following error has occured: ORA-29278: SMTP transient error:
    421 Service not available
    ORA-06512: at "SCOTT.MAIL_ATT_RAW", line 64
    ORA-06512: at line 1
    -----my procedure code------
    CREATE OR REPLACE PROCEDURE mail_att_raw(filename varchar2) AS
    fil BFILE;
    file_len PLS_INTEGER;
    MAX_LINE_WIDTH PLS_INTEGER := 54;
    buf RAW(2100);
    amt BINARY_INTEGER := 2000;
    pos PLS_INTEGER := 1; /* pointer for each piece */
    filepos PLS_INTEGER := 1; /* pointer for the file */
    filenm VARCHAR2(50) := filename; /* binary file attachment */
    data RAW(2100);
    chunks PLS_INTEGER;
    len PLS_INTEGER;
    modulo PLS_INTEGER;
    pieces PLS_INTEGER;
    err_num NUMBER;
    err_msg VARCHAR2(100);
    resultraw RAW(32000);
    BEGIN
    /* Assign the file a handle */
    fil := BFILENAME('BFILE_DIR', filenm);
    /* Get the length of the file in bytes */
    file_len := dbms_lob.getlength(fil);
    /* Get the remainer when we divide by amt */
    modulo := mod(file_len, amt);
    /* How many pieces? */
    pieces := trunc(file_len / amt);if (modulo <> 0) then
    pieces := pieces + 1;end if;/* Open the file */
    dbms_lob.fileopen(fil, dbms_lob.file_readonly);/* Read the first amt into the buffer */
    dbms_lob.read(fil, amt, filepos, buf);/* For each piece of the file . . . */
    FOR i IN 1..pieces LOOP/* Position file pointer for next read */
    filepos := i * amt + 1;/* Calculate remaining file length */
    file_len := file_len - amt;/* Stick the buffer contents into data */
    data := utl_raw.concat(data, buf);/* Calculate the number of chunks in this piece */
    chunks := trunc(utl_raw.length(data) / MAX_LINE_WIDTH);/* Don't want too many chunks */
    IF (i <> pieces) THEN
    chunks := chunks - 1;
    END IF;/* For each chunk in this piece . . . */
    FOR j IN 0..chunks LOOP/* Position ourselves in this piece */
    pos := j * MAX_LINE_WIDTH + 1;/* Is this the last chunk in this piece? */
    IF (j <> chunks) THEN len := MAX_LINE_WIDTH;
    ELSE
    len := utl_raw.length(data) - pos + 1;
    IF (len > MAX_LINE_width) THEN
    len := MAX_LINE_WIDTH;
    END IF;
    END IF;/* If we got something, let's write it */
    IF (len > 0 ) THEN
    resultraw := resultraw || utl_raw.substr(data, pos, len);
    END IF;
    END LOOP;/* Point at the rest of the data buffer */
    IF (pos + len <= utl_raw.length(data)) THEN
    data := utl_raw.substr(data, pos + len);
    ELSE
    data := NULL;
    END IF;/* We're running out of file, only get the rest of it */
    if (file_len < amt and file_len > 0) then
    amt := file_len;
    end if;/* Read the next amount into the buffer */dbms_lob.read(fil, amt, filepos, buf);
    END LOOP;/* Don't forget to close the file */
    dbms_lob.fileclose(fil);
    SYS.UTL_MAIL.SEND_ATTACH_RAW(sender => '[email protected]', recipients => '[email protected]',subject => 'Testmail', message => 'Hallo', attachment => resultraw, att_filename => filename);
    EXCEPTION
    WHEN OTHERS THEN--dbms_output.put_line('Fehler');
    raise_application_error(-20001,'The following error has occured: ' || sqlerrm);
    END;
    Please suggest me what settings i need to change. This same procedure is running on another maching,but not on my machine.
    If somebody is having any other simple procedure ,please help me.
    My SMTP port -25
    Thanks in advance.

    Hi Justin,
    Please get the answers of your queries
    The error you're getting is coming from the SMTP server you are trying to connect to.
    - What SMTP server is your database configured to use?
    Reply - I am using IIS(5.0)
    - What SMTP server is the database where this code is working configured to use?
    Reply - Same IIS. Database is installed locally on my machine only. I am trying to send mail locally to me only,Not to the outside person.
    - Has the SMTP server been configured to allow connections from both machines?
    Reply - Yes
    One more query, do we really require to set the SMTP_OUT_SERVER parameter for SCOPE=BOTH
    ALTER SYSTEM SET smtp_out_server = '172.16.1.10' SCOPE=BOTH
    I am not able to set like this for BOTH,only for SPFILE i can set ?.
    My SMTP Server IP=172.16.1.10
    PORT- 25
    Thanks
    Manoj

Maybe you are looking for