Query output SELECT Unix spool

Dear all,

I have a requirement spool the data in a table in a log file and send it as an email.

In my unix shell script, that's what I do:
set def off;
set echo off
spool mail_text.log
begin
SELECT *  FROM table1;
end;
spool off;

/usr/lib/sendmail -v <mail_id> < mail_text.log
On executing the shell script, I get an error-

SELECT * FROM table1;
*
ERROR on line 2:
ORA-06550: line 2, column 1:
PLS-00428: an INTO clause in this SELECT statement

If I am to use IN the clause, how would spool data?

Looking forward to your suggestions.

BEGIN and END belongs to PL/SQL. You want to run your code as a script. So delete BEGIN and END, and just use the SELECT.

Tags: Database

Similar Questions

  • How to remove the newline from the query output?

    Hello

    How to remove the newline from the query output?
    have tried to replace select (column_name, Chr (10), ' ') from table_name.

    Published by: GreenHorn 11 Sep, 2008 12:53 AM

    Please consider, that windows uses a sequence of chr13 | Chr (10) Unix uses only a single character CHR (10).
    The new line characters may depend on the operating system.

    You might consider with:

    Replace (replace (column_name, Chr (13) |)) CHR (10), ' '), CHR (10),' ')

    Hartmut

    Published by: hartmutm on 11.09.2008 01:32

  • Get blocking detected when waiting for resource query error select...

    Hi all

    I get an error below each time that the execution of the select query below...

    a few times, it will show lock detected while you wait resource and finished...

    a few times, it runs and give the result...

    but all the time, he writes a journal to alert to the alert

    Plesae suggest how to solve the problem...

    Thanks in advance

    .

    Env: Linux / Oracle 11.2.0.3.3

    .

    .

    Alerts log error:

    Errors in the /u01/oracle/oracle/diag/rdbms/bdrdb/bdrdb/trace/bdrdb_p017_6076.trc file:

    ORA-00060: Deadlock detected while you wait resource

    ORA-10387: interruption of server a (normal) parallel query

    Trace file... information bdrdb_p017_6076.trc:

    Trace file /U01/Oracle/Oracle/diag/RDBMS/bdrdb/bdrdb/trace/bdrdb_p017_6076.TRC

    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    ORACLE_HOME = /u01/oracle/oracle/product/11.2.0/dbhome_1

    Name of the system: Linux

    Name of the node: bdrdb.cteplindia.com

    News Release: 2.6.18 - 308.el5PAE

    Version: #1 SMP kills Jan 27 17:40:09 EST 2012

    Machine: i686

    Instance name: bdrdb

    Redo thread mounted by this instance: 1

    Oracle process number: 92

    Unix process pid: 6076, image: [email protected] (P017)

    2013-11-04 23:18:57.915

    SESSION ID: (423.59970) 2013-11-04 23:18:57.915

    CUSTOMER ID :() 23:18:57.915 2013-11-04

    SERVICE NAME: (bdrdb) 2013-11-04 23:18:57.915

    MODULE NAME :() 23:18:57.915 2013-11-04

    ACTION NAME :() 23:18:57.915 2013-11-04

    .

    .

    2013-11-04 23:18:57.915

    DEADLOCK DETECTED (ORA-00060)

    .

    [Transaction blocking]

    Deadlock graph event:

    -Blockers - Waiter (s).

    Resource name process session held process session expected holds expected

    PS-00000001-00000011 92 423 S 33 128 S X

    BF-2ed08c01-00000000 33 128 S 92 423 S X

    session 423: C 005-0001-00081126 session 128: DONE 01/21/67 D 23

    session 128: MADE 21/01/67 D session 23 423: have you 0001-005 C-00081126

    DEADLOCK DETECTED (ORA-00060)

    [Transaction blocking]

    Deadlock graph event:

    -Blockers - Waiter (s).

    Resource name process session held process session expected holds expected

    PS-00000001-00000011 92 423 S 33 128 S X

    BF-2ed08c01-00000000 33 128 S 92 423 S X

    session 423: C 005-0001-00081126 session 128: DONE 01/21/67 D 23

    session 128: MADE 21/01/67 D session 23 423: have you 0001-005 C-00081126

    Expected number of lines:

    Session 423: no line

    Session 128: obj - rowid = 00021DC1 - AAAh3BAAVAAAQL/AAA

    (dictionary objn - 138689, file - 21, block - 66303, machine slot - 0)

    -Information for OTHER waiting sessions-

    Session 128:

    SID: 128 ser: 46176 audsid: 1836857 user: 102/DBLOCAL

    indicators: (0 x 8000041) USR /-flags_idl: (0 x 1) BSY /-/ - /-/ - / -.

    Flags2: (0 x 40009) - /-/ INC.

    PID: 33 info o/s: user: oracle, duration: UNKNOWN, ospid: 31611

    image: [email protected]

    Customer details:

    Info of the o/s: user: hidden, term: hidden, ospid: 5924:568

    machine: hidden program: Toad.exe

    application name: TOAD background query session, the hash value = 526966934

    SQL courses

    application name: TOAD background query session, the hash value = 526966934

    SQL courses

    SELECT DISTINCT B_FP_TEST. TEST_ID

    OF B_FP_TEST.

    B_USER_INFO,

    J_FP_INVESTIGATOR,

    L_TEST_STATUS,

    L_ATMS_TEST_TYPE,

    j_op_test_anml

    WHERE B_FP_TEST. TEST_ID = J_FP_INVESTIGATOR. TEST_ID

    AND B_FP_TEST. TEST_TYPE_ID = L_ATMS_TEST_TYPE. ATMS_TEST_TYPE_ID

    AND B_USER_INFO. B_USER_INFO_ID = J_FP_INVESTIGATOR. INVESTIGATOR_ID

    AND B_FP_TEST. BATCH = L_TEST_STATUS. BATCH

    AND B_FP_TEST.IS_DELETED =: "SYS_B_00."

    AND B_FP_TEST. TEST_NUM NOT IN (: 'SYS_B_01,': 'SYS_B_02': 'SYS_B_03')

    AND L_ATMS_TEST_TYPE.IS_DELETED =: "SYS_B_04."

    AND J_FP_INVESTIGATOR.is_pi =: "SYS_B_05."

    AND L_TEST_STATUS. STATUS (: 'SYS_B_06': 'SYS_B_07': 'SYS_B_08')

    AND j_op_test_anml.test_id = B_FP_TEST. TEST_ID

    .

    .

    -End of information for OTHER waiting sessions-

    .

    .

    2013-11-04 23:18:57.916

    dbkedDefDump(): from a dump of diagnosis non-event (flags = 0 x 0, level = 3, mask = 0 x 0)

    -Error stack dump-

    ORA-00060: Deadlock detected while you wait resource

    ORA-10387: interruption of server a (normal) parallel query

    -SQL statement (none).

    Run SQL information not available - no cursor.

    -Call trace stack memory-

    call call entered the argument values in hex

    location point type (? means dubious value)

    More...

    .

    .

    .

    .

    Query:

    SELECT DISTINCT B_FP_TEST. TEST_ID

    OF B_FP_TEST.

    B_USER_INFO,

    J_FP_INVESTIGATOR,

    L_TEST_STATUS,

    L_ATMS_TEST_TYPE,

    j_op_test_anml

    WHERE B_FP_TEST. TEST_ID = J_FP_INVESTIGATOR. TEST_ID

    AND B_FP_TEST. TEST_TYPE_ID = L_ATMS_TEST_TYPE. ATMS_TEST_TYPE_ID

    AND B_USER_INFO. B_USER_INFO_ID = J_FP_INVESTIGATOR. INVESTIGATOR_ID

    AND B_FP_TEST. BATCH = L_TEST_STATUS. BATCH

    AND B_FP_TEST.IS_DELETED = 0

    AND B_FP_TEST. TEST_NUM NOT IN (1, 2, 99)

    AND L_ATMS_TEST_TYPE.IS_DELETED = 0

    AND J_FP_INVESTIGATOR.is_pi = 1

    AND L_TEST_STATUS. STATUS ('regular', 'In progress', 'completed')

    AND j_op_test_anml.test_id = B_FP_TEST. TEST_ID

    AND ((j_op_test_anml.end_date ENTRE TO_DATE (28 octobre 2013 ") - 1))

    AND TO_DATE (4 November 2013 ') + 1).

    OR (j_op_test_anml.start_date BETWEEN TO_DATE (28 October 2013 "") - 1).

    AND TO_DATE (4 November 2013 ') + 1).

    OR (TO_DATE (28 October 2013') BETWEEN j_op_test_anml.start_date)

    AND j_op_test_anml.end_date)

    OR (TO_DATE (4 November 2013") BETWEEN j_op_test_anml.start_date)

    (AND j_op_test_anml.end_date))

    AND L_ATMS_TEST_TYPE.IS_DELETED = 0

    AND B_FP_TEST. DATASOURCE_ID = 9

    .

    .

    .

    Exp query plan:

    Hash value of plan: 3398228788

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

    | ID | Operation                                          | Name                | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |    TQ | IN-OUT | PQ Distrib.

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

    |   0 | SELECT STATEMENT |                     |  1501 |   102K |  1929 (1) | 00:00:24 |       |       |        |      |            |

    |   1.  HASH UNIQUE                                       |                     |  1501 |   102K |  1929 (1) | 00:00:24 |       |       |        |      |            |

    |   2.   CONCATENATION.                     |       |       |            |          |       |       |        |      |            |

    |   3.    COORDINATOR OF PX |                     |       |       |            |          |       |       |        |      |            |

    |   4.     PX SEND QC (RANDOM). : TQ30005 |   241. 16870 |   800 (1) | 00:00:10 |       |       |  Q3, 05 | P > S | QC (RAND) |

    |*  5 |      HASH JOIN                                     |                     |   241. 16870 |   800 (1) | 00:00:10 |       |       |  Q3, 05 | SVCP |            |

    |   8 2       PX RECEIVE                                   |                     |   246. 15990.   797 (1) | 00:00:10 |       |       |  Q3, 05 | SVCP |            |

    |   7.        PX SEND HASH | : TQ30004 |   246. 15990.   797 (1) | 00:00:10 |       |       |  Q3, 04 | P > P | HASH |

    |*  8 |         HASH JOIN                                  |                     |   246. 15990.   797 (1) | 00:00:10 |       |       |  Q3, 04 | SVCP |            |

    |   9.          RECEIVE PX |                     |   573. 29223 |   793 (1) | 00:00:10 |       |       |  Q3, 04 | SVCP |            |

    |  10.           PX SEND HASH | : TQ30003 |   573. 29223 |   793 (1) | 00:00:10 |       |       |  Q3, 03 | P > P | HASH |

    | * 11 |            HASH JOIN                               |                     |   573. 29223 |   793 (1) | 00:00:10 |       |       |  Q3, 03 | SVCP |            |

    |  12.             KIND OF BUFFER.                     |       |       |            |          |       |       |  Q3, 03 | ISSUE |            |

    |  13.              RECEIVE PX |                     |       |       |            |          |       |       |  Q3, 03 | SVCP |            |

    |  14.               PX SEND BROADCAST | : TQ30000 |       |       |            |          |       |       |        | S > P | BROADCAST |

    |  15.                NESTED LOOPS |                     |       |       |            |          |       |       |        |      |            |

    |  16.                 NESTED LOOPS |                     |   485. 20855 |   781 (0) | 00:00:10 |       |       |        |      |            |

    |  17.                  TABLE ACCESS BY INDEX ROWID | J_OP_TEST_ANML |   485. 10185 |   296 (0) | 00:00:04 | ROWID | ROWID |        |      |            |

    | * 18.                   INDEX RANGE SCAN | IDX$ $_2D190001 |   485.       |     4 (0) | 00:00:01 |       |       |        |      |            |

    | * 19.                  INDEX UNIQUE SCAN | FT_TEST_ID_PK |     1.       |     0 (0) | 00:00:01 |       |       |        |      |            |

    | * 20.                 TABLE ACCESS BY INDEX ROWID | B_FP_TEST |     1.    22.     1 (0) | 00:00:01 | ROWID | ROWID |        |      |            |

    |  21.             ITERATOR BLOCK PX |                     | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q3, 03 | ISSUE |            |

    | * 22.              TABLE ACCESS FULL | J_FP_INVESTIGATOR | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q3, 03 | SVCP |            |

    |  23.          KIND OF BUFFER.                     |       |       |            |          |       |       |  Q3, 04 | ISSUE |            |

    |  24.           RECEIVE PX |                     |     3.    42.     3 (0) | 00:00:01 |       |       |  Q3, 04 | SVCP |            |

    |  25.            PX SEND HASH | : TQ30001 |     3.    42.     3 (0) | 00:00:01 |       |       |        | S > P | HASH |

    | * 26.             TABLE ACCESS FULL | L_TEST_STATUS |     3.    42.     3 (0) | 00:00:01 |       |       |        |      |            |

    |  27.       KIND OF BUFFER.                     |       |       |            |          |       |       |  Q3, 05 | ISSUE |            |

    |  28.        PX RECEIVE                                  |                     |    30.   150.     3 (0) | 00:00:01 |       |       |  Q3, 05 | SVCP |            |

    |  29.         PX SEND HASH | : TQ30002 |    30.   150.     3 (0) | 00:00:01 |       |       |        | S > P | HASH |

    | * 30 |          TABLE ACCESS FULL | L_ATMS_TEST_TYPE |    30.   150.     3 (0) | 00:00:01 |       |       |        |      |            |

    |  31.    NESTED LOOPS |                     |       |       |            |          |       |       |        |      |            |

    |  32.     NESTED LOOPS |                     |     3.   210 |   329 (1) | 00:00:04 |       |       |        |      |            |

    |  33.      NESTED LOOPS |                     |     3.   195.   329 (1) | 00:00:04 |       |       |        |      |            |

    | * 34 |       HASH JOIN                                    |                     |     2.   114.   325 (1) | 00:00:04 |       |       |        |      |            |

    |  35.        NESTED LOOPS |                     |       |       |            |          |       |       |        |      |            |

    |  36.         NESTED LOOPS |                     |     6.   258.   322 (1) | 00:00:04 |       |       |        |      |            |

    |  37.          RANGE OF SINGLE PARTITION |                     |     6.   126.   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 38 |           TABLE ACCESS FULL | J_OP_TEST_ANML |     6.   126.   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 39 |          INDEX UNIQUE SCAN | FT_TEST_ID_PK |     1.       |     0 (0) | 00:00:01 |       |       |        |      |            |

    | * 40 |         TABLE ACCESS BY INDEX ROWID | B_FP_TEST |     1.    22.     1 (0) | 00:00:01 | ROWID | ROWID |        |      |            |

    | * 41.        TABLE ACCESS FULL | L_TEST_STATUS |     3.    42.     3 (0) | 00:00:01 |       |       |        |      |            |

    | * 42 |       TABLE ACCESS BY INDEX ROWID | J_FP_INVESTIGATOR |     1.     8.     2 (0) | 00:00:01 |       |       |        |      |            |

    | * 43.        INDEX RANGE SCAN | FI_TEST_ID_PK |     1.       |     1 (0) | 00:00:01 |       |       |        |      |            |

    | * 44 |      INDEX UNIQUE SCAN | L_ATMS_TEST_TYPE_PK |     1.       |     0 (0) | 00:00:01 |       |       |        |      |            |

    | * 45 |     TABLE ACCESS BY INDEX ROWID | L_ATMS_TEST_TYPE |     1.     5.     1 (0) | 00:00:01 |       |       |        |      |            |

    |  46.    COORDINATOR OF PX |                     |       |       |            |          |       |       |        |      |            |

    |  47.     PX SEND QC (RANDOM). : TQ20003 |       |       |            |          |       |       |  Q2, 03 | P > S | QC (RAND) |

    |  48.      NESTED LOOPS |                     |       |       |            |          |       |       |  Q2, 03 | SVCP |            |

    |  49.       NESTED LOOPS |                     |    33.  2310 |   399 (2) | 00:00:05 |       |       |  Q2, 03 | SVCP |            |

    | * 50 |        HASH JOIN                                   |                     |    33.  2145.   397 (2) | 00:00:05 |       |       |  Q2, 03 | SVCP |            |

    |  51.         RECEIVE PX |                     |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q2, 03 | SVCP |            |

    |  52.          PX SEND HASH | : TQ20002 |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q2, 02 | P > P | HASH |

    | * 53 |           HASH JOIN                                |                     |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q2, 02 | SVCP |            |

    |  54.            KIND OF BUFFER.                     |       |       |            |          |       |       |  Q2, 02 | ISSUE |            |

    |  55.             RECEIVE PX |                     |       |       |            |          |       |       |  Q2, 02 | SVCP |            |

    |  86 M |              PX SEND BROADCAST | : TQ20000 |       |       |            |          |       |       |        | S > P | BROADCAST |

    |  57.               NESTED LOOPS |                     |       |       |            |          |       |       |        |      |            |

    |  58.                NESTED LOOPS |                     |    66.  2838 |   382 (1) | 00:00:05 |       |       |        |      |            |

    |  59.                 RANGE OF SINGLE PARTITION |                     |    66.  1386 |   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 60 |                  TABLE ACCESS FULL | J_OP_TEST_ANML |    66.  1386 |   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 61.                 INDEX UNIQUE SCAN | FT_TEST_ID_PK |     1.       |     0 (0) | 00:00:01 |       |       |        |      |            |

    | * 62 |                TABLE ACCESS BY INDEX ROWID | B_FP_TEST |     1.    22.     1 (0) | 00:00:01 | ROWID | ROWID |        |      |            |

    |  63.            ITERATOR BLOCK PX |                     | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q2, 02 | ISSUE |            |

    | * 64 |             TABLE ACCESS FULL | J_FP_INVESTIGATOR | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q2, 02 | SVCP |            |

    |  65.         KIND OF BUFFER.                     |       |       |            |          |       |       |  Q2, 03 | ISSUE |            |

    |  66.          RECEIVE PX |                     |     3.    42.     3 (0) | 00:00:01 |       |       |  Q2, 03 | SVCP |            |

    |  67.           PX SEND HASH | : TQ20001 |     3.    42.     3 (0) | 00:00:01 |       |       |        | S > P | HASH |

    | * 68 |            TABLE ACCESS FULL | L_TEST_STATUS |     3.    42.     3 (0) | 00:00:01 |       |       |        |      |            |

    | * 69 |        INDEX UNIQUE SCAN | L_ATMS_TEST_TYPE_PK |     1.       |     0 (0) | 00:00:01 |       |       |  Q2, 03 | SVCP |            |

    | * 70 |       TABLE ACCESS BY INDEX ROWID | L_ATMS_TEST_TYPE |     1.     5.     1 (0) | 00:00:01 |       |       |  Q2, 03 | SVCP |            |

    |  71.    COORDINATOR OF PX |                     |       |       |            |          |       |       |        |      |            |

    |  72.     PX SEND QC (RANDOM). : TQ10003 |       |       |            |          |       |       |  Q1, 03 | P > S | QC (RAND) |

    |  73.      NESTED LOOPS |                     |       |       |            |          |       |       |  Q1, 03 | SVCP |            |

    |  74.       NESTED LOOPS |                     |    33.  2310 |   399 (2) | 00:00:05 |       |       |  Q1, 03 | SVCP |            |

    | * 75 |        HASH JOIN                                   |                     |    34.  2210 |   397 (2) | 00:00:05 |       |       |  Q1, 03 | SVCP |            |

    |  76.         RECEIVE PX |                     |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q1, 03 | SVCP |            |

    |  77.          PX SEND HASH | : TQ10002 |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q1, 02 | P > P | HASH |

    | * 78 |           HASH JOIN                                |                     |    78.  3978 |   393 (1) | 00:00:05 |       |       |  Q1, 02 | SVCP |            |

    |  79.            KIND OF BUFFER.                     |       |       |            |          |       |       |  Q1, 02 | ISSUE |            |

    |  80.             RECEIVE PX |                     |       |       |            |          |       |       |  Q1, 02 | SVCP |            |

    |  81.              PX SEND BROADCAST | : TQ10000 |       |       |            |          |       |       |        | S > P | BROADCAST |

    |  82.               NESTED LOOPS |                     |       |       |            |          |       |       |        |      |            |

    |  83.                NESTED LOOPS |                     |    66.  2838 |   382 (1) | 00:00:05 |       |       |        |      |            |

    |  84.                 RANGE OF SINGLE PARTITION |                     |    66.  1386 |   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 85 |                  TABLE ACCESS FULL | J_OP_TEST_ANML |    66.  1386 |   316 (1) | 00:00:04 |     7.     7.        |      |            |

    | * 86 |                 INDEX UNIQUE SCAN | FT_TEST_ID_PK |     1.       |     0 (0) | 00:00:01 |       |       |        |      |            |

    | * 87.                TABLE ACCESS BY INDEX ROWID | B_FP_TEST |     1.    22.     1 (0) | 00:00:01 | ROWID | ROWID |        |      |            |

    |  88.            ITERATOR BLOCK PX |                     | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q1, 02 | ISSUE |            |

    | * 89 |             TABLE ACCESS FULL | J_FP_INVESTIGATOR | 70382 |   549KO |    11 (0) | 00:00:01 |       |       |  Q1, 02 | SVCP |            |

    |  90.         KIND OF BUFFER.                     |       |       |            |          |       |       |  Q1, 03 | ISSUE |            |

    |  91.          RECEIVE PX |                     |     5:    42.     3 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

    |  92.           PX SEND HASH | : TQ10001 |     5:    42.     3 (0) | 00:00:01 |       |       |        | S > P | HASH |

    | * 93 |            TABLE ACCESS FULL | L_TEST_STATUS |     5:    42.     3 (0) | 00:00:01 |       |       |        |      |            |

    | * 94 |        INDEX UNIQUE SCAN | L_ATMS_TEST_TYPE_PK |     1.       |     0 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

    | * 95 |       TABLE ACCESS BY INDEX ROWID | L_ATMS_TEST_TYPE |     1.     3:     1 (0) | 00:00:01 |       |       |  Q1, 03 | SVCP |            |

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

    Information of predicates (identified by the operation identity card):

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

    5 - access("B_FP_TEST".") TEST_TYPE_ID "=" L_ATMS_TEST_TYPE. " ("' ATMS_TEST_TYPE_ID")

    8 - access("B_FP_TEST".") BATCH "=" L_TEST_STATUS. " ("' BATCH ')

    11 - access("B_FP_TEST".") TEST_ID "=" J_FP_INVESTIGATOR. " ("' TEST_ID")

    18 - access("J_OP_TEST_ANML".") Start_date"> = TO_DATE(' 2013-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND"J_OP_TEST_ANML. " "" Start_date "< = TO_DATE (' 2013-11-05)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss"))

    19 - access("J_OP_TEST_ANML".") TEST_ID "=" B_FP_TEST. " ("' TEST_ID")

    20 - filter("B_FP_TEST".") DATASOURCE_ID '= 9 AND 'B_FP_TEST'." ' IS_DELETED '= 0 AND 'B_FP_TEST'.' <>TEST_NUM ' 1 AND 'B_FP_TEST '. "" TEST_NUM "<>2 AND

    'B_FP_TEST '. ("' TEST_NUM" <>99)

    22 - filter("J_FP_INVESTIGATOR".") IS_PI "= 1)

    26 - filter("L_TEST_STATUS".") STATUS "="Finished"OR"L_TEST_STATUS"". "" STATUS '= 'In progress' OR 'L_TEST_STATUS'." STATUS "="Regular")"

    30 - filter("L_ATMS_TEST_TYPE".") IS_DELETED "= 0)

    34 - access("B_FP_TEST".") BATCH "=" L_TEST_STATUS. " ("' BATCH ')

    38 - filter("J_OP_TEST_ANML".") End_date"> = TO_DATE(' 2013-10-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND"J_OP_TEST_ANML. " "' End_date ' < = TO_DATE (' 2013-11-05)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss") AND (LNNVL ("J_OP_TEST_ANML". "Start_date" > = TO_DATE (' 2013-10-27 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')) OR) "

    LNNVL ("J_OP_TEST_ANML". "Start_date" < = TO_DATE (' 2013-11-05 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')))) "

    39 - access("J_OP_TEST_ANML".") TEST_ID "=" B_FP_TEST. " ("' TEST_ID")

    40 - filter("B_FP_TEST".") DATASOURCE_ID '= 9 AND 'B_FP_TEST'." ' IS_DELETED '= 0 AND 'B_FP_TEST'.' <>TEST_NUM ' 1 AND 'B_FP_TEST '. "" TEST_NUM "<>2 AND

    'B_FP_TEST '. ("' TEST_NUM" <>99)

    41 - filter("L_TEST_STATUS".") STATUS "="Finished"OR"L_TEST_STATUS"". "" STATUS '= 'In progress' OR 'L_TEST_STATUS'." STATUS "="Regular")"

    42 - filter("J_FP_INVESTIGATOR".") IS_PI "= 1)

    43 - access("B_FP_TEST".") TEST_ID "=" J_FP_INVESTIGATOR. " ("' TEST_ID")

    44 - access("B_FP_TEST".") TEST_TYPE_ID "=" L_ATMS_TEST_TYPE. " ("' ATMS_TEST_TYPE_ID")

    45 - filter("L_ATMS_TEST_TYPE".") IS_DELETED "= 0)

    50 - access("B_FP_TEST".") BATCH "=" L_TEST_STATUS. " ("' BATCH ')

    53 - access("B_FP_TEST".") TEST_ID "=" J_FP_INVESTIGATOR. " ("' TEST_ID")

    60 - filter("J_OP_TEST_ANML".") End_date"> = TO_DATE(' 2013-11-04 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND"J_OP_TEST_ANML. " "" Start_date "< = TO_DATE (' 2013-11-04)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss") AND (LNNVL ("J_OP_TEST_ANML". "End_date" > = TO_DATE (' 2013-10-27 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')) OR) "

    LNNVL ("J_OP_TEST_ANML". "End_date" < = TO_DATE (' 2013-11-05 00:00:00 ',' syyyy-mm-dd hh24:mi:ss'))) AND (LNNVL ("J_OP_TEST_ANML".) " Start_date"> = TO_DATE (' 2013-10-27)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss")) or LNNVL("J_OP_TEST_ANML".") Start_date"< = TO_DATE (' 2013-11-05 00:00:00 ',' syyyy-mm-dd hh24:mi:ss'))))

    61 - access("J_OP_TEST_ANML".") TEST_ID "=" B_FP_TEST. " ("' TEST_ID")

    62 - filter("B_FP_TEST".") DATASOURCE_ID '= 9 AND 'B_FP_TEST'." ' IS_DELETED '= 0 AND 'B_FP_TEST'.' <>TEST_NUM ' 1 AND 'B_FP_TEST '. "" TEST_NUM "<>2 AND

    'B_FP_TEST '. ("' TEST_NUM" <>99)

    64 - filter("J_FP_INVESTIGATOR".") IS_PI "= 1)

    68 - filter("L_TEST_STATUS".") STATUS "="Finished"OR"L_TEST_STATUS"". "" STATUS '= 'In progress' OR 'L_TEST_STATUS'." STATUS "="Regular")"

    69 - access("B_FP_TEST".") TEST_TYPE_ID "=" L_ATMS_TEST_TYPE. " ("' ATMS_TEST_TYPE_ID")

    70 - filter("L_ATMS_TEST_TYPE".") IS_DELETED "= 0)

    75 - access("B_FP_TEST".") BATCH "=" L_TEST_STATUS. " ("' BATCH ')

    78 - access("B_FP_TEST".") TEST_ID "=" J_FP_INVESTIGATOR. " ("' TEST_ID")

    85 - filter("J_OP_TEST_ANML".") End_date"> = TO_DATE(' 2013-10-28 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND"J_OP_TEST_ANML. " "" Start_date "< = TO_DATE (' 2013-10-28)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss") AND (LNNVL ("J_OP_TEST_ANML". "End_date" > = TO_DATE (' 2013-11-04 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')) OR) "

    LNNVL ("J_OP_TEST_ANML". "Start_date" < = TO_DATE (' 2013-11-04 00:00:00 ',' syyyy-mm-dd hh24:mi:ss'))) AND (LNNVL ("J_OP_TEST_ANML".) " End_date"> = TO_DATE (' 2013-10-27)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss")) or LNNVL("J_OP_TEST_ANML".") End_date"< = TO_DATE (' 2013-11-05 00:00:00 ',' syyyy-mm-dd hh24:mi:ss'))) AND)

    (LNNVL ("J_OP_TEST_ANML". "Start_date" > = TO_DATE (' 2013-10-27 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')) or LNNVL ("J_OP_TEST_ANML".) " Start_date"< = TO_DATE (' 2013-11-05)

    00:00:00 ', "syyyy-mm-dd hh24:mi:ss")))

    86 - access("J_OP_TEST_ANML".") TEST_ID "=" B_FP_TEST. " ("' TEST_ID")

    87 - filter("B_FP_TEST".") DATASOURCE_ID '= 9 AND 'B_FP_TEST'." ' IS_DELETED '= 0 AND 'B_FP_TEST'.' <>TEST_NUM ' 1 AND 'B_FP_TEST '. "" TEST_NUM "<>2 AND

    'B_FP_TEST '. ("' TEST_NUM" <>99)

    89 - filter("J_FP_INVESTIGATOR".") IS_PI "= 1)

    93 - filter("L_TEST_STATUS".") STATUS "="Finished"OR"L_TEST_STATUS"". "" STATUS '= 'In progress' OR 'L_TEST_STATUS'." STATUS "="Regular")"

    94 - access("B_FP_TEST".") TEST_TYPE_ID "=" L_ATMS_TEST_TYPE. " ("' ATMS_TEST_TYPE_ID")

    95 - filter("L_ATMS_TEST_TYPE".") IS_DELETED "= 0)

    aanto wrote:

    Thanks for the update... but if we perform also using Toad... showing the same error...

    Thanks for this update, but it does not change the reality.

    If it hurts when you push you in the eyes, the only way to stop the pain should stop poking you in the eye.

    Oracle is not related ORA-00060 just to make life more difficult.

    ORA-000600 is thrown when a deadlock between two session is detected. PERIOD!

    The order in which the DML is run needs to change.

  • Insert a blank line in the query output

    Is it possible to insert a blank line between two rows of the query output?

    In the EMP table, the column LINES is as follows:

    LINES
    1
    2
    3
    4
    1
    2
    3
    1
    2
    3
    4
    5

    I want to insert a blank line after every 1

    Please suggest.

    Sanjay

    I'm quite puzzled why you need rows in the dataset returned by a select statement that is empty.
    If you are using Oracle reports to the release date, you define the presentation of the report to have spaces between the rows returned by the select and have do not need to have the select statement returns a blank line after each line of data. If the output should be obtained by using another client, I think that the customer will have facilities for output formatting.

    Admit that you really need "blank lines" between data lines, I see only one way: use a temporary table and do an insert into select temporary_table (...) ... from... where... Then, in this temporary table, you can insert 'empty rows', which is actually not really empty, because they must have some fields that give the order of the rows. And then select in temporary_table, you place your order by the columns that are used to give the order for the release.
    Thus

    insert into temporary_table (
    ....
    )
    select ...
    from ...
    where ...
    ;
    for r in (
    select col1, col2, col3  -- columns used for order by
    from temporary_table
    order by col1, col2, col3
    )
    loop
      insert into temporary_table (col1, col2,col3, col4)
      values (r.col1,r.col2,r.col3, null);
    end loop;
    -- this way, a select * from temporary_tabel order by col1, col2, col3, col4 will return a blank row after each data row
    
  • How can I get several hyperlinks to display in the query output?

    I uses two tables to list all a school sport teams. The table of sport lists all team data aggregated by gender. The second table uses the sportID of the first table to associate a team calendar.  The problem is not all the teams do not have a calendar.

    I'm trying to post a link to these teams with schedules. I compare the two tables, the sport and the calendar and a CFIF statement allows to compare the 2 sportIDs in the output to determine the teams who have a schedule.  If the two sportIDs corresponds to a hyperlink is displayed.

    Unfortuanetely, only one link will be displayed, even if there should be three links. Here is my code:

    Table to display aggregated by gender teams

    "< name cfquery ="getSports"datasource =" #application.database # "" >

    Choose between the sexes, team, levels, sportID

    sports

    Group sex, team, levels, sportID

    < / cfquery >

    Table used for the sportID of already created calendars

    < name cfquery = "getID" datasource = "#application.database #" >

    Select sportID

    annexes

    SportID group

    < / cfquery >

    I then compare the sportIDs and if they match, I then display a hyperlink

    "< cfoutput query ="getSports"group 'sex' = >"

    < h1 "> teams #gender < / h1 >"

    < ul >

    < cfoutput >

    < li >

    < cfif getID.sportID EQ getSports.sportID > <a href = "teams.cfm? sportID = #sportID #" >< / cfif >

    #team # < cfif levels GT "" >(#levels#) < / cfif > //levels is used to differentiate the J.V. and Varsity. "." Usage levels not all of the teams

    < cfif getID.sportID EQ getSports.sportID > </ a >< / cfif >

    < /li >

    < / cfoutput >

    < /ul >

    < / cfoutput >

    How can I get the other teams to display their links?

    Thank you gentlemen, since everyone was suggesting an outer join, I took out my trusty Manual of ColdFusion and learn about them. I've added the sum() for the query:

    Select sports.gender, sports.team, sports.levels, sports.sportID, sum (schedules.sportID) AS expected

    sports

    opening hours of the outer join left on sports.sportID = schedules.sportID

    Group of sports.gender, sports.team, sports.levels, sports.sportID

    So add the following to the output:

    And everything works perfectly. Once again, life is beautiful!

  • How to use a parameter query to select and display the data in the table of the façade

    Hiiiiii

    I am using Access 2007 database
    I want to select the specific data in the database using control of the chain as 'select product, size, weight of ProductInfo where barcode (chain control) =?'  and also display the same table of façade.

    I use the connected database toolkit.
    I saw the example of the parameterized insert, but it did not help to use parameterized select query, as well as to display data of parameterized select query.

    I looked for example on parameterized select query, but I don't have any.
    So pls guide me how to do this. I would like to know the other method (if any) that the use of parameter query to perform the same thing.
    If possble pls share a vi reference.
    Thank you!!!

    HII szewczak
    Thanks for the reply
    but I did not getsolution in one of your shared links
    My problem is solved. There is no need to use the parameter query to select control values
    In my case I want to display data from database where bar code is even entered by the user
    I use the data function DB TOOL CHOOSE and create the condition of chain based on concatenation of strings

  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

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

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Blank line between lines of query output

    Is it possible to add a blank line between two rows of the query output?

    Sanjay

    user12957777 wrote:
    Is it possible to add a blank line between two rows of the query output?

    Sanjay, it's a problem of client - customer is responsible for rendering data. If whites are needed, then the customer must make as a result.

    Under the projection of the cursor SQL is not a good idea.

  • Not able to change the password by using the query. Select APPS.fnd_web_sec

    Not able to change the password by using the query.
    Select APPS.fnd_web_sec.change_password ('username', 'password') 'RES' double;

    Can someone tell why and what privileges and subsidies have flexibility to the user non-apps while it can change the password using fnd_web_sec.change_password.



    Concerning

    the information above does not solve my problem, I get the message

    Because you do not have permission on all objects that are referenced by the API (see below).

    Select FND_WEB_SEC. CHANGE_PASSWORD ('MARSHAD', 'mohammad @123') "RES" of the double

    *

    ERROR on line 1:

    ORA-00942: table or view does not exist

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 25

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 432

    ORA-06512: at the 'APPS '. FND_PROFILE', line 110

    ORA-06512: at the 'APPS '. FND_SSO_MANAGER", line 227

    ORA-06512: at the 'APPS '. FND_WEB_SEC', line 1425

    ORA-06512: at line 1...

    can you please list me what are the grants and other Jules Destrooper I should give to a user so that he can change password.

    I don't have the list of objects and you should get yourself by consulting the site code and eTRM API.

    by changing the DDT in the user non-apps after the grant, will, it may be able to change the password.please tell this syntax is correct or not.
    Select applications. FND_WEB_SEC. CHANGE_PASSWORD ('user', 'pwd') "RES" of the double

    What is the point of using 'FND_WEB_SEC. CHANGE_PASSWORD' and not FNDCPASS or FND_USER_PKG API?

    Thank you
    Hussein

  • I need a query that selects the amount of records for each day of a table.

    I need a query that selects the amount of records for each day of a table.
    For example, the result would be:

    1 14 date
    Date 2-3

    etc.

    Any ideas?

    Sort:

    SELECT count ([IDCommentaire]), convert (varchar, dateAdded, 112)

    OF COMMENTSgroup by convert (varchar, dateAdded, 112)

  • Result of the COIL query SELECT UNIX - tabular format

    This request of mine is an extension of my previous thread that I've marked as 'Response' (where the new position).

    I am now able to spool the output of the SELECT query in a file through unix shell script.

    However, the output is not formatted. I tried to use options like
    COLUMN column_name FORMAT A20, but this has not worked as planned.

    I have 5 columns in the table and my output is to have these columns by dragging to the next line.

    for example, I want something like
    column1     column2       column3          column4        column5
    ======================================================================
    value1      value2        value3           value4         value5
    But I get:
    column1      column2         
    ======================
    value1                value2                 
    
    column3            column4         
    ======================
    value3       value4               
    
    column5
    ===========
                value5
    That is to say columns are coming on a single line or header and the value are aligned.

    any thoughts? what I'm missing here?

    Published by: Caitanya November 2, 2009 07:39
    set line  12000;
    set page  500;
    

    Before you run the query, and after you connect to SQLPLUS.

    See you soon!
    Bhushan Salgar

  • Query output to multiple selection data

    I am trying to output the name of the person and the Organization to which they belong. A user can belong to more than one org and org may have multiple users associated with them.

    I have a table of user with user_id, username_txt, password_txt user_org_id fields
    a table of org that has org_id and org_cd
    a user_org table that has a user_org_id, user_id and org_id
    This is how I create the relationship between users and organizations.

    I'm trying out the name of a person and a multiple selection box that has all the orgs that is assigned to a user selected. but the form is to select only a single organization. How can ensure me that the selection box shows the user orgs selected?

    I think I have to do some kind of loop or something else to get all values - I don't know what to do. any help would be appreciated. Thank you!

    See my code:

    With the help of a multiple selection with pre-selected items makes it very easy for users accidentally deselect things.

    But, if you insist, change this:
    SELECTED
    to do this:
    selected = "selected".

  • SQL Query hierarchical select 2 level parent over sheet.

    Here, we use Oracle 11 g R1. Here is a sample of our Tables of the employee.

    I want you select all managers managers above them (which we call the Site Manager) and direct (that we call the Service Manager)

    Here is the example for the base table.

    SET DEFINE OFF;
    CREATE TABLE EMP_SAMPLE 
    (
      AGENT_ID VARCHAR2(100 BYTE) 
    , FULL_NAME VARCHAR2(100 BYTE) 
    , AGENT_MANAGER VARCHAR2(100 BYTE) 
    ) ;
    
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('JS001','JOHN SMITH',null);
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('AL001','ANN LEE','JS001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('JD001','JOHN DOE','AL001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('MB002','MARY BAKER','AL001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('HM003','HOWARD MONROE','MB002');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('RM001','ROBYN MILLER','MB002');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('DJ002','DAVID JONES','RM001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('WW001','WENDY WONG','MB002');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('PB001','PETER RABBIT','JS001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('BB002','BEN BUNNY','PB001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('TM001','TONY MILLER','BB002');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('PP002','PETER PARKER','RM001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('PP003','PEPPA PIG','PB001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('DB002','daniel baker','HM003');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('TL001','Tom Lee','WW001');
    Insert into EMP_SAMPLE (AGENT_ID,FULL_NAME,AGENT_MANAGER) values ('MS001','Mary Smith',null);
    

    With the example like this data, I would like to that the result looks similar to

    Name of the Manager

    MARY BAKER - Manager of the Site

    HOWARD MONROE - Service Manager

    ROBYN MILLER - Service Manager

    WENDY WOND - Service Manager

    PETER RABBIT Site Manager

    BEN BUNNY - Service Manager

    I guess I should use the hierarchical query to achieve this. I googled to see all the solutions, I tried this under request

    SELECT agent_id, agent_manager, RPAD('.', (level-1)*2, '.') || full_name AS tree,
           level, CONNECT_BY_ROOT agent_id as root_id
           ,CONNECT_BY_ISLEAF AS is_leaf
    
    FROM EMP_SAMPLE
    START WITH agent_manager IS NULL
    CONNECT BY agent_manager = PRIOR agent_id
    ORDER SIBLINGS BY agent_id;
    

    But it seems that the level always starts from the root at the top of the page. I wonder, is it possible to identify even just the level two above the sheet.

    Here is some basic information. We are working on our oracle APEX application. One of the reports can be filtered by the Manager. The list currently shows a little all managers, regardless of what they are 1 senior as general manager, or the first line as a Service Manager Manager. Now, users want to be able to select only Service Manager and Site Manager.

    There is a DB work for updating the table Employee of LDAP. And the LDAP structure is not tidy this (we have some staff members who have no Manager, they are not even CEO). The Administrator told us that it is too busy to store it.

    We have about 20,000 employees in total including 800 East of managers.

    Thanks in advance.

    Ann

    Hi, Ann.

    Ann586341 wrote:

    Here, we use Oracle 11 g R1. Here is a sample of our Tables of the employee.

    I want you select all managers managers above them (which we call the Site Manager) and direct (that we call the Service Manager)

    Here is the example for the base table.

    1. TOGETHER TO DEFINE
    2. CREATE TABLE EMP_SAMPLE
    3. (
    4. AGENT_ID VARCHAR2 (100 BYTE)
    5. FULL_NAME VARCHAR2 (100 BYTE)
    6. AGENT_MANAGER VARCHAR2 (100 BYTE)
    7. ) ;
    8. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('JS001', 'JOHN SMITH', null);
    9. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('AL001', "ANN LEE", "JS001");
    10. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('JD001', 'JOHN DOE', "AL001");
    11. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('MB002', "MARY BAKER", "AL001");
    12. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('HM003', 'HOWARD MONROE', 'MB002');
    13. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('RM001", 'ROBYN MILLER', 'MB002');
    14. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('DJ002', 'DAVID JONES', "RM001");
    15. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('WW001', "WENDY WONG", "MB002");
    16. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('PB001', 'PETER RABBIT', "JS001");
    17. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('BB002', "BEN BUNNY", "PB001");
    18. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('TM001', 'TONY MILLER', "BB002");
    19. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('PP002","PETER PARKER","RM001");
    20. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('PP003', 'PEPPA PIG', "PB001");
    21. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('DB002', "daniel baker", "HM003");
    22. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('TL001', "Tom Lee", "WW001");
    23. Insert into EMP_SAMPLE (AGENT_ID, FULL_NAME, AGENT_MANAGER) values ('MS001', 'Mary Smith', null);

    With the example like this data, I would like to that the result looks similar to

    Name of the Manager

    MARY BAKER - Manager of the Site

    HOWARD MONROE - Service Manager

    ROBYN MILLER - Service Manager

    WENDY WOND - Service Manager

    PETER RABBIT Site Manager

    BEN BUNNY - Service Manager

    I guess I should use the hierarchical query to achieve this. I googled to see all the solutions, I tried this under request

    1. SELECT agent_id, agent_manager, RPAD ('.) (', (level 1) * 2, '.') || full_name LIKE tree,
    2. level, agent_id CONNECT_BY_ROOT as root_id
    3. CONNECT_BY_ISLEAF AS is_leaf
    4. OF EMP_SAMPLE
    5. START WITH agent_manager IS NULL
    6. CONNECT BY PRIOR agent_id = agent_manager
    7. Brothers and SŒURS of ORDER BY agent_id;

    But it seems that the level always starts from the root at the top of the page. I wonder, is it possible to identify even just the level two above the sheet.

    Here is some basic information. We are working on our oracle APEX application. One of the reports can be filtered by the Manager. The list currently shows a little all managers, regardless of what they are 1 senior as general manager, or the first line as a Service Manager Manager. Now, users want to be able to select only Service Manager and Site Manager.

    There is a DB work for updating the table Employee of LDAP. And the LDAP structure is not tidy this (we have some staff members who have no Manager, they are not even CEO). The Administrator told us that it is too busy to store it.

    We have about 20,000 employees in total including 800 East of managers.

    Thanks in advance.

    Ann

    Here's one way:

    WITH leaves LIKE

    (

    SELECT agent_id

    Of emp_sample

    LESS

    SELECT agent_manager

    Of emp_sample

    )

    got_lvl AS

    (

    SELECT-full_name agent_id

    LEVEL AS lvl

    Of emp_sample

    START WITH agent_id IN)

    SELECT agent_id

    Sheets

    )

    CONNECTION BY agent_id = agent_manager PRIOR

    )

    SELECT full_name

    CASE

    WHEN MAX (lvl) = 3

    THEN 'Site Manager'

    ANOTHER "Service Manager"

    END AS title

    OF got_lvl

    GROUP BY full_name-, agent_id

    WITH MIN (lvl) > = 2

    AND MAX (lvl)<=>

    ORDER BY full_name

    ;

    Output:

    FULL_NAME TITLE

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

    BEN BUNNY Service Manager

    MONROE HOWARD Service Manager

    MARY BAKER Site Manager

    PETER RABBIT Site Manager

    ROBYN MILLER Service Manager

    WENDY WONG Service Manager

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

    LEVEL does not always begin with the root; It starts with the lines that meet the condition to START WITH.  If you have a START WITH condition that only roots meet (as in the query you posted) then, Yes, LEVEL will start with the roots.  If you have a condition START WITH answering the criteria only the leaves (as in the query I posted), then LEVEL will start with the leaves.

    I guess just some of your needs.  If seems that a 'Site Manager' is the grandparent of a leaf, but "John Smith" (which is the grandmother of "John Doe", a sheet) is not considered to be a 'Site Manager'.  Similarly, it seems that a 'Service Manager' is the parent (but not the grand-parent) of the leaf, but "Ann Lee" (the mother of "John Doe") is not considered to be a 'Service Manager' for a reason any.

    I guess that full_name is unique.  If full_name is not unique, but agent_id is, then you will need a comment a few line above ends.  (I guess that agent_id is unique and not NULL).

  • Need of below query output

    WITH rcv_transactions 
         AS (SELECT 1001      TRANSACTIONS_ID, 
                    -1        PARENT_TRANSACTION_ID, 
                    'RECEIVE' TRANSACTION_TYPE, 
                    NULL      LPN_ID, 
                    'LPN01'   TRANSFER_LPN_ID 
             FROM   dual 
             UNION ALL 
             SELECT 1002, 
                    1001, 
                    'DELIVER', 
                    'LPN01', 
                    'LPN01' 
             FROM   dual 
             UNION ALL 
             SELECT 1003, 
                    -1, 
                    'RECEIVE', 
                    NULL, 
                    'LPN01' 
             FROM   dual) 
    SELECT * 
    FROM   rcv_transactions; 
    
    My output for the above query is 
    
    transactions_id   parent_transaction_id   transaction_type     lpn_id     transfer_lpn_id
    ---------------------------------------------------------------------------
    1001                        -1                          receive                                 lpn01
    1002                    1001                           deliver                  lpn01      lpn01
    1003                         -1                         receive                                lpn01
    
    
    I want the output as below:
     TRANSACTIONS_ID,   PARENT_TRANSACTION_ID,  TRANSACTION_TYPE,     LPN_ID,     TRANSFER_LPN_ID, 
    1003                                    -1                                   RECEIVE                                   LPN01
    
    i.e., I want the transactions id which are only 'receive' and not 'deliver' for the particular transfer_lpn_id
    
    in the above scenario 1001 is received and delivered in 1002. 
    
    But 1003 is only received. so  I need the output of 1003
    WITH rcv_transactions AS (SELECT 1001 TRANSACTIONS_ID,
                                     -1 PARENT_TRANSACTION_ID,
                                     'RECEIVE' TRANSACTION_TYPE,
                                     NULL LPN_ID,
                                     'LPN01' TRANSFER_LPN_ID
                                FROM DUAL
                              UNION ALL
                              SELECT 1002,
                                     1001,
                                     'DELIVER',
                                     'LPN01',
                                     'LPN01'
                                FROM DUAL
                              UNION ALL
                              SELECT 1003,
                                     -1,
                                     'RECEIVE',
                                     NULL,
                                     'LPN01'
                                FROM DUAL)
    SELECT *
      FROM rcv_transactions rcv_out
     WHERE rcv_out.transaction_type = 'RECEIVE'
           AND NOT EXISTS
                  (SELECT 1
                     FROM rcv_transactions
                    WHERE parent_transaction_id = rcv_out.TRANSACTIONS_ID)
    
  • Filtering of query output

    Hi, I use developer Forms 10 g and I learned recently from the with... As command. I have an exit that gives the details of a particular query executed; Here's my query:

    {WITH months LIKE)
    SELECT ADD_MONTHS(:V_DATE_FROM,LEVEL-1) m_first
    M_last (ADD_MONTHS(:V_DATE_FROM, LEVEL-0)-1)
    OF the double
    CONNECT BY LEVEL < MONTHS_BETWEEN(:V_DATE_TO,:V_DATE_FROM) + 1
    )
    load_per_month AS)
    SELECT conn_load
    SUM (conn_load) max_conn_load
    m_LASt
    CIRCUIT_code, substation_code, classification
    FROM (SELECT substr (c1. CIRCUIT_code, 1, 5) circuit_code, max (c1.connected_load) conn_load,.
    C1.classification, m_LAst, c1.substation_code
    SINCE CROSS JOIN SPM_CIRCUITS c1
    WHERE the c1.date_commission < = m_last
    AND (c1.date_decommission > m_first)
    GOLD date_decommission IS NULL)
    AND SUBSTR(c1.substation_code,6,4) IN ('N002")
    GROUP BY substr (c1. CIRCUIT_code, 1, 5).
    C1.classification, m_LAst, substation_code
    )
    Conn_load, m_last, CIRCUIT_code, substation_code, classification group)
    * SELECT NVL (SUM (NVL(conn_load,0)), 0) connected_load, m_LASt *.
    *, CIRCUIT_code, substation_code, classification *.
    * From load_per_month *.
    * WHERE conn_load = max_conn_load *.
    * GROUP OF M_LAST, CIRCUIT_code, substation_code, classification *.
    * ORDER BY m_LASt, CIRCUIT_code *;
    }

    The above query gives a power of connected load values, substation_code and classification for each circuit_code of the year grouped into months.

    And in the above query if I changed the my Select command (in bold) to this:

    SELECT MAX (load)
    Of
    *(*
    SELECT NVL (SUM (NVL(conn_load,0)), 0) connected_load
    *, m_LAst. *
    OF load_per_month
    WHERE conn_load = max_conn_load
    GROUP BY m_LAst
    ORDER BY m_LAst
    *)*

    I get an output value of 279, which corresponds to the total of the load for the month of November (total monthly high for the year). I want to show well that are the specific columns (connected_load, m_LASt, CIRCUIT_code, substation_code, classification) of that particular month. How can I do this? Thank you very much.

    Thank you guys! I, atlas, created the query by trail and error Phew!

Maybe you are looking for

  • Why can't iOS on my iPad Pro 9.3.2

    I would like to know why I am unable to get the new operating system on my iPad 9.7 Pro 9.3.2!

  • Need help to find the drivers for windows 7 | Pavilion | G6-2132nr

    I have recently reinstalled windows premium 7 on my computer portable pavilion g6-2132nr. It does not connect to ethernet (LAN) / all internet when it had done before. I checked the drivers on the subject and they are installed, I tried to install th

  • Satellite A100-225: Question about upgrade up to 4 GB of RAM

    I'm confused. Very confused. I myself have an A100-225 and browse the documentation, I noticed that even if it comes with 1 GB DDR2 533 Mhz RAM, the maximum memory (RAM?) system upgrade it will take is cited as an impressive 4 Gb 'Cool' think me "I w

  • Need new DVD player for Satellite A30

    Hello! I am looking for the replacement of the mat of DVD - RAM * a UJ-811 in my Satellite A30-303.What models of DVD (rw) are compatibleThank you Lukas

  • ENVY DV4 Internet troubles

    I got this computer since Christmas and since it is nothing but trouble, especially with the Internet. All started saying I was connected when I wasn't really. Then it would just connect. These two questions were annoying, but temporary. They may las