Using a SQL for Oracle in Microsoft Excel Query

I am having the most difficult time (in fact, I can't get it to work) trying to use an SQL I created in Toad for Oracle. It works fine in Toad for Oracle...gives me all the data I need. I am trying to use it in Excel for users that don't know SQL or Oracle so they can use the query to extract data they need for Charts, Graphs, etc.
Here is the SQL code from Toad for Oracle:
/* Formatted on 2006/09/22 11:42 (Formatter Plus v4.8.6) */
SELECT a_compl_summary.incident_number, a_compl_summary.case_number,
       a_compl_summary.part_sequence, a_compl_summary.part_number,
       a_compl_summary.lot_number, a_compl_summary.alert_date,
       a_compl_summary.entry_date, a_compl_summary.NAME,
       a_compl_summary.MONTH, a_compl_summary.product_family,
       a_compl_summary.complaint, a_compl_summary.reportable,
       a_compl_summary.product_returned, a_compl_summary.case_desc,
       a_compl_summary.failure_invest_desc, a_compl_summary.lhr_search,
       a_compl_summary.root_cause, a_compl_summary.corrective_action,
       a_compl_summary.region,
       rp_qa_reported_device_codes.reported_device_code,
       rp_qa_reported_device_codes.reported_dev_clarification,
       rp_qa_reported_device_codes.reported_dev_code_desc,
       rp_qa_patient_codes.patient_code,
       rp_qa_patient_codes.patient_code_clarif,
       rp_qa_patient_codes.patient_code_severity,
       rp_qa_patient_codes.description
  FROM chsuser.a_compl_summary,
       chsuser.rp_qa_patient_codes,
       chsuser.rp_qa_reported_device_codes
WHERE (    (a_compl_summary.product_division = 'CP')
        AND (    a_compl_summary.entry_date >= :date1
             AND a_compl_summary.entry_date <= :date2
        AND (   a_compl_summary.product_family LIKE :pf1
             OR a_compl_summary.product_family LIKE :pf2
             OR a_compl_summary.product_family LIKE :pf3
             OR a_compl_summary.product_family LIKE :pf4
             OR a_compl_summary.product_family LIKE :pf5
        AND (a_compl_summary.region = :r1)
        AND (   a_compl_summary.NAME = :c1
             OR a_compl_summary.NAME = :c2
             OR a_compl_summary.NAME = :c3
             OR a_compl_summary.NAME = :c4
             OR a_compl_summary.NAME = :c5
        AND (a_compl_summary.complaint = :yorn)
        AND (   rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                          :cl1
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                          :cl2
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                          :cl3
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                          :cl4
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
                                                                          :cl5
        AND (rp_qa_reported_device_codes.reported_dev_clarification NOT LIKE
                                                                          :dc1
        AND (a_compl_summary.incident_number =
                                           rp_qa_patient_codes.incident_number
        AND (a_compl_summary.case_number = rp_qa_patient_codes.case_number)
        AND (a_compl_summary.part_sequence = rp_qa_patient_codes.part_sequence
        AND (a_compl_summary.incident_number =
                                   rp_qa_reported_device_codes.incident_number
        AND (a_compl_summary.case_number =
                                       rp_qa_reported_device_codes.case_number
        AND (a_compl_summary.part_sequence =
                                     rp_qa_reported_device_codes.part_sequence
        AND (rp_qa_reported_device_codes.incident_number =
                                           rp_qa_patient_codes.incident_number
        AND (rp_qa_reported_device_codes.case_number =
                                               rp_qa_patient_codes.case_number
        AND (rp_qa_reported_device_codes.part_sequence =
                                             rp_qa_patient_codes.part_sequence
       )Can someone help me...maybe point out what I'm doing wrong.
Note: I also tried creating this query in Microsoft Query (the simple way) and when I first create it...it works...But then if I go back in to edit the query, and refresh the query or try to Return data to Excel, it gives me a ORA-00936 error message.
Why it works when I first create the query in Excel, I don't know. But I have to validate the queries I'm creating (SQL or not) and I can't validate it if every time I go into edit the query (which may have to happen; that's why I have to fix this before I can submit my validation).
Anyway, any help would be greatly appreciated.

Okay, I know I'm replying to my own threads here...but I want to add a little bit more information again.
I was successful in figuring out that changing the :criteria to a ? worked.
I tested this on 1 criteria at a time. Adding one more scenario ? at at time.
It only worked up until about 3 scenarios of each criteria.
Then when I refreshed the query in Microsoft Excel Query, I got an "out of memory" error, and then it ended up just erasing the SQL I had been using.
Here's the SQL I had where it gave me this error. Am I possibly just making Excel work too hard? It just doesn't make sense because Toad for Oracle handled it in like 4 seconds. Which brings me back to an intial question I had. Can Excel use Toad for Oracle somehow?
Here's the code:
SELECT a_compl_summary.incident_number, a_compl_summary.case_number,
       a_compl_summary.part_sequence, a_compl_summary.part_number,
       a_compl_summary.lot_number, a_compl_summary.alert_date,
       a_compl_summary.entry_date, a_compl_summary.NAME,
       a_compl_summary.MONTH, a_compl_summary.product_family,
       a_compl_summary.complaint, a_compl_summary.reportable,
       a_compl_summary.product_returned, a_compl_summary.case_desc,
       a_compl_summary.failure_invest_desc, a_compl_summary.lhr_search,
       a_compl_summary.root_cause, a_compl_summary.corrective_action,
       a_compl_summary.region,
       rp_qa_reported_device_codes.reported_device_code,
       rp_qa_reported_device_codes.reported_dev_clarification,
       rp_qa_reported_device_codes.reported_dev_code_desc,
       rp_qa_patient_codes.patient_code,
       rp_qa_patient_codes.patient_code_clarif,
       rp_qa_patient_codes.patient_code_severity,
       rp_qa_patient_codes.description
  FROM chsuser.a_compl_summary,
       chsuser.rp_qa_patient_codes,
       chsuser.rp_qa_reported_device_codes
WHERE (    (a_compl_summary.incident_number =
                                           rp_qa_patient_codes.incident_number
        AND (a_compl_summary.case_number = rp_qa_patient_codes.case_number)
        AND (a_compl_summary.part_sequence = rp_qa_patient_codes.part_sequence
        AND (a_compl_summary.incident_number =
                                   rp_qa_reported_device_codes.incident_number
        AND (a_compl_summary.case_number =
                                       rp_qa_reported_device_codes.case_number
        AND (a_compl_summary.part_sequence =
                                     rp_qa_reported_device_codes.part_sequence
        AND (rp_qa_reported_device_codes.incident_number =
                                           rp_qa_patient_codes.incident_number
        AND (rp_qa_reported_device_codes.case_number =
                                               rp_qa_patient_codes.case_number
        AND (rp_qa_reported_device_codes.part_sequence =
                                             rp_qa_patient_codes.part_sequence
AND (a_compl_summary.product_division = 'CP')
        AND (    a_compl_summary.entry_date >= ?
             AND a_compl_summary.entry_date <= ?
        AND (   a_compl_summary.product_family LIKE ?
             OR a_compl_summary.product_family LIKE ?
             OR a_compl_summary.product_family LIKE ?
             OR a_compl_summary.product_family LIKE ?
             OR a_compl_summary.product_family LIKE ?
        AND (a_compl_summary.region = ?)
        AND (   a_compl_summary.NAME = ?
             OR a_compl_summary.NAME = ?
             OR a_compl_summary.NAME = ?
             OR a_compl_summary.NAME = ?
             OR a_compl_summary.NAME = ?
        AND (a_compl_summary.complaint = ?)
        AND (   rp_qa_reported_device_codes.reported_dev_clarification LIKE
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
             OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
        AND (rp_qa_reported_device_codes.reported_dev_clarification NOT LIKE
           ))

Similar Messages

  • Can we use Dynamic SQL in Oracle Reports ?

    Hi ,
    Can we use Dynamic SQL in Oracle Reports ?
    If yes please give some examples .
    Thanx
    srini

    I believe the built-in package SRW.Do_Sql is what you are looking for
    Example from the document:
    /* Suppose you want to create a "table of contents" by getting the
    ** first character of a columns value, and page number on which its
    ** field fires to print. Assume that you want to put the "table of
    contents"
    ** into a table named SHIP. You could write the following construct:
    DECLARE
    PAGE_NO NUMBER;
    PAGE_FOR INDEX NUMBER;
    SORT_CHAR CHAR(1);
    CMD_LINE CHAR(200);
    BEGIN
    SORT_CHAR := :SORT_NAME ;
    IF :CALLED = Y THEN
         SRW.GET_PAGE_NUM(PAGE_FOR_INDEX);
         SRW.USER_EXIT(RWECOP PAGE_FOR_INDEX
         P_START_PAGENO);
         SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO));
    END IF;
    SRW.GET_PAGE_NUM(PAGE_NO);
    CMD_LINE := INSERT INTO SHIP VALUES
                          (||SORT_CHAR||,||TO_CHAR(PAGE_NO)||);
    SRW.MESSAGE(2,CMD_LINE);
    SRW.DO_SQL(CMD_LINE);
    COMMIT;
    EXCEPTION
      WHEN DUP_VAL_ON_INDEX THEN
            NULL;
      WHEN SRW.DO_SQL_FAILURE THEN
            SRW.MESSAGE(1,FAILED TO INSERT ROW INTO SHIP TABLE);
      WHEN OTHERS THEN
           COMMIT;
    END;

  • Executing psadmin.sql for Oracle

    I am trying to insatll Peoplesoft using Oracle 10g Release2,Websphere,Tuxedo 9.1, PeopleTools 8.49 and FSCM9.0.
    I have successfully installed Oracle 10g, Websphere,Tuxedo,Peopletools and FSCM9.0.
    Now, when I am trying to create database from C:\PT8.49\setup\PsMpDbInstall\setup.exe, the Installer after asking the paths get stuck in "Executing psadmin.sql for Oracle" for more than 2 days.
    I read in other threads that some people could resolve this by running the scripts manually. If that is the solution can anyone please help me with the scripts in sequence.
    Thanks in advance!!!!

    Peoplesoft database wizard for Oracle was/is a quite buggy. You should follow the Peopletools Installation Guide for the manual installation tasks instead.
    All the steps can be found in the doc :
    http://download.oracle.com/docs/cd/E05406_01/psft/acrobat/hwtools849_itora.pdf
    If it is not clear, you can have a look to my blog (see my profile), I tried to explain simple as possible the main steps.
    Nicolas.

  • Could we use embedded SQL for XML in .pc ?

    Hi,
    Can we use embedded SQL for XML in .pc ?
    <1> assume we have run SQL statements in Oracle9i:
    SQL>create table MY_XML_TABLE
    (Key1 NUMBER,
    Xml_Column SYS.XMLTYPE);
    SQL>insert into MY_XML_TABLE(key1, Xml_Column) values
    (1, SYS.XMLTYPE.CREATEXML
    ('<book>
    <chapter num="1">
    <text>This is the my text</text>
    </chapter>
    <book>')
    <2> Could we directly translate it in .pc as usually:
    <outlined, not exactly)
    int emp_number = 1;
    XML_Data emprec; /* ?????? */
    EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
    INTO :emprec INDICATOR :emprec_ind
    FROM MY_XML_TABLE M
    WHERE Key1 = :emp_number;
    Thanks
    MJ

    reply by myself.
    No problem!!
    ===============================
    int emp_number = 1;
    struct emprec{
    char feature[1280]
    EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
    INTO :emprec INDICATOR :emprec_ind
    FROM MY_XML_TABLE M
    WHERE Key1 = :emp_number;

  • Why do we use reverse proxy for Oracle RAC Cluster setup

    Hello All,
                 I got this question lately.. "why do we use reverse proxy for Oracle RAC Cluster setup". I know we use the reverse proxy at Middleware level for multiple security reasons.
    Thanks..

    "why do we use reverse proxy for Oracle RAC Cluster setup".
    I wouldn't. I wouldn't use a proxy of any sort for the Cluster Interconnect for sure.
    Cheers,
    Brian

  • Should I use dynamic SQL for simple updates?

    Please tell me, out of the two options given below, which option should i use to update columns in a table and why?
    what will be the performance difference between the two approaches?
    Please note: The options given below is just for an example
    procedure proc1(var1 varchar2)
    is
    begin
    update tab1 set col1 = var1;
    commit;
    end;
    procedure proc1(var1 varchar2)
    is
    sqlstr varchar2(1000);
    begin
    sqlstr := 'update tab1 set col1 = :v1';
    execute immediate sqlstr using var1;
    commit;
    end;
    Thanks
    Arun

    Arun G Nath wrote:.
    Should I use dynamic SQL for simple updates? No way, not a chance.
    Performance is not the issue (as long as you are using bind variables).
    But with dynamic SQL, you loose compile time checking; you do not know until runtime if the SQL is valid.
    You also loose the dependency between proc1 and tab1, which can be found only if you search user_source.
    (And in either case, you probably want to remove the commit)
    Regards
    Peter

  • Delcare Cursor using Dynamic SQL using PL/SQL in Oracle 7.3.4

    In Oracle 7.3.4, can I declare a cursor at run time using Dynamic SQL. From the sample code in this website, it seems that Oracle 8 support this function. Please help. Thanks a lot.
    If I can do this on Oracle 7.3.4, could you give me some sample codes? Thanks.
    Regards,
    Raymond

    Hi,
    Try using the the following code where you can dynamically build the Valid Select stmt. and call that where ever you want.
    declare
    Type Cur_ref Is Ref Cursor;
    C_ref Cur_ref;
    V_Str Varchar2(100);
    V_Name Varchar2(100);
    Begin
    V_Str := 'Select Ename from Scott.emp Where empno = 7369';
    Open C_Ref for V_Str;
    Fetch C_ref Into V_Name;
    close C_Ref;
    dbms_output.put_line(V_Name);
    End;
    regards
    gaurav
    null

  • Errors using DBMS_SQLTUNE Advisors for Oracle 10g

    I get errors trying to tune the below query for Oracle 10g using the DBMS_SQLTUNE advisors.
    It happens when I wrap either a large block of PL/SQL code that uses bind variables or multiple nested subqueries with multiple JOIN conditions in a SELECT query statement that I wish to tune using the 10g SQLTUNE advisors.
    Message was edited by:
    benprusinski

    Hi, I was trying to use the DBMS_SQLTUNE package to tune my sql statements used in the huge procedure. I can successfully create a task and execute it. But when I run report tuning task, I'm always getting error like the one in below example. Two questions I have now.
    1) Is this becuase I'm using bind, but not passing any values?
    2) Can I able to use to this package to tune a procedures instead of sql statement?
    Example output...
    SQL&gt; SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'my_sql_tuning_task3')
    2 FROM DUAL;
    DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK3')
    GENERAL INFORMATION SECTION
    Tuning Task Name : my_sql_tuning_task3
    Tuning Task Owner : SCOTT
    Scope : COMPREHENSIVE
    Time Limit(seconds) : 3000
    Completion Status : COMPLETED
    Started at : 02/26/2009 21:44:41
    Completed at : 02/26/2009 21:44:41
    Number of Errors : 1
    DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK3')
    Schema Name: KPRAVEEN
    SQL ID : 479831s42xj1n
    SQL Text : SELECT a.pdrorn, a.pdrcto, a.pdrlln FROM f4311 a
    WHERE a.pddoco = receiptsrcrec.prdoco AND a.pddcto = :2 AND
    a.pdkcoo = :3 AND a.pdsfxo = :4 AND a.pdlnid = :5
    ERRORS SECTION
    SQL&gt;

  • Using JNDI Provider for Oracle JMS Queue

    Hello,
    I created a JMS Queue in Oracle 9.2.0.1 and would like
    a Java client to receive events from the Queue. I am
    not running Oracle9iAS. I have access to WebLogic server
    7.0 which is also a JNDI provider. Is there a sample code
    that shows the steps on how to go about this.
    thanks very much for any pointers.

    To define an Enterprise Message Source for AS JMS and OJMS in BAM, see Chapter 3 in the BAM Architect's User Guide.
    Specifying Settings for Oracle (AS JMS and OJMS)
    Settings for Oracle (AS JMS and OJMS) include:
    ■ Initial Context Factory.
    For 10.1.3: oracle.j2ee.rmi.RMIInitialContextFactory
    For 10.1.2: com.evermind.server.rmi.RMIInitialContextFactory
    ■ JNDI Service Provider URL. For standalone use oc4j: ormi://machine_name/
    where machine_name is the OC4J installed host, and for production use Application Server: opmn:ormi://<machine_name>:<opmn request port>:home where machine_name is the application server installed host, opmn request port could be found from looking at opmn.xml in <App server install location>/opmn/conf
    ■ TopicConnectionFactory Name.
    java:comp/resource/BAMTTT/TopicConnectionFactories/bam_ttq_tab
    ■ Topic Name. java:comp/resource/BAMTTT/Topics/bam_ttq
    ■ JMS Message Type. TextMessage.
    ■ Durable Subscriber Name. BAMFilteredSubscription
    ■ Message Selector. Message selector, for example, BAMFilter='true'
    ■ Client ID. ClientID
    You can also refer to:
    http://www.oracle.com/technology/products/integration/bam/10.1.3/TechNotes/TechNote_BAM_AQ_Configuration.pdf
    Regards, Stephen

  • Oracle to microsoft excel

    i would like to query a view and convert the result into microsoft excel(.xls) and store it in file system. Actually is it possible. If yes how? Immediate reply would be highy appreciated.
    Thanks in advance,
    shravan
    null

    Hi Try This.
    Select all the columns from a the table like...
    Select empno &#0124; &#0124; ',' &#0124; &#0124; ename &#0124; &#0124; ',' &#0124; &#0124; sal from emp;
    Spool this into mydata.csv ( Note the Ext)
    Then Open the file in excel.
    When u give SQLPLUS in the cmd like use sqlplus -s.
    U Can also try UTL_FILE
    Regards,
    Ganesh R

  • Mix Local and Global Transaction using XA Driver for Oracle

    Hi all,
    We are trying to use a XA Driver which can support both local as well as global
    transaction. We tried using the Weblogic jDriver (XA Driver) type 2 that comes
    along with Weblogic installation but unfortunaltely it cannot mix local as well
    as global transaction.
    Please let me know in case we have any XA JDBC driver for Oracle Database which
    supports both local and global transaction together.
    Thnx,
    Kumar
    Environment:
    Weblogic 8.1 server
    Database used : Oracle8i

    Most database drivers can support local and global transactions, with some
    restrictions.
    The JDBC spec has been changed to require compliant drivers to let the
    application
    know if they try to start a global transaction while a local transaction has
    not been
    completed (or vice verse). So most of the database drivers have been
    changed to enforce
    this restriction (breaking a lot of code that is out there).
    "Kumar Raman" <[email protected]> wrote in message
    news:4033457c$[email protected]..
    >
    Hi all,
    We are trying to use a XA Driver which can support both local as well asglobal
    transaction. We tried using the Weblogic jDriver (XA Driver) type 2 thatcomes
    along with Weblogic installation but unfortunaltely it cannot mix local aswell
    as global transaction.
    Please let me know in case we have any XA JDBC driver for Oracle Databasewhich
    supports both local and global transaction together.
    Thnx,
    Kumar
    Environment:
    Weblogic 8.1 server
    Database used : Oracle8i

  • Using native sql for update

    Hello ,
    I have a reqaust to update a db table declared "outside" our R3 db.
    I mennage to select the data using native sql with a connection to the db.
    Now i need to modify the data on the db.
    Is there a similliar command like "fetch next" ' for update?
    Mybe i need to build a procedure in th "host" db and use its own commands to update?
    Thanks,
    koby

    Hello Kobi,
    Which release of SAP are you woking on?
    If you're on ECC6.0, instead you using Native SQL to call the stored procs of external DBs you can use the [ADBC APIs |http://help.sap.com/abapdocu_702/en/abenadbc_procedure.htm](CL_SQL* classes).
    BR,
    Suhas

  • What legal requirements for releasing an Microsoft Excel add-in?

    Hello,
    We developed an application to be released as a Microsoft Excel add-in. What are the legal requirements for releasing an add-in? We are located in Manitoba, Canada.
    Kurt Jakob,
    C.E.T.
    Certified Engineering Technologist
    Horizon Innovations

    You are free to release the add-in any way you want - for free or commercially. There are no legal requirements.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Most widely used operating system for oracle database

    hi,
    can anyone figure out which operating system is widely used for oracle database around the world.
    thanks and regards,
    Ashok

    I don't think you can safely pick one single operating system for Oracle.
    Over the years I have seen various Unix flavors, VAX/VMS, Windows and others being used to a great extent for running Oracle database.
    Picking one flavor will be tougher then having to program the database under any operating system it is made available.

  • SQL for oracle Reports

    Hi, I am having trouble developing an oracle report to return information from several tables. The information to be returned is an aggregate operator "Count" and several fields from the tables. I cannot get the sql to compile without error.
    Does anyone know of a good website for oracle reports design with sql?

    Hi,
    Why not paste the SQL code along with the
    error or send it to : [email protected]
    Naresh
    null

Maybe you are looking for

  • Kernel Upgrade on Windows

    Hello, While performing Kernel Upgrade (4.7 Enterprise Edition), I noticed that the in the system the following 2 directories have the same kernel files G:\usr\sap\B47\SYS\exe\run G:\usr\sap\B47\SYS\exe\nuc\NtIntel There can't be 2 kernel directories

  • ORA-00600: internal error code, arguments:[k2gUGPC: ptcnt = tcnt] in 11gR2

    Dear Friends, we are using 11.2.0.2 RAC database (e-biz database) on solaris sparc (64 bit) and we are getting errors on alert log: ORA-00600: internal error code, arguments: [k2gUGPC: ptcnt >= tcnt], Please let me know the fix. Recent Change: Upgrad

  • Brushes grayed out on Aperture3

    I purchased & downloaded Aperture3 from the Apple store and all the brushes are grayed out and I can't access them. How do I correct this problem?

  • Making a checkerboard image

    I use Elements 3. I would like to fill a 8.5 X 11 white canvas with 12 to 15 to 20 individual images, side by side, etc. (like on a checkerboard). Each of my images is approximately 3000 X 2000 pixels. Is there a good way (and a quicker way) to do th

  • Relation between undo_retention and undo tablepsace size

    Hello,i am on 10.2.0.3. Can someone please clear this things a little bit. Let's say that i have one SQL that is doing inserts or updates and this have execution time of 30 minutes, and my undo_retention parameter is set to 20mins, undo_management=au