Oracle database parallel query

Hello,
I am trying to execute a pararallel query in oracle oracle database 10g but it is not working. please see the below server settings and explain plan.
NAME                                 TYPE        VALUE
fast_start_parallel_rollback         string      LOW
parallel_adaptive_multi_user         boolean     TRUE
parallel_automatic_tuning            boolean     TRUE
parallel_execution_message_size      integer     4096
parallel_instance_group              string
parallel_max_servers                 integer     40
parallel_min_percent                 integer     0
parallel_min_servers                 integer     0
parallel_server                      boolean     TRUE
parallel_server_instances            integer     2
parallel_threads_per_cpu             integer     2
xplain plan of SELECT  /*+ PARALLEL(a, 2) */  *  FROM  prt_sales_disc_matrix  where sdm_crt_user='sys'
Plan
SELECT STATEMENT ALL_ROWS Cost: 89,113 Bytes: 144 Cardinality: 1
1 TABLE ACCESS FULL TABLE PRISM.PRT_SALES_DISC_MATRIX Cost: 89,113 Bytes: 144 Cardinality: 1

Apart from the important syntactical error which sb has highlighted, the parallel hint does not mandate that the statement is run in parallel.
http://jonathanlewis.wordpress.com/2007/06/17/hints-again/

Similar Messages

  • Oracle error-parallel query

    Hi Experts,
    While i'm running a parallel query through a procedure...
    its throwing the below error.....
    when others Error ORA-12801: error signaled in parallel query server P006
    ORA-01114: IO error writing block to file  (block # )
    ORA-01114: IO error writing block to file 1025 (block # 2790848)
    ORA-27063: number of byte with query
    Can you people suggest me?
    Thanks in advance!!!

    You probably meant 11.2.0.3 instead of 11.2.3.0?
    Did you (or your DBA) check the alert log?
    What happens if you remove your WHEN OTHERS and rerun the code?
    Do you get any additional information?

  • Is there any difference in oracle database and forms database

    i want to know is there any difference in oracle database and forms 6i database
    ,if i import some file through oracle database then same data will exist in forms database or not
    thanks

    Oracle Forms is a Rapid Application Development (RAD) tool not a database. With Forms, you connect to an Oracle database to query and display data from the database as well as insert new or update existing data. Consequently, if exists in the database - you should be able to display it in a Form.
    Craig...

  • How can i query oracle database data to xml file with c++?

    I want query data to xml file directly in my c++ application .
    I know the oracle XSU provide interferce for query data to xml
    file directly.
    But XSU for oracle8i does not support c++.
    I do not know if XSU for oracle9i support c++.
    can you tell me?
    If i do not use XSU to finish my applicayion.
    what interface that oracle provide can help me do my work?
    thank you !

    BTW why do you want to migrate oracle database data to db2 database? Any specific project requirement like Parallel run with Oracle database (e.g data replication)? Or any other issues - Cost? Manageability? Availability? Business requirements?
    Do you need to do a day-to-day data transfer or it is for permanent migration?

  • Database stopped with Error:ORA-10388: parallel query server interrupt (fai

    Hi Team,
    My Oracle 10g Database stopped automatically. When i checked the alert log i found the below Errors:
    Errors in file /opt/oracle/admin/DWS/bdump/dws_p000_10374.trc:
    ORA-10388: parallel query server interrupt (failure)
    Fri Mar 2 18:55:18 2012
    SMON: Restarting fast_start parallel rollback
    Fri Mar 2 18:55:47 2012
    Thread 1 advanced to log sequence 384310 (LGWR switch)
    Current log# 3 seq# 384310 mem# 0: +DBDG/dws/onlinelog/group_3.259.733426831
    Fri Mar 2 18:57:48 2012
    Errors in file /opt/oracle/admin/DWS/bdump/dws_p000_10374.trc:
    ORA-10388: parallel query server interrupt (failure)
    Fri Mar 2 18:57:49 2012
    Errors in file /opt/oracle/admin/DWS/bdump/dws_smon_10337.trc:
    ORA-00600: internal error code, arguments: [6006], [1], [], [], [], [], [], []
    Fri Mar 2 19:18:31 2012
    Errors in file /opt/oracle/admin/DWS/bdump/dws_pmon_10277.trc:
    ORA-00474: SMON process terminated with error
    Fri Mar 2 19:18:31 2012
    PMON: terminating instance due to error 474
    ======================================================================
    A week before we stopped oracle using "Shutdown abort" command. But two days before we stopped using "shutdown immediate", it went fine and system up and run fine.
    But today it stopped with this error message.
    Operating system : SOlaris 10
    I changed the parameter parameter fast_start_parallel_rollback to HIGH from LOW, but no use
    SQL> ALTER SYSTEM SET FAST_START_PARALLEL_ROLLBACK=HIGH SCOPE=BOTH;
    System altered.
    SQL> show parameter fast_start_parallel_rollback
    NAME TYPE VALUE
    fast_start_parallel_rollback string HIGH
    Usually The dead transaction will be rolled back after raising the Priority from LOW to HIGH. But this time its not rolled back. still etting the same error.
    Your answers will help to stop the oracle getting down in the LIVE production server. please share your experience guys.
    Thanks and Regards,
    Deeban

    Hi,
    Here im pasting the Trace file content for the error "ORA-00600: internal error code, arguments: [6006], [1], [], [], [], [], [], []".
    [10:20pm] root@dws41: # cat /opt/oracle/admin/DWS/bdump/dws_pmon_10277.trc
    /opt/oracle/admin/DWS/bdump/dws_pmon_10277.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /opt/oracle/product/10.2.0
    System name: SunOS
    Node name: dws41
    Release: 5.10
    Version: Generic_138888-06
    Machine: sun4u
    Instance name: DWS
    Redo thread mounted by this instance: 1
    Oracle process number: 3
    Unix process pid: 10277, image: oracle@dws41 (PMON)
    **** 2012-03-02 19:18:31.509*
    **** SERVICE NAME:(SYS$BACKGROUND) 2012-03-02 19:18:31.504*
    **** SESSION ID:(1511.1) 2012-03-02 19:18:31.504*
    Background process SMON found dead
    Oracle pid = 8
    OS pid (from detached process) = 10337
    OS pid (from process state) = 10337
    dtp = 380017a10, proc = 7fd001048
    Dump of memory from 0x0000000380017A10 to 0x0000000380017A58
    380017A10 0000007C 00000000 00000007 FD001048 [...|...........H]
    380017A20 00000000 00000000 00000000 534D4F4E [............SMON]
    380017A30 00020000 00000000 00002861 00000000 [..........(a....]
    380017A40 00000000 4F507D38 00000001 327FA838 [....OP}8....2..8]
    380017A50 00040081 00000000 [........]
    Dump of memory from 0x00000007FD001048 to 0x00000007FD001830
    7FD001040 02010000 00000000 [........]
    7FD001050 00000000 00000000 00000000 00000000 [................]
    7FD001060 00000000 00000000 00000007 FD6D0CD0 [.............m..]
    7FD001070 00000007 FD700328 00000007 FD546D78 [.....p.(.....Tmx]
    7FD001080 00000005 3C6FD110 00000000 00000000 [....<o..........]
    7FD001090 00000005 3C6FD198 00000005 3C6FD198 [....<o......<o..]
    7FD0010A0 00000007 FD700318 01160800 00000000 [.....p..........]
    7FD0010B0 00000007 FD53FF88 00000007 FD544698 [.....S.......TF.]
    7FD0010C0 00000008 00000000 00000000 00000000 [................]
    7FD0010D0 00000000 00000000 00000000 00000000 [................]
    7FD0010E0 00000007 FD6CE770 00000007 FD6D0D00 [.....l.p.....m..]
    7FD0010F0 00000000 00000000 00000000 00000000 [................]
    Repeat 3 times
    7FD001130 00000000 00000000 00000012 00000000 [................]
    7FD001140 00000000 00000000 0000000F 00000000 [................]
    7FD001150 00000000 00000000 00000012 00000000 [................]
    Repeat 1 times
    7FD001170 00000000 00000000 0000000F 00000000 [................]
    Repeat 1 times
    7FD001190 00000000 00000000 00000012 00000000 [................]
    Repeat 1 times
    7FD0011B0 00000000 00000000 0000000E 00000000 [................]
    7FD0011C0 00000000 00000000 00000008 00000000 [................]
    7FD0011D0 00000000 00000000 00000012 00000000 [................]
    7FD0011E0 00000000 00000000 00000000 00000000 [................]
    Repeat 2 times
    7FD001210 00000000 00000000 00000004 00000000 [................]
    7FD001220 00000000 00000000 00000000 00000000 [................]
    7FD001230 4F50FF9A 00000000 00000000 00000000 [OP..............]
    7FD001240 00000000 00000000 00000000 00000000 [................]
    Repeat 1 times
    7FD001260 00000007 FD001260 00000007 FD001260 [.......`.......`]
    7FD001270 00000000 00000000 00000000 FFFFFFFF [................]
    7FD001280 00000007 FD001280 00000007 FD001280 [................]
    7FD001290 00000000 00000000 00000005 00000000 [................]
    7FD0012A0 00000000 00000000 00000000 00000000 [................]
    7FD0012B0 000000AB BABCDEFA 00000000 00000000 [................]
    7FD0012C0 00000000 00000000 000000FF 7FFFC971 [...............q]
    7FD0012D0 00000021 00000026 0008CBAA 00039976 [...!...&.......v]
    7FD0012E0 00000005 3C003FB8 00000006 7E0037D0 [....<.?.....~.7.]
    7FD0012F0 00000001 00000000 00000000 00000000 [................]
    7FD001300 00000000 00000000 00000000 00000000 [................]
    Repeat 1 times
    7FD001320 00000000 00000000 00002861 00000000 [..........(a....]
    7FD001330 00000000 00000000 00000000 00000000 [................]
    Repeat 2 times
    7FD001360 00000000 00000000 00000007 FD001048 [...............H]
    7FD001370 00000000 00000000 00000000 00000000 [................]
    Repeat 4 times
    7FD0013C0 00000000 00000000 00000001 00000000 [................]
    7FD0013D0 00000000 00000000 00000000 00000000 [................]
    Repeat 1 times
    7FD0013F0 4F50FF9A 00000000 00000007 FD0013F8 [OP..............]
    7FD001400 00000007 FD0013F8 00000000 00000000 [................]
    7FD001410 00010000 00000000 00000000 01000057 [...............W]
    7FD001420 0000000C 00000000 00002861 00000000 [..........(a....]
    7FD001430 00000000 4F507D38 00000001 00000000 [....OP}8........]
    7FD001440 00000000 00000000 00000000 00000000 [................]
    Repeat 3 times
    7FD001480 0000000F FFFFFFFF 00000000 00000000 [................]
    7FD001490 00000000 00000000 00000000 00000000 [................]
    Repeat 2 times
    7FD0014C0 00000000 00000000 00000020 00000000 [........... ....]
    7FD0014D0 00000000 00000000 00000000 00000000 [................]
    Repeat 8 times
    7FD001560 00000000 00000000 6F726163 6C650000 [........oracle..]
    7FD001570 00000000 00000000 00000000 00000000 [................]
    7FD001580 00000000 00000000 00000000 00000006 [................]
    7FD001590 64777334 31000000 00000000 00000000 [dws41...........]
    7FD0015A0 00000000 00000000 00000000 00000000 [................]
    Repeat 2 times
    7FD0015D0 00000000 00000005 554E4B4E 4F574E00 [........UNKNOWN.]
    7FD0015E0 00000000 00000000 00000000 00000000 [................]
    7FD0015F0 00000000 00000000 00000000 00000008 [................]
    7FD001600 31303333 37000000 00000000 00000000 [10337...........]
    7FD001610 00000000 00000000 00000000 00000005 [................]
    7FD001620 6F726163 6C654064 77733431 2028534D [oracle@dws41 (SM]
    7FD001630 4F4E2900 00000000 00000000 00000000 [ON).............]
    7FD001640 00000000 00000000 00000000 00000000 [................]
    7FD001650 00000000 00000013 00000000 00000002 [................]
    7FD001660 00000000 00000000 00000000 00000000 [................]
    Repeat 9 times
    7FD001700 00000000 00020000 00000000 00000000 [................]
    7FD001710 00000000 00000000 00000000 00000000 [................]
    7FD001720 00000003 BD4FFA28 00000005 3C0026F8 [.....O.(....<.&.]
    7FD001730 00000006 7E000F40 00000000 00000000 [....~..@........]
    7FD001740 00000003 BC691FD8 00000000 00000000 [.....i..........]
    7FD001750 00000000 00000000 00000000 00000000 [................]
    7FD001760 00000000 00000000 00000007 FD001768 [...............h]
    7FD001770 00000007 FD001768 00000000 09EF0000 [.......h........]
    7FD001780 00000000 086F0000 00000000 017A17D9 [.....o.......z..]
    7FD001790 00000000 00273A49 00000000 13B817D9 [.....':I........]
    7FD0017A0 00000000 00015030 00000000 0000A848 [......P0.......H]
    7FD0017B0 00000000 001350A0 00000000 00000828 [......P........(]
    7FD0017C0 00000000 000000E0 00000000 00000828 [...............(]
    7FD0017D0 00000000 00000000 00000000 00000000 [................]
    Repeat 4 times
    7FD001820 32B310E7 000152FB 00000003 00000000 [2.....R.........]
    error 474 detected in background process
    ORA-00474: SMON process terminated with error
    [10:20pm] root@dws41: #

  • Query in timesten taking more time than query in oracle database

    Hi,
    Can anyone please explain me why query in timesten taking more time
    than query in oracle database.
    I am mentioning in detail what are my settings and what have I done
    step by step.........
    1.This is the table I created in Oracle datababase
    (Oracle Database 10g Enterprise Edition Release 10.2.0.1.0)...
    CREATE TABLE student (
    id NUMBER(9) primary keY ,
    first_name VARCHAR2(10),
    last_name VARCHAR2(10)
    2.THIS IS THE ANONYMOUS BLOCK I USE TO
    POPULATE THE STUDENT TABLE(TOTAL 2599999 ROWS)...
    declare
    firstname varchar2(12);
    lastname varchar2(12);
    catt number(9);
    begin
    for cntr in 1..2599999 loop
    firstname:=(cntr+8)||'f';
    lastname:=(cntr+2)||'l';
    if cntr like '%9999' then
    dbms_output.put_line(cntr);
    end if;
    insert into student values(cntr,firstname, lastname);
    end loop;
    end;
    3. MY DSN IS SET THE FOLLWING WAY..
    DATA STORE PATH- G:\dipesh3repo\db
    LOG DIRECTORY- G:\dipesh3repo\log
    PERM DATA SIZE-1000
    TEMP DATA SIZE-1000
    MY TIMESTEN VERSION-
    C:\Documents and Settings\dipesh>ttversion
    TimesTen Release 7.0.3.0.0 (32 bit NT) (tt70_32:17000) 2007-09-19T16:04:16Z
    Instance admin: dipesh
    Instance home directory: G:\TimestTen\TT70_32
    Daemon home directory: G:\TimestTen\TT70_32\srv\info
    THEN I CONNECT TO THE TIMESTEN DATABASE
    C:\Documents and Settings\dipesh> ttisql
    command>connect "dsn=dipesh3;oraclepwd=tiger";
    4. THEN I START THE AGENT
    call ttCacheUidPwdSet('SCOTT','TIGER');
    Command> CALL ttCacheStart();
    5.THEN I CREATE THE READ ONLY CACHE GROUP AND LOAD IT
    create readonly cache group rc_student autorefresh
    interval 5 seconds from student
    (id int not null primary key, first_name varchar2(10), last_name varchar2(10));
    load cache group rc_student commit every 100 rows;
    6.NOW I CAN ACCESS THE TABLES FROM TIMESTEN AND PERFORM THE QUERY
    I SET THE TIMING..
    command>TIMING 1;
    consider this query now..
    Command> select * from student where first_name='2155666f';
    < 2155658, 2155666f, 2155660l >
    1 row found.
    Execution time (SQLExecute + Fetch Loop) = 0.668822 seconds.
    another query-
    Command> SELECT * FROM STUDENTS WHERE FIRST_NAME='2340009f';
    2206: Table SCOTT.STUDENTS not found
    Execution time (SQLPrepare) = 0.074964 seconds.
    The command failed.
    Command> SELECT * FROM STUDENT where first_name='2093434f';
    < 2093426, 2093434f, 2093428l >
    1 row found.
    Execution time (SQLExecute + Fetch Loop) = 0.585897 seconds.
    Command>
    7.NOW I PERFORM THE SIMILAR QUERIES FROM SQLPLUS...
    SQL> SELECT * FROM STUDENT WHERE FIRST_NAME='1498671f';
    ID FIRST_NAME LAST_NAME
    1498663 1498671f 1498665l
    Elapsed: 00:00:00.15
    Can anyone please explain me why query in timesten taking more time
    that query in oracle database.
    Message was edited by: Dipesh Majumdar
    user542575
    Message was edited by:
    user542575

    TimesTen
    Hardware: Windows Server 2003 R2 Enterprise x64; 8 x Dual-core AMD 8216 2.41GHz processors; 32 GB RAM
    Version: 7.0.4.0.0 64 bit
    Schema:
    create usermanaged cache group factCache from
    MV_US_DATAMART
    ORDER_DATE               DATE,
    IF_SYSTEM               VARCHAR2(32) NOT NULL,
    GROUPING_ID                TT_BIGINT,
    TIME_DIM_ID               TT_INTEGER NOT NULL,
    BUSINESS_DIM_ID          TT_INTEGER NOT NULL,
    ACCOUNT_DIM_ID               TT_INTEGER NOT NULL,
    ORDERTYPE_DIM_ID          TT_INTEGER NOT NULL,
    INSTR_DIM_ID               TT_INTEGER NOT NULL,
    EXECUTION_DIM_ID          TT_INTEGER NOT NULL,
    EXEC_EXCHANGE_DIM_ID TT_INTEGER NOT NULL,
    NO_ORDERS               TT_BIGINT,
    FILLED_QUANTITY          TT_BIGINT,
    CNT_FILLED_QUANTITY          TT_BIGINT,
    QUANTITY               TT_BIGINT,
    CNT_QUANTITY               TT_BIGINT,
    COMMISSION               BINARY_FLOAT,
    CNT_COMMISSION               TT_BIGINT,
    FILLS_NUMBER               TT_BIGINT,
    CNT_FILLS_NUMBER          TT_BIGINT,
    AGGRESSIVE_FILLS          TT_BIGINT,
    CNT_AGGRESSIVE_FILLS          TT_BIGINT,
    NOTIONAL               BINARY_FLOAT,
    CNT_NOTIONAL               TT_BIGINT,
    TOTAL_PRICE               BINARY_FLOAT,
    CNT_TOTAL_PRICE          TT_BIGINT,
    CANCELLED_ORDERS_COUNT          TT_BIGINT,
    CNT_CANCELLED_ORDERS_COUNT     TT_BIGINT,
    ROUTED_ORDERS_NO          TT_BIGINT,
    CNT_ROUTED_ORDERS_NO          TT_BIGINT,
    ROUTED_LIQUIDITY_QTY          TT_BIGINT,
    CNT_ROUTED_LIQUIDITY_QTY     TT_BIGINT,
    REMOVED_LIQUIDITY_QTY          TT_BIGINT,
    CNT_REMOVED_LIQUIDITY_QTY     TT_BIGINT,
    ADDED_LIQUIDITY_QTY          TT_BIGINT,
    CNT_ADDED_LIQUIDITY_QTY     TT_BIGINT,
    AGENT_CHARGES               BINARY_FLOAT,
    CNT_AGENT_CHARGES          TT_BIGINT,
    CLEARING_CHARGES          BINARY_FLOAT,
    CNT_CLEARING_CHARGES          TT_BIGINT,
    EXECUTION_CHARGES          BINARY_FLOAT,
    CNT_EXECUTION_CHARGES          TT_BIGINT,
    TRANSACTION_CHARGES          BINARY_FLOAT,
    CNT_TRANSACTION_CHARGES     TT_BIGINT,
    ORDER_MANAGEMENT          BINARY_FLOAT,
    CNT_ORDER_MANAGEMENT          TT_BIGINT,
    SETTLEMENT_CHARGES          BINARY_FLOAT,
    CNT_SETTLEMENT_CHARGES          TT_BIGINT,
    RECOVERED_AGENT          BINARY_FLOAT,
    CNT_RECOVERED_AGENT          TT_BIGINT,
    RECOVERED_CLEARING          BINARY_FLOAT,
    CNT_RECOVERED_CLEARING          TT_BIGINT,
    RECOVERED_EXECUTION          BINARY_FLOAT,
    CNT_RECOVERED_EXECUTION     TT_BIGINT,
    RECOVERED_TRANSACTION          BINARY_FLOAT,
    CNT_RECOVERED_TRANSACTION     TT_BIGINT,
    RECOVERED_ORD_MGT          BINARY_FLOAT,
    CNT_RECOVERED_ORD_MGT          TT_BIGINT,
    RECOVERED_SETTLEMENT          BINARY_FLOAT,
    CNT_RECOVERED_SETTLEMENT     TT_BIGINT,
    CLIENT_AGENT               BINARY_FLOAT,
    CNT_CLIENT_AGENT          TT_BIGINT,
    CLIENT_ORDER_MGT          BINARY_FLOAT,
    CNT_CLIENT_ORDER_MGT          TT_BIGINT,
    CLIENT_EXEC               BINARY_FLOAT,
    CNT_CLIENT_EXEC          TT_BIGINT,
    CLIENT_TRANS               BINARY_FLOAT,
    CNT_CLIENT_TRANS          TT_BIGINT,
    CLIENT_CLEARING          BINARY_FLOAT,
    CNT_CLIENT_CLEARING          TT_BIGINT,
    CLIENT_SETTLE               BINARY_FLOAT,
    CNT_CLIENT_SETTLE          TT_BIGINT,
    CHARGEABLE_TAXES          BINARY_FLOAT,
    CNT_CHARGEABLE_TAXES          TT_BIGINT,
    VENDOR_CHARGE               BINARY_FLOAT,
    CNT_VENDOR_CHARGE          TT_BIGINT,
    ROUTING_CHARGES          BINARY_FLOAT,
    CNT_ROUTING_CHARGES          TT_BIGINT,
    RECOVERED_ROUTING          BINARY_FLOAT,
    CNT_RECOVERED_ROUTING          TT_BIGINT,
    CLIENT_ROUTING               BINARY_FLOAT,
    CNT_CLIENT_ROUTING          TT_BIGINT,
    TICKET_CHARGES               BINARY_FLOAT,
    CNT_TICKET_CHARGES          TT_BIGINT,
    RECOVERED_TICKET_CHARGES     BINARY_FLOAT,
    CNT_RECOVERED_TICKET_CHARGES     TT_BIGINT,
    PRIMARY KEY(ORDER_DATE, TIME_DIM_ID, BUSINESS_DIM_ID, ACCOUNT_DIM_ID, ORDERTYPE_DIM_ID, INSTR_DIM_ID, EXECUTION_DIM_ID,EXEC_EXCHANGE_DIM_ID),
    READONLY);
    No of rows: 2228558
    Config:
    < CkptFrequency, 600 >
    < CkptLogVolume, 0 >
    < CkptRate, 0 >
    < ConnectionCharacterSet, US7ASCII >
    < ConnectionName, tt_us_dma >
    < Connections, 64 >
    < DataBaseCharacterSet, AL32UTF8 >
    < DataStore, e:\andrew\datacache\usDMA >
    < DurableCommits, 0 >
    < GroupRestrict, <NULL> >
    < LockLevel, 0 >
    < LockWait, 10 >
    < LogBuffSize, 65536 >
    < LogDir, e:\andrew\datacache\ >
    < LogFileSize, 64 >
    < LogFlushMethod, 1 >
    < LogPurge, 0 >
    < Logging, 1 >
    < MemoryLock, 0 >
    < NLS_LENGTH_SEMANTICS, BYTE >
    < NLS_NCHAR_CONV_EXCP, 0 >
    < NLS_SORT, BINARY >
    < OracleID, NYCATP1 >
    < PassThrough, 0 >
    < PermSize, 4000 >
    < PermWarnThreshold, 90 >
    < PrivateCommands, 0 >
    < Preallocate, 0 >
    < QueryThreshold, 0 >
    < RACCallback, 0 >
    < SQLQueryTimeout, 0 >
    < TempSize, 514 >
    < TempWarnThreshold, 90 >
    < Temporary, 1 >
    < TransparentLoad, 0 >
    < TypeMode, 0 >
    < UID, OS_OWNER >
    ORACLE:
    Hardware: Sunos 5.10; 24x1.8Ghz (unsure of type); 82 GB RAM
    Version 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    Schema:
    CREATE MATERIALIZED VIEW OS_OWNER.MV_US_DATAMART
    TABLESPACE TS_OS
    PARTITION BY RANGE (ORDER_DATE)
    PARTITION MV_US_DATAMART_MINVAL VALUES LESS THAN (TO_DATE(' 2007-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_NOV_D1 VALUES LESS THAN (TO_DATE(' 2007-11-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_NOV_D2 VALUES LESS THAN (TO_DATE(' 2007-11-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_NOV_D3 VALUES LESS THAN (TO_DATE(' 2007-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_DEC_D1 VALUES LESS THAN (TO_DATE(' 2007-12-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_DEC_D2 VALUES LESS THAN (TO_DATE(' 2007-12-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_07_DEC_D3 VALUES LESS THAN (TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_08_JAN_D1 VALUES LESS THAN (TO_DATE(' 2008-01-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_08_JAN_D2 VALUES LESS THAN (TO_DATE(' 2008-01-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_08_JAN_D3 VALUES LESS THAN (TO_DATE(' 2008-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS,
    PARTITION MV_US_DATAMART_MAXVAL VALUES LESS THAN (MAXVALUE)
    LOGGING
    NOCOMPRESS
    TABLESPACE TS_OS
    NOCACHE
    NOCOMPRESS
    NOPARALLEL
    BUILD DEFERRED
    USING INDEX
    TABLESPACE TS_OS_INDEX
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    ENABLE QUERY REWRITE
    AS
    SELECT order_date, if_system,
    GROUPING_ID (order_date,
    if_system,
    business_dim_id,
    time_dim_id,
    account_dim_id,
    ordertype_dim_id,
    instr_dim_id,
    execution_dim_id,
    exec_exchange_dim_id
    ) GROUPING_ID,
    /* ============ DIMENSIONS ============ */
    time_dim_id, business_dim_id, account_dim_id, ordertype_dim_id,
    instr_dim_id, execution_dim_id, exec_exchange_dim_id,
    /* ============ MEASURES ============ */
    -- o.FX_RATE /* FX_RATE */,
    COUNT (*) no_orders,
    -- SUM(NO_ORDERS) NO_ORDERS,
    -- COUNT(NO_ORDERS) CNT_NO_ORDERS,
    SUM (filled_quantity) filled_quantity,
    COUNT (filled_quantity) cnt_filled_quantity, SUM (quantity) quantity,
    COUNT (quantity) cnt_quantity, SUM (commission) commission,
    COUNT (commission) cnt_commission, SUM (fills_number) fills_number,
    COUNT (fills_number) cnt_fills_number,
    SUM (aggressive_fills) aggressive_fills,
    COUNT (aggressive_fills) cnt_aggressive_fills,
    SUM (fx_rate * filled_quantity * average_price) notional,
    COUNT (fx_rate * filled_quantity * average_price) cnt_notional,
    SUM (fx_rate * fills_number * average_price) total_price,
    COUNT (fx_rate * fills_number * average_price) cnt_total_price,
    SUM (CASE
    WHEN order_status = 'C'
    THEN 1
    ELSE 0
    END) cancelled_orders_count,
    COUNT (CASE
    WHEN order_status = 'C'
    THEN 1
    ELSE 0
    END
    ) cnt_cancelled_orders_count,
    -- SUM(t.FX_RATE*t.NO_FILLS*t.AVG_PRICE) AVERAGE_PRICE,
    -- SUM(FILLS_NUMBER*AVERAGE_PRICE) STAGING_AVERAGE_PRICE,
    -- COUNT(FILLS_NUMBER*AVERAGE_PRICE) CNT_STAGING_AVERAGE_PRICE,
    SUM (routed_orders_no) routed_orders_no,
    COUNT (routed_orders_no) cnt_routed_orders_no,
    SUM (routed_liquidity_qty) routed_liquidity_qty,
    COUNT (routed_liquidity_qty) cnt_routed_liquidity_qty,
    SUM (removed_liquidity_qty) removed_liquidity_qty,
    COUNT (removed_liquidity_qty) cnt_removed_liquidity_qty,
    SUM (added_liquidity_qty) added_liquidity_qty,
    COUNT (added_liquidity_qty) cnt_added_liquidity_qty,
    SUM (agent_charges) agent_charges,
    COUNT (agent_charges) cnt_agent_charges,
    SUM (clearing_charges) clearing_charges,
    COUNT (clearing_charges) cnt_clearing_charges,
    SUM (execution_charges) execution_charges,
    COUNT (execution_charges) cnt_execution_charges,
    SUM (transaction_charges) transaction_charges,
    COUNT (transaction_charges) cnt_transaction_charges,
    SUM (order_management) order_management,
    COUNT (order_management) cnt_order_management,
    SUM (settlement_charges) settlement_charges,
    COUNT (settlement_charges) cnt_settlement_charges,
    SUM (recovered_agent) recovered_agent,
    COUNT (recovered_agent) cnt_recovered_agent,
    SUM (recovered_clearing) recovered_clearing,
    COUNT (recovered_clearing) cnt_recovered_clearing,
    SUM (recovered_execution) recovered_execution,
    COUNT (recovered_execution) cnt_recovered_execution,
    SUM (recovered_transaction) recovered_transaction,
    COUNT (recovered_transaction) cnt_recovered_transaction,
    SUM (recovered_ord_mgt) recovered_ord_mgt,
    COUNT (recovered_ord_mgt) cnt_recovered_ord_mgt,
    SUM (recovered_settlement) recovered_settlement,
    COUNT (recovered_settlement) cnt_recovered_settlement,
    SUM (client_agent) client_agent,
    COUNT (client_agent) cnt_client_agent,
    SUM (client_order_mgt) client_order_mgt,
    COUNT (client_order_mgt) cnt_client_order_mgt,
    SUM (client_exec) client_exec, COUNT (client_exec) cnt_client_exec,
    SUM (client_trans) client_trans,
    COUNT (client_trans) cnt_client_trans,
    SUM (client_clearing) client_clearing,
    COUNT (client_clearing) cnt_client_clearing,
    SUM (client_settle) client_settle,
    COUNT (client_settle) cnt_client_settle,
    SUM (chargeable_taxes) chargeable_taxes,
    COUNT (chargeable_taxes) cnt_chargeable_taxes,
    SUM (vendor_charge) vendor_charge,
    COUNT (vendor_charge) cnt_vendor_charge,
    SUM (routing_charges) routing_charges,
    COUNT (routing_charges) cnt_routing_charges,
    SUM (recovered_routing) recovered_routing,
    COUNT (recovered_routing) cnt_recovered_routing,
    SUM (client_routing) client_routing,
    COUNT (client_routing) cnt_client_routing,
    SUM (ticket_charges) ticket_charges,
    COUNT (ticket_charges) cnt_ticket_charges,
    SUM (recovered_ticket_charges) recovered_ticket_charges,
    COUNT (recovered_ticket_charges) cnt_recovered_ticket_charges
    FROM us_datamart_raw
    GROUP BY order_date,
    if_system,
    business_dim_id,
    time_dim_id,
    account_dim_id,
    ordertype_dim_id,
    instr_dim_id,
    execution_dim_id,
    exec_exchange_dim_id;
    -- Note: Index I_SNAP$_MV_US_DATAMART will be created automatically
    -- by Oracle with the associated materialized view.
    CREATE UNIQUE INDEX OS_OWNER.MV_US_DATAMART_UDX ON OS_OWNER.MV_US_DATAMART
    (ORDER_DATE, TIME_DIM_ID, BUSINESS_DIM_ID, ACCOUNT_DIM_ID, ORDERTYPE_DIM_ID,
    INSTR_DIM_ID, EXECUTION_DIM_ID, EXEC_EXCHANGE_DIM_ID)
    NOLOGGING
    NOPARALLEL
    COMPRESS 7;
    No of rows: 2228558
    The query (taken Mondrian) I run against each of them is:
    select sum("MV_US_DATAMART"."NOTIONAL") as "m0"
    --, sum("MV_US_DATAMART"."FILLED_QUANTITY") as "m1"
    --, sum("MV_US_DATAMART"."AGENT_CHARGES") as "m2"
    --, sum("MV_US_DATAMART"."CLEARING_CHARGES") as "m3"
    --, sum("MV_US_DATAMART"."EXECUTION_CHARGES") as "m4"
    --, sum("MV_US_DATAMART"."TRANSACTION_CHARGES") as "m5"
    --, sum("MV_US_DATAMART"."ROUTING_CHARGES") as "m6"
    --, sum("MV_US_DATAMART"."ORDER_MANAGEMENT") as "m7"
    --, sum("MV_US_DATAMART"."SETTLEMENT_CHARGES") as "m8"
    --, sum("MV_US_DATAMART"."COMMISSION") as "m9"
    --, sum("MV_US_DATAMART"."RECOVERED_AGENT") as "m10"
    --, sum("MV_US_DATAMART"."RECOVERED_CLEARING") as "m11"
    --,sum("MV_US_DATAMART"."RECOVERED_EXECUTION") as "m12"
    --,sum("MV_US_DATAMART"."RECOVERED_TRANSACTION") as "m13"
    --, sum("MV_US_DATAMART"."RECOVERED_ROUTING") as "m14"
    --, sum("MV_US_DATAMART"."RECOVERED_ORD_MGT") as "m15"
    --, sum("MV_US_DATAMART"."RECOVERED_SETTLEMENT") as "m16"
    --, sum("MV_US_DATAMART"."RECOVERED_TICKET_CHARGES") as "m17"
    --,sum("MV_US_DATAMART"."TICKET_CHARGES") as "m18"
    --, sum("MV_US_DATAMART"."VENDOR_CHARGE") as "m19"
              from "OS_OWNER"."MV_US_DATAMART" "MV_US_DATAMART"
    where I uncomment a column at a time and rerun. I improved the TimesTen results since my first post, by retyping the NUMBER columns to BINARY_FLOAT. The results I got were:
    No Columns     ORACLE     TimesTen     
    1     1.05     0.94     
    2     1.07     1.47     
    3     2.04     1.8     
    4     2.06     2.08     
    5     2.09     2.4     
    6     3.01     2.67     
    7     4.02     3.06     
    8     4.03     3.37     
    9     4.04     3.62     
    10     4.06     4.02     
    11     4.08     4.31     
    12     4.09     4.61     
    13     5.01     4.76     
    14     5.02     5.06     
    15     5.04     5.25     
    16     5.05     5.48     
    17     5.08     5.84     
    18     6     6.21     
    19     6.02     6.34     
    20     6.04     6.75

  • How to pass a date parameter from report builder query designer to oracle database

    i'm using report builder 3.0 connected to oracle database. i'm trying to pass a date parameter in the query with no success, i don't
    know the exact syntax. I've tried :
    SELECT * FROM igeneral.GCL_CLAIMS where CREATED_BY IN (:CREATED_BY) AND CLAIM_YEAR IN(:UW_YEAR) AND (LOSS_DATE) >To_Date('01/01/2014','mm/dd/yyyy')
    it worked perfectly.
    However if i try to put a date parameter "From" instead of 01/01/2014 it will not work, a Define Query Parameter popup window appear and error occurred after i fill
    the values (usually i shouldnt get this popup i should enter the value when i run the report)
    SELECT * FROM igeneral.GCL_CLAIMS where CREATED_BY IN (:CREATED_BY) AND CLAIM_YEAR IN(:UW_YEAR) AND (LOSS_DATE) >To_Date(:From,'mm/dd/yyyy')
    appreciate your assistance

    Hi Gorgo,
    According to your description, you have problem when in passing a parameter for running a Oracle Query. Right?
    Based on my knowledge, it use "&" as synax for parameter in Oracle, like we use "@" in SQL Server. In this scenario, maybe you can try '01/01/2014' when inputing in "From". We are not sure if there's any limitation for To_Date()
    function. For your self-testing, you can try the query in sqlplus/sql delveloper. Since your issue is related to Oracle query, we suggest you post this thread onto Oracle forum.
    Best Regards,
    Simon Hou

  • How to generate XML file from oracle database query result

    Hi dudes,
    as stated on the subject, can anyone suggests me how can i achieve the task stated above??
    Here is a brief description of my problem:
    I need to create a XML file once i query from the oracle database, and the query result returned from the database will be stored in XML file.
    I'd searched around the JAXB, DOM, SAXP and the like basic concepts, but i still don't know how to start??
    Any suggestions ???

    Read this:
    http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html
    You might have to read more of the book to understand that chapter.

  • Store SQL Query in Oracle database

    Hello,
    I am storing SQL query in database. here is an example of query.
    INSERT INTO TABLE_1 Values (' " + getValue1() + " ', ' " + getValue2() + " ' )
    getValue1() and getValue2() are functions to retrieve values.
    When I read query from the database and execute it, it doesn't read values from function.
    After I read query from database I would expect it to be
    INSERT INTO TABLE_1 Values ('value1', ' value2' ) but it is not reading values and trying to execute whatever I got from database.
    Any help?
    Thanks

    Thanks for your reply. Let me give you more info.
    All I am trying to do is storing queries in oracle
    database to use it in future for reporting. As I am
    doing reporting where clause will be different every
    time. Reporting involves queries not updates. But in any case that means that you would use a java SQL string that is useable via a prepared statement. As such your statement would look like....
    INSERT INTO TABLE_1 Values (?,?)
    Is it not possible to substitute variable string I
    got from database?What do you mean?
    SQL is SQL. You construct SQL so it is valid and runs. Can you construct SQL so it runs a function/select and uses that value in some more SQL - depends on the database, but usually.
    But that has nothing to do with java - it is SQL.
    Query contains variables that I have in Java code .Then it is SQL. It is java. You use bind variables (see PreparedStatement) and assign values to it.
    The SQL for such a query would look like the following...
    select field1, field2 from table1 where id=?
    In your java you would then use something like PreparedStatement.setInt(1, 100), to fill in the value for the '?' in the above.
    You might also note that your solution will not work for any arbritrary SQL statement unless you are also storing meta data about the SQL itself. For instance the following SQL statements would return the same result set but your java code would have to populate the bind variables different for both...
    select field1, field2 from table1 where id=? and name=?
    select field1, field2 from table1 where name=? and id=?

  • Querying an Oracle Database Using XSL

    I know from years of experience as an Oracle DBA that to suggest that a program generate SQL is anathema, but I'm going to ask anyway!
    Is there currently (or soon) to be a means of submitting XSL (or, perhaps, some variant based on the most recently published "standard") to an Oracle database and receiving an XML result set?
    Note that I have not mentioned writing any SQL myself. I'm either looking for some middleware to translate the XSL "query" into the appropriate SQL query (with appropriate after-query transformations) or for the database engine itself to be able to parse and optimize XSL.
    I just read a position paper (dated 1998) on this site that says that Oracle intends to closely follow developments in the world of XML Query. And, I've read in a "Byte" article ("Where Are The XML Apps We Can See And Touch? Report From XML DevCon 2001", April 2001, Jon Udell) that Steve Muench had demonstrated some means of super-imposing an XML schema over top of a database in order to query it via XPath. Where does the product stand in regards to this type of functionality?
    Thanks in advance,
    David Park
    [email protected]

    For your reference:
    1/XML SQL Utility(XSU) in XDK for Java (also with PL/SQL API)
    http://technet.oracle.com/tech/xml/xdk_java
    - The XSU can transform data retreived from object-relational database tables or views into XML.
    - The XSU can extract data from a XML document and using a canonical mapping, insert the data into the appropriate columns/attributes of a table or a view.
    - The XSU can extract data from a XML document and apply this data to updating or deleteing values of the appropriate columns/attributes.
    2/ The documents for XMLType and DBUri(available in Oracle9i).
    http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a88894/adx05xml.htm#1012692
    3/ Oracle Text also have XPATH-based search.
    http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/text.901/a90122/csectio4.htm#33034

  • Problem querying an Oracle Database using PHP

    Hi there, im rather new to Oracle so pardon my ignorance if this is completely obvious but I am creating a web form that queries an oracle database, firstly is a user form which looks like this.
    <br><br>
    Search for Investments<br>
    <form action="query.php" method="POST"><br>
    <input type = "text" name = "invest"><br>
    <input type="submit" value="Search" name="submit" /><br>
    </form><br>
    -----------------------<br><br>
    and the php script which looks like this<br><br>
    -----------------------<br><br>
    <?php<br><
    print "<HTML><PRE>";<br><br>
    require_once('connect.php');<br>
    select_data($conn);<br><br>
    $invest = $_POST['invest'];<br>
    echo "Returning results related to $invest";<br><br>
    function select_data($conn)<br>
    { $stmt = ociparse($conn,"select * from investmentbase where INVTYPE='$invest'");<br>
    ociexecute($stmt,OCI_DEFAULT);<br><br>
    echo "<table border = 1 class=results>";<br><br>
    echo "<tr>";<br>
    echo "<td>Reference Number</td>";<br>
    echo "<td>User ID</td>";<br>
    echo "<td>Investment Type</td>";<br>
    echo "<td>Investment Description</td>";<br>
    echo "<td>Amount Required</td>";<br>
    echo "<td>Due Date<td>";<br>
    echo "</tr>";<br><br>
    while (ocifetch($stmt)){<br>
    echo "<tr>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"INVREF")." ";<br>
    echo "</td>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"USERID")." ";<br>
    echo "</td>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"INVTYPE")." ";<br>
    echo "</td>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"INVDESCRIPTION")." ";<br>
    echo "</td>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"AMOUNTREQUIRED")." ";<br>
    echo "</td>";<br>
    echo "<td>";<br>
    echo ociresult($stmt,"REQUIREDATE");<br>
    echo "</td>";<br>
    echo "</tr>";<br><br>
    }<br>
    echo "</table>";<br>
    }<br><br>
    ocilogoff($conn);<br>
    print "</PRE></HTML>";<br>
    ?> <br><br>
    When i search for a value that is in the database no results are returned, however the form is definitely posting the variable as the echo statement on the PHP script displays it. Any ideas would be gratefully appreciated
    Many Thanks
    Paul

    Do you need to set $invest before calling do_select() and pass it as a
    parameter? Also, watch out for SQL Injection security risks. Try
    using a bind variable.
    $invest = $_POST['invest'];
    echo "Returning results related to $invest";
    select_data($conn, $invest);
    function select_data($conn, $invest)
      $stmt = ociparse($conn,"select * from investmentbase where INVTYPE=:ibv");
      ocibindbyname($stmt, ':ibv', $invest);
      ociexecute($stmt,OCI_DEFAULT);
      . . .Although the PHP 4 naming style for oci8 functions can be used with
    PHP 5, I know there is a possibility you are using the PHP 4 OCI8
    extension. If you are, then upgrade at least OCI8. There are some
    notes on this in
    Re: frustrations with oci_fetch_array()
    -- cj

  • Oracle 10g and parallel query question

    Hi Oracle on SAP Gurus!
    We are currently thinking of activating parallel query for certain segments (large application tables and indexes). We searched in SAPNet and SDN and have also studied the SAP Note 651060. But we did not find a complete answer to the following question which is very important for us:
    Which kinds of queries (despite from full table scan and index scan in partitioned indexes) support parallel queries and which ones do not support parallel queries?
    This is important for us to find out whether we have candidates for parallel queries or not.
    Thanx for any hint!
    Regards,
    Volker

    But why do you not propose to use parallel query in OLTP systems?
    If the queries are accessed very frequently you will just run out of cpu and io ressources. OLTP systems are (historical) typically multi user systems. You can off course use PQ for 'single user' activities, like index rebuilds, some batchjobs, but you shouldn't do for frequent user queries.
    If you have time look at this interesting Article [Suck It Dry - Tuning Parallel Execution|http://doug.burns.tripod.com/px.html]
    It is quite old, and you don't have to read all tech details, but i recommend having a look at the conclusions at the end.
    May it make sense to use partitioning of these tables in conjunction with parallel query?
    I know some guys, who do partitioning on OLTP systems, even SAP systems. But they don't use PQ then. The use partitioning to work on a smaller set of data. In your case the range scans, would need to scan only one partition, saving buffer cache and effectively speeding up execution. So you don't need PQ to scan all partitions at all, this would be a typical OLAP approach.
    Best regards
    Michael

  • Query using link server to an Oracle database failswhile similar query works

    I have two queries almost the same that use a link to an Oracle database. One works ok, the other is a copy of the first with a few fields selects removed.  The first one works fine, the copy fails with: Cannot get the data of the row from the OLE DB
    provider "OraOLEDB.Oracle" for linked server "linkname".
    They are so similar, why would one work but not the other? 
    First query, this one works:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, p.testid,
    mdx."Dx_4", td.acquisitiondatetime_dt, td.democompletedatetime_dt,
    td.editdatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Arrival_date,
    CAST(STUFF(STUFF(mt."Comp_D_T_22",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Order_date, td.confirmdatetime_dt
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."ARRIVAL_TIME_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE",
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MT."COMP_D_T_22", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT)
    as char(10))
    + 'min') 
    AS "ORDER TO COMPLETE"
    from linknametosqldb.sqldbname.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.sqldbname dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left
    outer join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb."M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientfullname_last, p.patientfullname_first
    END
    GO
    Second query, copied from first with some fields selects removed, this does not work:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name_2]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, mdx."Dx_4",
    td.democompletedatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as EDIS_Arrival_date,
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."Arrival_Time_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE"
    from linknametosqldb.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left outer
    join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientid
    END
    GO
    Thanks very much for any help with this.

    * Consider putting parentheses around the 3 oracle tables so the 3 of them can possibly be treated as a unit.  Assuming there's some performance impact due to the linked server, this MIGHT help, may do a little joining over on the Oracle side of
    the world.  In either case, it's a little cleaner.  They syntax below, including a few extra line breaks for clarity, should be correct.  (try the change to the ON clause suggested above too, though).
    The parentheses will not help much. SQL Server will remote (as the term is) the query to the Oracle instance if this appears to have a lower cost and there is nothing the blocks remoting.
    On the other hand, OPENQUERY can be an alternative to ensure that this happens:
     left outer join
        OPENQUERY (linknametooracledb,
                   'SELECT ...
                    FROM   "M01Tab01_Main" mn
                    JOIN   "M01Tab06_Ord" mt ON mn."Master_Recid_1" = mt."Master_Recid_1"
                    JOIN   "M01Tab09_Dx" mdx on mn."Master_Recid_1" = mdx."Master_Recid_1"') mn on td.visitnumber = mn."Pt_Acct_5"
    But this presumes that you there are no columns from the SQL Server side that are used to select data from the Oracle side. That is, the above could lead to far much data being brought across the wire.
    Then again, this does not really seem to relate to the original problem where a stored procedure was not working at all. That problem is not very easy to assist with since code post is the not the authentic code as pointed out in the thread. For instance
    inner JOIN linknametooracledb."M01Tab06_Ord"
    Has nothing to do with Oracle, but accesses a table in the schema linknametooracledb.
    I think to help dmcm, you need a really good crystal ball - at least as long he/she does not share the actual code.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Parallel  query in Oracle 11g

    We use Oracle 11g DB on windows2008R2.
    We wrote very long and heavy SELECT SQL query usign several table join and sub-queries and it take very long time to get result.
    We did SQL statement tuning as much as we can do so far. ( I will get the Execution Plan and ADDM, etc access right)
    I today notice about Parallel query function.
    Where could I write parallel hint phrases in very long SELECT SQL query ?
    In each selected tables like below ?
    /sample in Oracle Doc/
    SELECT /*+ PARALLEL(employees 4) PARALLEL(departments 4)
           USE_HASH(employees) ORDERED */ MAX(salary), AVG(salary)
    FROM employees, departments
    WHERE employees.department_id = departments.department_id
    GROUP BY employees.department_id;

    You need to be careful with some of the examples in the docs. The example you quote includes an unnecessary join. Before considering parallel query, it should have been re-written to this:
    SELECT MAX(salary), AVG(salary)
    FROM employees
    WHERE department_id is not null
    GROUP BYdepartment_id;
    Later versions of the CBO may do this re-write for you, but it is important to understand why the SQL is inefficient before throwing parallel servers at it. Are you sure that all your joins are actually necessary? (I know you are just going to say "yes", but you might want to think about it first.)

  • Query to insert file in Oracle database  9.2.0.1.0

    how can I can reafear to a file field of an oracle database 9.2.0.1.0 in a query?
    Thanks

    Hi
    Use external table definiton.
    Ott Karesz
    http://www.trendo-kft.hu

Maybe you are looking for

  • Calendar stuck in year view

    On my iphone 4 using ios7.02 the calendar is stuck in year view.  There are no tabs.  I can't escape.  I tried quitting and restoring the phone, that did not work.  How do I get back to the classic month view with the tabs?

  • Help with download and delete??

    Ok i have all my music on my library in one computer now my itouch is on auto synce..im goin on vacation so i put my itouch on manual update so i can l add songs to it from my sisters computer. now my question is when i go baq home i wanna put my ipo

  • Component video codec

    okay awhile back i asked about why the quality setting couldn't be adjusted for the component video codec...not truly answered though i appreciate dick napoli for jumping in...anyway now it's just gone! no component video codec at all. anything else

  • StoredProcedure outParameters oracle

    Hi, I have a java project where I try to obtain a data type from a Oracle Stored Procedure. My problem is when I recive the Map (the Map is returned by execute method from StoredProcedure of Spring), the object I have received is a * $Proxy3 * Object

  • Remote Telenet

    Just received a new DSL modem/router, D-Link 2750B. to replace my Westell 327w.  I can see it is configured for remote Telnet administration but I do not know the username/password. When I try a remote telnet login I do get a prompt for username and