SQL*Plus: compute sum of tablespaces; incorrect figures

Hi,
I wonder if someone would be interested in checking the below script.
It is from Darl Kuhn's book 'Pro Oracle Database 11g Administration' (page 81) , and the code can be freely
downloaded from Apress' website, so I guess it's OK to post it here. I assume it's a standard script most DBA's have, anyway.
SET PAGESIZE 300 LINES 132 ECHO OFF VERIFY OFF FEEDB OFF SPACE 1 TRIMSP ON
COMPUTE SUM OF a_byt t_byt f_byt ON REPORT
BREAK ON REPORT ON tablespace_name ON pf
COL tablespace_name FOR A17   TRU HEAD 'Tablespace|Name'
COL file_name       FOR A40   TRU HEAD 'Filename'
COL a_byt           FOR 9,990.999 HEAD 'Allocated|GB'
COL t_byt           FOR 9,990.999 HEAD 'Current|Used GB'
COL f_byt           FOR 9,990.999 HEAD 'Current|Free GB'
COL pct_free        FOR 990.0     HEAD 'File %|Free'
COL pf              FOR 990.0     HEAD 'Tbsp %|Free'
COL seq NOPRINT
DEFINE b_div=1073741824
select * from (
SELECT 1 seq, b.tablespace_name, nvl(x.fs,0)/y.ap*100 pf, b.file_name file_name,
  b.bytes/&&b_div a_byt, NVL((b.bytes-SUM(f.bytes))/&&b_div,b.bytes/&&b_div) t_byt,
  NVL(SUM(f.bytes)/&&b_div,0) f_byt, NVL(SUM(f.bytes)/b.bytes*100,0) pct_free
FROM dba_free_space f, dba_data_files b
,(SELECT y.tablespace_name, SUM(y.bytes) fs
   FROM dba_free_space y GROUP BY y.tablespace_name) x
,(SELECT x.tablespace_name, SUM(x.bytes) ap
   FROM dba_data_files x GROUP BY x.tablespace_name) y
WHERE f.file_id(+) = b.file_id
AND   x.tablespace_name(+) = y.tablespace_name
and   y.tablespace_name =  b.tablespace_name
AND   f.tablespace_name(+) = b.tablespace_name
GROUP BY b.tablespace_name, nvl(x.fs,0)/y.ap*100, b.file_name, b.bytes
UNION
SELECT 2 seq, tablespace_name,
  j.bf/k.bb*100 pf, b.name file_name, b.bytes/&&b_div a_byt,
  a.bytes_used/&&b_div t_byt, a.bytes_free/&&b_div f_byt,
  a.bytes_free/b.bytes*100 pct_free
FROM v$temp_space_header a, v$tempfile b
  ,(SELECT SUM(bytes_free) bf FROM v$temp_space_header) j
  ,(SELECT SUM(bytes) bb FROM v$tempfile) k
WHERE a.file_id = b.file#
ORDER BY 1,2,4,3);The thing is, if I run this on our production database (Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi)
I get individually correct rows, but the sumline is incorrect:
Tablespace        Tbsp %                                           Allocated    Current    Current File %
Name                Free Filename                                         GB    Used GB    Free GB   Free
plenty of rows like this here...
SCDAT               12.4 /oracle/SCDT/data/SCDT/c_scdat01.dbf         10.000      8.944      1.056   10.6
                         /oracle/SCDT/data/SCDT/c_scdat02.dbf         10.000      8.875      1.125   11.3
                         /oracle/SCDT/data/SCDT/c_scdat03.dbf         10.000      8.820      1.180   11.8
                         /oracle/SCDT/data/SCDT/c_scdat04.dbf         10.000      8.819      1.181   11.8
                         /oracle/SCDT/data/SCDT/c_scdat05.dbf         10.000      8.787      1.213   12.1
                         /oracle/SCDT/data/SCDT/c_scdat06.dbf         10.000      8.792      1.208   12.1
                         /oracle/SCDT/data/SCDT/c_scdat07.dbf         10.000      8.508      1.492   14.9
then the summing row shows (for AllocatedGB, CurrentGB and CurrentFreeGB)
                                                                 1,155.000     858     179The thing is that this isn't correct. Firstly; current free isn't equal to allocated - currently used.
Secondly, if I sum all the rows in a spreadsheet, they are
1171.668 931.897 239.758
Do you get similiar results, i.e. the script sums incorrectly?
If yes, can anybody spot the error? I can't..
Thanks very much!

Slow_moe wrote:
Tablespace        Tbsp %                                           Allocated    Current    Current File %
Name                Free Filename                                         GB    Used GB    Free GB   Free
plenty of rows like this here...
SCDAT               12.4 /oracle/SCDT/data/SCDT/c_scdat01.dbf         10.000      8.944      1.056   10.6
/oracle/SCDT/data/SCDT/c_scdat02.dbf         10.000      8.875      1.125   11.3
/oracle/SCDT/data/SCDT/c_scdat03.dbf         10.000      8.820      1.180   11.8
/oracle/SCDT/data/SCDT/c_scdat04.dbf         10.000      8.819      1.181   11.8
/oracle/SCDT/data/SCDT/c_scdat05.dbf         10.000      8.787      1.213   12.1
/oracle/SCDT/data/SCDT/c_scdat06.dbf         10.000      8.792      1.208   12.1
/oracle/SCDT/data/SCDT/c_scdat07.dbf         10.000      8.508      1.492   14.9
then the summing row shows (for AllocatedGB, CurrentGB and CurrentFreeGB)
1,155.000     858     179The thing is that this isn't correct. Firstly; current free isn't equal to allocated - currently used.Looks like it is to me, and I just worked it out in my head.
Secondly, if I sum all the rows in a spreadsheet, they are
1171.668 931.897 239.758How do you know the spreadsheet is right and hasn't rounded up/down some figures?

Similar Messages

  • Simple PL/SQL Report - Using Break on and Compute Sum - Not So Simple

    Good morning, All:
    I have a simple pl/sql report that is not so simple. Basic on the code below, would like to add a blank line/row after the resulting "sum" row to make it easier to read. Any and all help would be appreciated.
    Thank you.
    Preston@Large
    Code:
    =======================
    BREAK ON ALM_OG_CAMPAIGN_CODE
    COMPUTE SUM OF ALM_OG_AMOUNT ON ALM_OG_CAMPAIGN_CODE
    set linesize 1024
    set pagesize 60
    set newpage 0
    set serveroutput on
    SPOOL &so_outfile;
    ttitle center 'Wayne State University' skip 1 Left 'WSU Online Giving Essentials Report' skip 2
    select TO_CHAR(sysdate, 'mm/dd/yyyy hh:mm AM') "Report Date" from dual;
    CLEAR COLUMNS
    column ALM_OG_ACCI_CODE heading "ACCI|CODE" format a10
    column ALM_OG_AMOUNT heading "AMOUNT|DONATED" format $999,999,999.99
    column ALM_OG_CAMPAIGN_CODE heading "CAMPAIGN|CODE" format a14
    select
    ALM_OG_CAMPAIGN_CODE,
    ALM_OG_ACCI_CODE,
    ALM_OG_AMOUNT
    From WSUALUMNI.WSU_ONLINE_GIVING_TABLE
    ORDER BY ALM_OG_CAMPAIGN_CODE;
    CLEAR COLUMNS
    spool off
    Output:
    WSU Online Giving Essentials Report
    Report Date
    ======================
    06/05/2009 10:06 AM
    1 row selected.
    Wayne State University
    WSU Online Giving Essentials Report
    CAMPAIGN ACCI AMOUNT
    CODE CODE DONATED
    ====== ======== ==========
    sum $560.00
    NUR 444814 $10.00
    ***** =======
    sum $10.00
    PHS 445216 $10.00
    ***** =======
    sum $10.00
    PRES 445211 $450.00
    445211 $60.00
    445211 $250.00
    ***** =======
    sum $760.00
    SBA 444216 $10.00
    ***** =======
    sum $10.00
    SSW 444469 $10.00
    ***** =======
    sum $10.00

    Prestone,
    Welcome to the Forum!
    I have used skip 2 lines you can use 1
    SQL> break on job report skip 2
    SQL> compute sum of sal on job report
    SQL> select job , sal from emp order by job ;
    JOB              SAL
    ANALYST         3000
                    3000
    sum             6000
    CLERK           1300
                     950
                     800
                    1100
    sum             4150
    MANAGER         2850
                    2975
                    2450
    sum             8275
    PRESIDENT       5000
    sum             5000
    SALESMAN        1500
                    1250
                    1250
                    1600
    sum             5600
    14 rows selected.READ
    Quick SQL*Plus Guide
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12171/toc.htm
    SQL*Plus Reference
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/toc.htm
    SS

  • SQL*PLUS console not coming back when create a tablespace in ORACLE RAC11g

    Hi all,
    I have run a create command in oracle RAC 11g system (2 nodes, ASM) by SQL*PLUS, every datafile for this tablespace is 1.5GB, I want to create 6 tablespace at the first:
    1. It run successfully for the first tablespace , it toook 4-5 minutes to come back;
    2. It run much longer time for the second tablespace , it took over 20 minutes to come back;
    3. The third tablespace , I waited for 45 minutes and it didn't come back.
    I have check in alert.log, and saw all three tablespace were successfully created about 4-5 minutes. And I also use another SQL*PLUS to query in user_tablespaces. the third tablespace did display in user_tablespaces view.
    From that time, I tried 4,5,6, it took me 30 minutes to create 1.5GB big tablespace. It doesn't make sense for me.
    Any sugguestion? Thanks.

    How did they create the disk group?
    How big are the devices/LUNs?
    are all of the LUNS the same size?
    Check the alert log for both the RDBMS and ASM.
    What redundancy did they use?
    in asmca, what is the total size of the disk group(s)? ( or sum total_mb from v$asm_diskgroup for each disk group)

  • SQL Plus Bug/Question: 'COMPUTE' command does not work in script.(BUG?!)

    Good Day to ALL!
    I have a script of SQLPlus that creates a report. I have 8/9 numeric columns which are 'SUM'ed up thru 'COMPUTE' command. It works for all BUT 2 columns. If I put these two columns, compute does not take affect. If I remove these two columns ( just cut) 'COMPUTE' works fine!!! These two coulumns use DB Function. But I have other column that also use DB Function. These two columns has some extra additions. Any thing wrong with the script/column defn.
    Thanks - Pradip (Pradip Biswas @Singapore) Could you pl. reply to [email protected]
    Here is bit of script. Sorry about the length of the cut and paste.
    COLUMN OPEN_QTY_BAL           FORMAT 9,99,990          HEADING 'Opening|Qty'           Justify LEFT
    COLUMN OPEN_QTY_VALUE          FORMAT 99,999,990      HEADING 'Opening|S$'           Justify LEFT
    COLUMN PO_RECEIPTS_QTY      FORMAT 99,990          HEADING 'PO Rec|QTY '          Justify LEFT
    COLUMN PO_RECEIPTS_QTY_VALUE     FORMAT 9,999,990      Heading 'PO Rec|S$'           Justify LEFT
    COLUMN MISC_RECEIPTS_QTY     Format 99,990          Heading 'Misc |Qty'          Justify LEFT
    Column MISC_RECEIPTS_QTY_VALUE      Format 9,999,990      Heading 'Misc|S$'          Justify LEFT
    COLUMN WORKORDER_QTY           FORMAT 99,990          HEADING 'WorkOrd|Qty'          Justify LEFT
    COLUMN WorkOrder_QTY_VALUE      Format 9,999,990      HEADING 'WorkOrd|S$'          Justify LEFT
    COLUMN SALES_SHIPMENT_QTY      FOrmat 99,990          Heading 'SalesShip|Qty'          Justify LEFT
    COLUMN SALES_SHIPMENT_QTY_VALUE FOrmat 9,999,990      Heading 'SalesShip|S$'          Justify LEFT
    COLUMN MISC_ISSUE_QTY     Format 99,999          HEADing 'Misc|Qty'          Justify LEFT
    COLUMN MISC_ISSUE_QTY_VALUE Format 9,999,990 heading 'Misc|S$'          Justify LEFT
    COLUMN TRANSFER_QTY          format 99,990          heading 'Transfer|Qty'          Justify LEFT
    COLUMN TRANSFER_QTY_VALUE     format 99,999,990     heading 'Transfer|S$'          Justify LEFT
    COLUMN REVAL_VALUE Format 99,990          Heading 'Reval|S$'          Justify LEFT
    COLUMN ON_HAND_QTY           FORMAT 9,99,990      HEADING 'Closing|Qty'           Justify LEFT
    COLUMN ON_HAND_QTY_VALUE     FORMAT 99,999,999,990      HEADING 'Closing|S$'           Justify LEFT
    REPHEADER on
    REPHEADER left ' GL Period From: &&P_GL_PERIOD_NAME_FROM ' skip left ' GL Period To : &&P_GL_PERIOD_NAME_TO ' skip left ' Inv Org Code : &&P_INV_ORG_CODE ' skip left 'SubInventory Code : &&P_SUBINVENTORY_CODE ' skip 2
    TTITLE left 'H - Inv Inventory Movement Report as at:' TTITLE_DATE RIGHT 'PAGE:' FORMAT 999 SQL.PNO SKIP 2
    BTITLE skip 1 CENTER 'COMPANY CONFIDENTIAL - Printed on ' TTITLE_DATE
    BREAK on REPORT skip 1;
    --rem(1) compute SUM label 'Total' of OPEN_QTY_VALUE PO_RECEIPTS_QTY_VALUE MISC_RECEIPTS_QTY_VALUE WorkOrder_QTY_VALUE SALES_SHIPMENT_QTY_VALUE MISC_ISSUE_QTY_VALUE TRANSFER_QTY_VALUE REVAL_VALUE on report;
    --REM(2) compute SUM label 'Total $S: ' of OPEN_QTY_VALUE REVAL_VALUE on report;
    --REM(3) compute SUM label 'Total $S: ' of OPEN_QTY_VALUE REVAL_VALUE  ON_HAND_QTY_VALUE on report;
    compute SUM label 'Total $S:' of OPEN_QTY_VALUE PO_RECEIPTS_QTY_VALUE MISC_RECEIPTS_QTY_VALUE WorkOrder_QTY_VALUE SALES_SHIPMENT_QTY_VALUE MISC_ISSUE_QTY_VALUE TRANSFER_QTY_VALUE REVAL_VALUE on report;
    WHENEVER SQLERROR EXIT FAILURE
    select
    --     MSI.ORGANIZATION_ID                          ORGANIZATION_ID,
    -- MSI.INVENTORY_ITEM_ID                                   INVENTORY_ITEM_ID,
         MSI.SEGMENT1||'//'||MSI.DESCRIPTION                                   ITEM,
    -- MSI.DESCRIPTION                                             DESCRIPTION,
    All_Item_subinv.SUBINVENTORY_CODE                              SUBINVENTORY,
    MSIV.PRIMARY_UOM_CODE                                        UOM,
         --NVL(MOQ_OPen_BAL.OPEN_QTY_BAL ,0)                               OPEN_QTY_BAL ,
    -- NVL(MOQ_OPen_BAL.OPEN_QTY_BAL,0) * NVL(AVG_ITEM_COST1.ITEM_COST,0)           OPEN_QTY_VALUE,
    (MOQ_OPen_BAL( All_Item_subinv.SUBINVENTORY_CODE,
              MSI.ORGANIZATION_ID,
    MSI.INVENTORY_ITEM_ID,
    '&P_GL_PERIOD_NAME_FROM') )     OPEN_QTY_BAL ,
    (MOQ_OPen_BAL_VAL( All_Item_subinv.SUBINVENTORY_CODE,
              mSI.ORGANIZATION_ID,
    MSI.INVENTORY_ITEM_ID,
    '&P_GL_PERIOD_NAME_FROM')
         )                                             OPEN_QTY_VALUE,
    NVL(AGGREGATED_MTT.PO_RECEIPTS_QTY,0)                              PO_RECEIPTS_QTY,
         NVL(AGGREGATED_MTT.PO_RECEIPTS_QTY_VALUE,0)                          PO_RECEIPTS_QTY_VALUE,
         NVL(AGGREGATED_MTT.MISC_RECEIPTS_QTY,0)                              MISC_RECEIPTS_QTY,
         NVL(AGGREGATED_MTT.MISC_RECEIPTS_QTY_VALUE,0)                          MISC_RECEIPTS_QTY_VALUE,
         NVL(AGGREGATED_MTT.WORKORDER_QTY,0)                              WORKORDER_QTY,
         NVL(AGGREGATED_MTT.WorkOrder_QTY_VALUE,0)                          WorkOrder_QTY_VALUE,
    NVL(AGGREGATED_MTT.SALES_SHIPMENT_QTY,0)                         SALES_SHIPMENT_QTY,
         NVL(AGGREGATED_MTT.SALES_SHIPMENT_QTY_VALUE,0)                         SALES_SHIPMENT_QTY_VALUE,
         NVL(AGGREGATED_MTT.MISC_ISSUE_QTY,0)                              MISC_ISSUE_QTY,
         NVL(AGGREGATED_MTT.MISC_ISSUE_QTY_VALUE,0)                          MISC_ISSUE_QTY_VALUE,
         NVL(AGGREGATED_MTT.TRANSFER_QTY,0)                              TRANSFER_QTY,
         NVL(AGGREGATED_MTT.TRANSFER_QTY_VALUE,0)                         TRANSFER_QTY_VALUE,
         NVL(AGGREGATED_MTT.REVAL_VALUE,0)                              REVAL_VALUE,
              (MOQ_OPen_BAL(All_Item_subinv.SUBINVENTORY_CODE,
              MSI.ORGANIZATION_ID,
    MSI.INVENTORY_ITEM_ID,
    '&P_GL_PERIOD_NAME_FROM')
              +
              nvl(AGGREGATED_MTT.PO_RECEIPTS_QTY,0)      +
              nvl(AGGREGATED_MTT.MISC_RECEIPTS_QTY,0)     +
              nvl(AGGREGATED_MTT.WORKORDER_QTY,0)     +
              nvl(AGGREGATED_MTT.SALES_SHIPMENT_QTY,0)     +
              nvl(AGGREGATED_MTT.MISC_ISSUE_QTY,0)          +
              nvl(AGGREGATED_MTT.TRANSFER_QTY,0)     )                ON_HAND_QTY,
    ((MOQ_OPen_BAL_VAL( All_Item_subinv.SUBINVENTORY_CODE,MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID,'&P_GL_PERIOD_NAME_FROM'))
    +(nvl( AGGREGATED_MTT.PO_RECEIPTS_QTY_VALUE,0) )     
    +(nvl( AGGREGATED_MTT.MISC_RECEIPTS_QTY_VALUE,0) )
    +(nvl( AGGREGATED_MTT.WorkOrder_QTY_VALUE,0) )
    +(nvl( AGGREGATED_MTT.sALES_SHIPMENT_QTY_VALUE,0) )
    +(nvl( AGGREGATED_MTT.MISC_ISSUE_QTY_VALUE,0) )
    +(nvl( AGGREGATED_MTT.TRANSFER_QTY_VALUE,0) )
    +nvl( AGGREGATED_MTT.REVAL_VALUE,0))                               ON_HAND_QTY_VALUE -- column alias
    FROM
    -- In line View for MSI
    (select distinct MMT.ORGANIZATION_ID, MMT.INVENTORY_ITEM_ID, MMT.SUBINVENTORY_CODE
    From MTL_MATERIAL_TRANSACTIONS      MMT,
    ORG_ORGANIZATION_DEFINITIONS      OOD,
    MTL_ONHAND_QUANTITIES moq
    where
         OOD.organization_code           = '&P_INV_ORG_CODE' --'HS' --'&P_INV_ORG_CODE'
    AND OOD.inventory_enabled_flag = 'Y'
    AND OOD.operating_unit          = fnd_profile.value('ORG_ID') --83 --fnd_profile.value('ORG_ID')
    AND OOD.SET_OF_BOOKS_ID          = fnd_profile.value('GL_SET_OF_BKS_ID') --1 --fnd_profile.value('GL_SET_OF_BKS_ID')
    AND     MMT.ORGANIZATION_ID          = OOD.organization_id
    AND MMT.SUBINVENTORY_CODE          = NVL('&P_SUBINVENTORY_CODE', MMT.SUBINVENTORY_CODE)
    and MMT.ORGANIZATION_ID      = MOQ.ORGANIZATION_ID -- to eliminate consigend items:2007Jan04:PKB
    and MMT.INVENTORY_ITEM_ID = MOQ.INVENTORY_ITEM_ID --,,
    and MMT.SUBINVENTORY_CODE = MOQ.SUBINVENTORY_CODE --,,
    UNION
    Select distinct      MOQ.ORGANIZATION_ID,      MOQ.INVENTORY_ITEM_ID,     MOQ.SUBINVENTORY_CODE
    from      MTL_ONHAND_QUANTITIES                MOQ,
         ORG_ORGANIZATION_DEFINITIONS           OOD2
    WHERE
         OOD2.organization_code           = '&P_INV_ORG_CODE' --'HS' --'&P_INV_ORG_CODE'
    AND OOD2.inventory_enabled_flag      = 'Y'
    AND OOD2.operating_unit          = fnd_profile.value('ORG_ID') --83 --fnd_profile.value('ORG_ID')
    AND OOD2.SET_OF_BOOKS_ID          = fnd_profile.value('GL_SET_OF_BKS_ID') --1 --fnd_profile.value('GL_SET_OF_BKS_ID')
    AND moq.ORGANIZATION_ID          = OOD2.organization_id
    AND moq.SUBINVENTORY_CODE          = NVL('&P_SUBINVENTORY_CODE', moq.SUBINVENTORY_CODE)
    ) ALL_Item_SUBInv,
    MTL_SYSTEM_ITEMS_B MSI,
    Mtl_System_Items_Vl MSIV,
    (SELECT
         MMT.ORGANIZATION_ID ORGANIZATION_ID,
    MMT.INVENTORY_ITEM_ID          INVENTORY_ITEM_ID,
    MMT.SUBINVENTORY_CODE          SUBINVENTORY_CODE,
    -- PO RECEIPTS.
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Purchase order')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('PO Receipt','PO Rcpt Adjust','Return to Vendor')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) PO_RECEIPTS_QTY,
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Purchase order')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('PO Receipt','PO Rcpt Adjust','Return to Vendor')
    THEN
                   NVL(MMT.ACTUAL_COST,0)* nvl(mmt.primary_quantity,0)
                   MMT.TRANSACTION_COST * NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) PO_RECEIPTS_QTY_VALUE,
    -- MISC RECEIPTS.
    SUM( CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Account','Inventory')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Account receipt','Miscellaneous receipt')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) MISC_RECEIPTS_QTY,
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Account', 'Inventory')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Account receipt','Miscellaneous receipt')
    THEN
                   NVL(MMT.ACTUAL_COST,0) * nvl(mmt.primary_quantity,0)
                        MMT.TRANSACTION_COST NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) MISC_RECEIPTS_QTY_VALUE,
    -- WorkOrder Qty and S$
    SUM( CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Job or Schedule')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('WIP Assembly Return','WIP Assy Completion','WIP component issue','WIP Component Return')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) WORKORDER_QTY,
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Job or Schedule')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('WIP Assembly Return','WIP Assy Completion','WIP component issue','WIP Component Return')
    THEN
                   NVL(MMT.ACTUAL_COST,0) * nvl(mmt.primary_quantity,0)
                        MMT.TRANSACTION_COST NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) WorkOrder_QTY_VALUE,
    -- Sales Shipment
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ( 'Sales order','RMA')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Sales order issue','Sales Order Pick','RMA Return','RMA Receipt')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) SALES_SHIPMENT_QTY,
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ( 'Sales order','RMA')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Sales order issue','Sales Order Pick','RMA Return','RMA Receipt')
    THEN
                   NVL(MMT.ACTUAL_COST,0) * nvl(mmt.primary_quantity,0)
                   MMT.TRANSACTION_COST NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) SALES_SHIPMENT_QTY_VALUE,
    -- MISC ISSUE
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Inventory','Account' )
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Miscellaneous issue','Account issue')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) MISC_ISSUE_QTY,
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ('Inventory','Account' )
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Miscellaneous issue','Account issue')
    THEN
                   NVL(MMT.ACTUAL_COST,0) * nvl(mmt.primary_quantity,0)
                   MMT.TRANSACTION_COST NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) MISC_ISSUE_QTY_VALUE,
    -- Transfers
    SUM( CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ( 'Inventory' )
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Subinventory Transfer')
    THEN
                   --MMT.TRANSACTION_QUANTITY
                   mmt.primary_quantity
    ELSE 0
    END
    ELSE 0
    END ) TRANSFER_QTY,
    SUM( CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ( 'Inventory')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Subinventory Transfer')
    THEN      NVL(MMT.ACTUAL_COST,0) * nvl(mmt.primary_quantity,0)
                   MMT.TRANSACTION_COST NVL(AVG_ITEM_COST.ITEM_COST,0)
    ELSE 0
    END
    ELSE 0
    END ) TRANSFER_QTY_VALUE,
    -- Adjustment to Cost (Revaluation)
    SUM(CASE
         WHEN MTST.TRANSACTION_SOURCE_TYPE_NAME in
    ( 'Standard cost update','Job or Schedule')
         THEN
              CASE
              WHEN MTT.TRANSACTION_TYPE_NAME in
    ('Standard cost update','WIP cost update')
    THEN
                   --2007JAN03:PKB MMT.TRANSACTION_COST
    MMT.TRANSACTION_COST* MMT.QUANTITY_ADJUSTED
    ELSE 0
    END
    ELSE 0
    END ) REVAL_VALUE
         FROM
         MTL_MATERIAL_TRANSACTIONS                MMT,
         --GL_PERIODS                          GP,
         MTL_TRANSACTION_TYPES                MTT,
         MTL_TXN_SOURCE_TYPES                    MTST,
    ORG_ORGANIZATION_DEFINITIONS                OOD
    WHERE     
    OOD.organization_code           = '&P_INV_ORG_CODE' --'HS' --'&P_INV_ORG_CODE'
    AND OOD.inventory_enabled_flag = 'Y'
    AND OOD.operating_unit          = fnd_profile.value('ORG_ID') --83 --fnd_profile.value('ORG_ID')
    AND OOD.SET_OF_BOOKS_ID          = fnd_profile.value('GL_SET_OF_BKS_ID') --1 --fnd_profile.value('GL_SET_OF_BKS_ID')
    AND     MMT.ORGANIZATION_ID          = OOD.organization_id
    AND MMT.SUBINVENTORY_CODE          = NVL('&P_SUBINVENTORY_CODE', MMT.SUBINVENTORY_CODE)
    -- AND GP.PERIOD_SET_NAME          = 'HF-ACCTG-CAL' -- Hardcoded PKB
    AND
         (     (EXISTS
         ( select GP.Period_name
    FROM GL_PERIODS GP
    where TO_DATE(TO_CHAR(MMT.TRANSACTION_DATE,'DD-MM-YYYY'),'DD-MM-YYYY')
                   >= TO_DATE(TO_CHAR(GP.START_DATE,'DD-MM-YYYY'),'DD-MM-YYYY') --Between GP.START_DATE and GP.END_DATE
         AND GP.PERIOD_NAME      = '&P_GL_PERIOD_NAME_FROM'
              and GP.PERIOD_SET_NAME          = 'HF-ACCTG-CAL'
    AND NVL('&P_GL_PERIOD_NAME_FROM','ALL')      != 'ALL'
    OR (NVL('&P_GL_PERIOD_NAME_FROM' ,'ALL')               = 'ALL')
    AND
         (     (EXISTS
         ( select GP.Period_name
    FROM GL_PERIODS GP
    where TO_DATE(TO_CHAR(MMT.TRANSACTION_DATE,'DD-MM-YYYY'),'DD-MM-YYYY')
                   <= TO_DATE(TO_CHAR(GP.END_DATE,'DD-MM-YYYY'),'DD-MM-YYYY')
         AND GP.PERIOD_NAME      = '&P_GL_PERIOD_NAME_TO'
              and GP.PERIOD_SET_NAME          = 'HF-ACCTG-CAL'
    AND NVL('&P_GL_PERIOD_NAME_TO','ALL')      != 'ALL'
    OR (NVL('&P_GL_PERIOD_NAME_TO','ALL')               = 'ALL')
    AND MMT.TRANSACTION_TYPE_ID          = MTT.TRANSACTION_TYPE_ID
    AND MMT.TRANSACTION_SOURCE_TYPE_ID          = MTST.TRANSACTION_SOURCE_TYPE_ID
    group by
         MMT.ORGANIZATION_ID,
    MMT.INVENTORY_ITEM_ID,
    MMT.SUBINVENTORY_CODE
    )                    AGGREGATED_MTT,
    -- Inline Table for AVG_ITEM_COSTs 2nd time,
    (SELECT
         CIC.ORGANIZATION_ID     ORGANIZATION_ID,
    CIC.INVENTORY_ITEM_ID INVENTORY_ITEM_ID,
    CIC.COST_TYPE_ID COST_TYPE_ID,
    CCT.COST_TYPE     COST_TYPE,
    NVL(CIC.ITEM_COST ,0) ITEM_COST
    FROM
         CST_ITEM_COSTS           CIC,
         CST_COST_TYPES           ccT,
    ORG_ORGANIZATION_DEFINITIONS                OOD1
    WHERE
         CCT.COST_TYPE_ID           = CIC.COST_TYPE_ID
         /*AND (
         (CCT.COST_TYPE          = 'Average' and '&P_INV_ORG_CODE' = 'HS')
              OR
    (CCT.COST_TYPE          = 'Frozen' and '&P_INV_ORG_CODE' = 'HL')
    AND CCT.COST_TYPE_ID =
              ( select      m.primary_cost_method
              from      mtl_parameters m
    where      m.organization_id      = OOD1.ORGANIZATION_ID
         and OOD1.organization_code      = '&P_INV_ORG_CODE' --'HS' --'&P_INV_ORG_CODE'
         AND OOD1.inventory_enabled_flag = 'Y'
         AND OOD1.operating_unit          = fnd_profile.value('ORG_ID') 83 --fnd_profile.value('ORG_ID')
         AND OOD1.SET_OF_BOOKS_ID     = fnd_profile.value('GL_SET_OF_BKS_ID') 1 --fnd_profile.value('GL_SET_OF_BKS_ID')
         AND cic.ORGANIZATION_ID          = OOD1.organization_id
         )                               AVG_ITEM_COST1
    WHERE
    AGGREGATED_MTT.ORGANIZATION_ID(+)          = All_Item_subinv.ORGANIZATION_ID
    AND AGGREGATED_MTT.INVENTORY_ITEM_ID(+) = All_Item_subinv.INVENTORY_ITEM_ID
    AND AGGREGATED_MTT.subinventory_code(+)     = All_Item_subinv.subinventory_code
    AND All_Item_subinv.ORGANIZATION_ID          = MSI.ORGANIZATION_ID
    AND ALL_Item_SUBInv.INVENTORY_ITEM_ID          = MSI.INVENTORY_ITEM_ID
    AND AVG_ITEM_COST1.ORGANIZATION_ID(+)     = MSI.ORGANIZATION_ID
    AND AVG_ITEM_COST1.INVENTORY_ITEM_ID(+)      = MSI.INVENTORY_ITEM_ID
    and msi.ROWID                         = MSIV.ROW_ID
    and msi.ORGANIZATION_ID                    = fnd_profile.value('ORG_ID') --83 --fnd_profile.value('ORG_ID')
    and sysdate between NVL(msi.start_date_active,sysdate -1 )
    and NVL(msi.end_date_active,sysdate+1)
    Order BY
         MSI.SEGMENT1,
    MSI.DESCRIPTION     ,
    All_Item_subinv.SUBINVENTORY_CODE
    /

    Hi Barry and All: This indeed is a bug in SQLPLUS ! Version 9.2.0.1.0 as well.
    Thanks for asking the version no of SQLLPLUs. I was working thru Oracle Apps 11i.10 (concurrent program). So I did not get any message from SQLPLUS.
    I tested independently in SQLPLUS and got the message! Thanks Oracle!!!
    The Bug is in the name of COLUMN NAME or ALIAS Name. I renamed the columns from ON_HAND_QTY and ON_HAND_VALUE to CLOSE_QTY and CLOSE_QTY_VALUE. It worked!! The string 'ON' in the column/alias name is taken as 'ON' keyword/clause for 'compute' statement for SQLPLUS.
    Here is the message from SQLPLUS
    " SP2-0084: COMPUTE ON keyword specified already"
    See these two line and compare
    --compute SUM label 'Total $S: ' of SALARY ON_SALARY  on report;
    compute SUM label 'Total $S: ' of SALARY on report;
    Thanks - Pradip
    Here is the sample code to simulate. (not Big :))
    WHENEVER SQLERROR EXIT FAILURE
    CLEAR computes
    CLEAR BREAKS
    clear column
    TTITLE OFF
    BTITLE OFF
    set verify off
    set feedback off
    set echo off
    set heading off
    set termout off
    set linesize 203
    set pagesize 30
    set termout on
    SET UNDERLINE =
    set heading on
    COLUMN SALARY               FORMAT 9,999,990      Heading 'SALARY'           
    COLUMN ON_SALARY          format 9,999,990 Heading 'ON Salary'
    column ENAME format a20 heading 'NAME'
    COLUMN EMPNO Format 99999 HEADING 'EMPNO'
    BREAK on REPORT skip 3;
    --compute SUM label 'Total $S: ' of SALARY ON_SALARY  on report;
    compute SUM label 'Total $S: ' of SALARY on report;
    WHENEVER SQLERROR EXIT FAILURE
    select empno, ename, sal SALARY, sal ON_SALARY from scott.emp;

  • SQL*Plus displays European chars incorrectly when using Net*8 to query remote DB

    I have two 8.1.5 DBs, one on Win2k and one on RedHat Linux 6.2. I can successfully insert and retreive Western European characters fine on each of those systems using SQL*Plus and Net*8, provided that I am connecting to the local DB. I can also insert these characters fine while using SQL*Plus and Net*8 between the systems.
    The failure shows up when I try to view (select) the Western European characters using SQL*Plus on the Win2k system while querying the data on the Linux system (via Net*8). What gets displayed is the 7-bit ASCII truncated-equivalent of the character. I have verified that the data is commited and can be viewed correctly when a query is issued from the Linux system.
    Has anyone encountered anything like this??
    Any advice would be appreciated.

    I am confused about your questions .
    I have two 8.1.5 DBs. I can successfully insert and retreive Western European characters fine on each of those systems using SQL*Plus and Net*8, provided that I am connecting to the local DB. What is local db ? Do you mean you need to use dblink to connect from one database to another ? Or do you mean local machines ?
    The failure shows up when I try to view (select) the Western European characters using SQL*Plus on the Win2k system while querying the data on the Linux system (via Net*8). Do you mean selecting data from the 8.1.5 DB on Linux from SQL*Plus on Win2K ?
    What are your db character sets ?
    What are your NLS_LANG enviroment settings ?
    Which datatypes are you using ? If NCHAR , what are your national database character sets ?

  • How to install and practice SQL* plus on my personal computer

    I am doing BSC-IT and studying oracle in one of the semester. I have to practice on SQL* plus to create tables etc. I need to know what are the applications i need to install and steps i need to follow on my pc to successfully practice on SQL*plus. Your kind prompt on the current issue will be highly appreciated.
    regards,

    Few More Querries:
    -> Which Deployment Option Should i select:
    Rapid deployment
    Standard
    deployment
    Custom
    deployment
    Upgrade
    or
    Maintenance
    installation
    I guess Rapid Deployment will be suitable.
    Please suggest.
    Thanks in Advance.
    Reagrds,
    Satish

  • Need help in sql plus

    i install in my computer the oracle9i
    my problem is that : i can login to sql plus
    althoge i was tring all the passwords that i know
    scott/tiger
    sys/change_on_install
    system/manager and the result is allways the same
    ora-12560 error
    how can i solve that problem?
    did i missed somthing during the installation?

    Thank you to EVERYONE!!
    I have been searching every possible forum to find out how to install/run SQL *Plus on a home computer without a server/network to work within.  As most just learning, I could not figure out how to get past the SQL Plus Username/Password/Host String logon.
    After much trial and error, I got through and I hope this helps a lot of people just starting out.
    I used 'SYSTEM' as my username and my password created on install.
    When installing I created a database and fixed the password so my default password was the password I created on install.
    As long as I had those two fields filled in, I could leave the Host String blank and I could still get into the SQL Plus workspace.
    Since I also created a database on install, I found that I could also use the name I gave the installed database (I didn't leave the default database name so I do not remember what the default name was, but I think the default password was 'manager' for those who were not tempted to change it).
    Worst case scenario if you forgot your database name given during install, you can do a search for all of your .ora files (usually in the drive you installed Oracle on). Open the tnsnames.ora file in Notepad and you can see which database names are available on your system. The path to my file was:
    D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
    You want the SERVICE_NAME = 'databasename'
    I hope this reduced someone's stress...and thanks for all the helpful hints on these threads...they led me to the final outcome!!
    In the end, I tried a lot of other combinations for the username/host strings with plenty of errors. You would think this information would be on page one of every Oracle install!! Or maybe it is and I am just a bit slow. : )
    Thanks again to all that posted with this initial question (years ago)...
    Brian Reeves
    Oracle Student

  • Windows System Environment Variables in "Sql * plus"

    Can i use/reference Windows System Environment variables in "Sql * plus"?
    For example, i want to create sql-script to run in database server computer that asks variable "ORA_HOME" and uses this value to execute some sql/plsql sentences.
    Oracle 10g Personal, Windows 7.
    Edited by: CharlesRoos on 12.11.2010 17:28

    CharlesRoos wrote:
    Business problem:
    I have created 2 databases in my computer. Both databases needs tablespaces created by a script. Tablespaces' datafiles (.dbf files) names are same for both database. Both database has it's own directory where it holds datafiles at the moment. At the moment the datafiles for Database1 are in folder something like "%ORACLE_HOME%"\oradata\%databasename1%\*.dbf, and second database has its datafiles in other folder, somewhere ""%ORACLE_HOME%"\oradata\%databasename1%\*.dbf". I want now the script to create tablespace called "INDX" with same datafile name "indx1.dbf" into both database. So into both mentioned folder the file "indx1.dbf" must be created by script. I think the script should do following:
    1. get ORACLE_HOME.
    2. connect to database "databasename1"
    3. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename1 || indx1.dbf"
    4. connect to database "databasename2"
    5. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename2 || indx1.dbf"I don't have Oracle database near by anymore, so the code was pseudocode.
    I don't understand how to use ?-shortcut.OK, my first impression is "why does this even NEED to be scripted? Creation of new tablespaces is usually a one-off operation.
    But that aside how about this sqlplus command-line substitution variables. This example is in linux, but will work as well in Windows with the change of the way environment variables are referenced:
    *nix - echo $myvariable
    Windows - echo %myvariable%
    First, the sqlscript to create the TS. Note the use of the substitution variable "&1"
    {code}
    [oracle@vmlnx01 ~]$ cat cat makets.sql
    set echo on feedback on verify on trimsp on
    prompt &1
    CREATE SMALLFILE TABLESPACE EDSTEST
    DATAFILE '/ora01/oradata/&1/edstest.dbf'
    SIZE 5M
    REUSE
    AUTOEXTEND ON
    NEXT 1280K
    MAXSIZE 32767M
    LOGGING
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO
    drop tablespace edstest
    including contents and datafiles
    exit
    {code}
    So, at the OS prompt: Notice that the @ is separated by a space, makeing it a command line parm instead of part of the connect string
    {code}
    [oracle@vmlnx01 ~]$ export myparm=vlnxora1
    [oracle@vmlnx01 ~]$ sqlplus system/pswd @makets $myparm
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 12 13:18:05 2010
    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> prompt &1
    vlnxora1
    SQL> --
    SQL> CREATE SMALLFILE TABLESPACE EDSTEST
    2 DATAFILE '/ora01/oradata/&1/edstest.dbf'
    3 SIZE 5M
    4 REUSE
    5 AUTOEXTEND ON
    6 NEXT 1280K
    7 MAXSIZE 32767M
    8 LOGGING
    9 EXTENT MANAGEMENT LOCAL
    10 SEGMENT SPACE MANAGEMENT AUTO
    11 ;
    old 2: DATAFILE '/ora01/oradata/&1/edstest.dbf'
    new 2: DATAFILE '/ora01/oradata/vlnxora1/edstest.dbf'
    Tablespace created.
    SQL> --
    SQL> drop tablespace edstest
    2 including contents and datafiles
    3 ;
    Tablespace dropped.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@vmlnx01 ~]$
    {code}

  • 3.1EA1: Column Headings don't display when using SQL*Plus formatting

    The Col[umn] command doesn't show the column headings or the total lines in sqldev. This SQL command:
    -- Size per datafile
    col tablespace_name format a10 head 'Tablespace'
    col file_name format a40 head DataFileName
    col cursize form 999.99 head "CurrSize|GB"
    col maxsize form 999.99 head "MaxSize|GB"
    col Autoextensible form a4 head "Auto"
    break on tablespace_name
    compute sum label Total of cursize maxsize on tablespace_name
    select tablespace_name,
    file_name,
    bytes/1024/1024/1024 cursize,
    maxbytes/1024/1024/1024 maxsize,
    autoextensible
    from dba_data_files
    where tablespace_name = 'TS_DP'
    Looks like this in sqldev:
    TS_DP /ddawno/oradata/data01/dp_data22.dbf 1.76 1.76 YES
    TS_DP /ddawno/oradata/data01/dp_data01.dbf 1.76 1.76 YES
    22 rows selected
    But looks like this in SQLPlus:
    CurrSize MaxSize
    Tablespace DataFileName GB GB Auto
    TS_DP /ddawno/oradata/data01/dp_data22.dbf 1.76 1.76 YES
    /ddawno/oradata/data01/dp_data01.dbf 1.76 1.76 YES
    Total 36.20 31.64
    22 rows selected.
    Edited by: 893982 on Nov 1, 2011 11:09 AM Fix dashed line formatting.

    Hi, thanks for the response.
    No, I do not have "set heading off" somewhere. What I pasted into my original post is the entire script that I am running from the worksheet, and I am not using a startup script.
    Odd that the column formatting works for you, yet the list of unsupported commands that you pointed me to says that col[umn] is not supported. Help column from within sqldev contradicts that documentation, showing that col[umn] is supported, but only for the "NEW_V[ALUE] syntax."
    Wow, there's nothing like enabling the most obscure keyword just to be able to say that a function is supported. Oh, well, at least the scripts that I download from the web run now. In 3.0 they died with a hard error just because the col[umn] keyword was used.

  • Problem with report COMPUTE SUM

    hi @all
    hope sombody can help me
    i have a prob with a report in sql, see script below:
    CLEAR COLUMNS BREAKS COMPUTES;
    COLUMN WORK_TYPE FORMAT a95 HEADING 'Work Type' ENTMAP off
    COLUMN TEXT FORMAT a95 HEADING 'Work Description' ENTMAP off
    COLUMN TOTAL_MAN_MINUTES FORMAT 9999.99 HEADING 'Working Hours' ENTMAP off
    COLUMN TOTAL_MAINT_MAN_MINUTES FORMAT 9999.99 HEADING 'Maintanance Hours' ENTMAP off
    BREAK ON report
    COMPUTE SUM OF TOTAL_MAN_MINUTES TOTAL_MAINT_MAN_MINUTES ON report
    SELECT MWO.WORK_TYPE AS Work_TYpe, WORK_TYPE.TEXT AS Description, SUM(TRUNC(MAINT_ACTION.TOTAL_MAN_MINUTES / 60, 2)) AS Working_Hours, SUM(TRUNC(MAINT_ACTION.TOTAL_MAINT_MAN_MINUTES / 60, 2)) AS Maintanance_Hours
    FROM MAINT_ACTION, MWO, WORK_TYPE
    WHERE MWO.MWO_ID = MAINT_ACTION.originating_mwo_id
    AND MWO.WORK_TYPE = WORK_TYPE.CODE
    AND MWO.AC_SERIAL_NO = 'AS0007'
    AND MAINT_ACTION.START_DATE_TIME_ACT >= '01.04.2010'
    AND MAINT_ACTION.START_DATE_TIME_ACT <= '01.05.2010'
    AND MWO.WORK_TYPE BETWEEN '000' AND '999'
    GROUP BY MWO.WORK_TYPE, WORK_TYPE.TEXT
    ORDER BY MWO.WORK_TYPE, WORK_TYPE.TEXT;
    what i expect is the total working_hours and maintanance_hours per column at the last line from the output, but what i get is only that below
    WORK_TYPE DESCRIPTION WORKING_HOURS MAINTANANCE_HOURS
    041, blablabla, 1,16, 0,58
    105, sülzsülz, 2, 1,5,
    348, bla, 3, 2,33,
    what is my mistake??
    sorry for my bad english
    cu ice
    Edited by: Icebear on May 14, 2010 1:28 AM

    Hi,
    The SQL*Plus command:
    COMPUTE SUM OF TOTAL_MAN_MINUTES TOTAL_MAINT_MAN_MINUTES ON reportmeans "from now on, any time there a result set has is a column called TOTAL_MAN_MINUTES or TOTAL_MAINT_MAN_MINUTES, print the grand total of that column at the end of the report."
    Your result set does not have columns with those names, so the COMPUTE statement does not apply to that query.
    The alias used in the output is what's important; SQL*Plus won't try to find out what columns from the table were used in deriving all the output columns.
    Try using the same column names in both the COMPUTE statement and the query.
    For example:
    COMPUTE SUM OF   Working_Hours   Maintanance_Hours    ON report

  • Locked out of SQL*PLUS!! HELP!

    i have just started using sql*plus to access my 10g database as it was all installed on my computer by someone else for me.... and the helpfully didnt tell me the user name and password they had used
    so when i got my laptop back and discovered that i couldnt log in as scott/tiger or anything else... started messing around and managed to get a dialoge box asking me to enter a password for SYSMAN so i did so and everything was fine,,,,,
    Until i restarted my computer now it says that SYSMAN is locked just like it says for all the other standard logins!! now ive had a read around and people keep saying just grant the privelages to the scott/tiger account..... how can i do that if i cant log in as anything???
    please help oh super smart guru peoples :)
    thanks in advance
    RMMO (PL/SQL / SQL*PLUS NOOBMASTER!)

    thanks for that... sadly it didnt work... the database is local to my laptop.... but when i entered that command into cmd... another command prompt opens up for a split second then closes back down... there isnt enough time to see anything displayed in it... but i assume that it tells me that either the account is locked like all the other accounts or it says that its not a valid username/password... or somthing to that effect....
    again thankyou for the time you put into helping.... and sadly again any other ideas or possible solutions would be GREATLY appreciated!
    RMMO
    (undercover noob)

  • Got SQL *Plus query output in more than one in a single page

    Hi All,
    I have write a SQL *Plus code for execute one SQL query and registered as concurrent program. But I have got the output more than once in a single page after running the concurrent program. I am not getting what is the my code problem. Please can any one help me.
    This is my SQL code.
    -- These commands are added by applications concurrent manager
    SET TERMOUT OFF
    SET PAUSE OFF
    SET HEADING OFF
    SET FEEDBACK OFF
    SET VERIFY OFF
    SET ECHO OFF
    WHENEVER sqlerror exit failure
    -- set user environment
    SET pagesize 999
    SET linesize 860
    SET appinfo on
    SET tab off
    SET newpage none
    SET heading on
    --SET colsep ','
    -- define heading/footer
    --ttitle -
    -- left currdate -
    -- center 'SSFT Open PO Report' -
    -- right 'Page : ' format 999 sql.pno -
    -- skip 1 -
    -- center 'Organization US / Type Contract Labor / Status - Open' -
    -- skip 2
    --btitle -
    -- skip 1 -
    -- center 'Scansoft Inc. - All information confidential'
    -- define columns
    CLEAR columns
    SET heading on
    COLUMN c1 format a30 heading '"Last Name"' trunc
    COLUMN c2 format a30 heading '"First Name"' trunc
    COLUMN c3 format a50 heading '"Employee Name"' trunc
    COLUMN c4 format a20 heading '"Timecard Number"' trunc
    COLUMN c5 format a40 heading '"Expenditure Batch"' trunc
    COLUMN c6 format a24 heading '"Weekending Date"' trunc
    COLUMN c7 format a24 heading '"Expenditure Item Date"' trunc
    COLUMN c8 format a20 heading '"Expendtrmonth"' trunc
    COLUMN c9 format a20 heading '"Expendtryear"' trunc
    COLUMN c10 format a24 heading '"Sortdate"' trunc
    COLUMN c11 format 999999999 heading '"Task Id"'
    COLUMN c12 format a30 heading '"Task Name"' trunc
    COLUMN c13 format a30 heading '"Task Number"' trunc
    COLUMN c14 format a24 heading '"Closed Date"' trunc
    COLUMN c15 format a30 heading '"Project Name"' trunc
    COLUMN c16 format a30 heading '"Project Number"' trunc
    COLUMN c17 format a30 heading '"Project Status Code"' trunc
    COLUMN c18 format a30 heading '"Expenditure Type"' trunc
    COLUMN c19 format a30 heading '"Expenditure Org Name"' trunc
    COLUMN c20 format 999999999 heading '"Organization Id"'
    COLUMN c21 format a50 heading '"Projmrg"' trunc
    COLUMN c22 format a25 heading '"Role"' trunc
    COLUMN c23 format a24 heading '"Projmrg Start Date"' trunc
    COLUMN c24 format a24 heading '"Projmrg Start Date"' trunc
    COLUMN c25 format a35 heading '"Job Name"' trunc
    COLUMN c26 format a35 heading '"Project Type"' trunc
    COLUMN c27 format 999999999.99 heading '"Quentity"' trunc
    -- define breaks & computes
    --break -
    -- on report skip 2 -
    -- on c30 -
    -- on c20 skip 1
    --compute avg label 'Average' of c210 on report
    -- select statement here
    SELECT papf.last_name || '' c1, papf.first_name || '' c2,
    papf.full_name || '' c3, pea.orig_user_exp_txn_reference || '' c4,
    pea.expenditure_group || '' c5, pea.expenditure_ending_date || '' c6,
    peia.expenditure_item_date || '' c7,
    SUBSTR (TO_CHAR (peia.expenditure_item_date), 4, 3) || '' c8,
    SUBSTR (TO_CHAR (peia.expenditure_item_date), 8, 2) || '' c9,
    TO_DATE (SUBSTR (TO_CHAR (peia.expenditure_item_date), 4, 6),
    'MM/YY'
    || '' c10,
    peia.task_id || '' c11, pt.task_name || '' c12,
    pt.task_number || '' c13, ppa.closed_date || '' c14, ppa.NAME || '' c15,
    ppa.segment1 || '' c16, ppa.project_status_code || '' c17,
    pet.expenditure_type || '' c18, haou.NAME || '' c19,
    haou.organization_id || '' c20, pppv.full_name || '' c21,
    pppv.ROLE || '' c22, pppv.start_date_active || '' c23,
    pppv.end_date_active || '' c24, pj.NAME || '' c25,
    ppa.project_type || '' c26, peia.quantity || '' c27
    FROM pa.pa_expenditures_all pea,
    pa.pa_expenditure_items_all peia,
    pa.pa_tasks pt,
    pa.pa_projects_all ppa,
    hr.per_all_people_f papf,
    hr.hr_all_organization_units haou,
    pa.pa_expenditure_types pet,
    apps.pa_project_players_v pppv,
    hr.per_jobs pj
    WHERE pea.expenditure_id = peia.expenditure_id
    AND peia.task_id = pt.task_id
    AND peia.job_id = pj.job_id
    AND pt.project_id = ppa.project_id
    AND pea.incurred_by_person_id = papf.person_id
    AND pea.incurred_by_organization_id = haou.organization_id
    AND pet.expenditure_type = peia.expenditure_type
    AND ppa.project_id = pppv.project_id
    AND pppv.end_date_active IS NULL
    AND pea.expenditure_ending_date >= SUBSTR (SYSDATE - 545, 1, 9)
    ORDER BY papf.full_name ASC,
    pea.expenditure_ending_date ASC,
    peia.expenditure_item_date ASC;
    --spool off
    Thanks in advance
    --Subhas                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi
    Either remove the semicolon (;) or the slash (/) at the end of your query, as both will execute it.

  • Interactive script in SQL*PLUS

    Hi,
    I am a student and we need to write a script to be executed in SQL*PLUS.
    Script has to execute an insert statement but all values need to be provided during runtime and in the end there should be a question if you wan't to save data. When yes then commit when no then rollback.
    Below is my code. Problem is that program asks for variables' values after beginning then it displays all dbms_output.put_line and then continue with pl/sql.
    I want to for examle:
    - display message 'provide date'
    - covvert string date to date type
    - when error then exit, when ok then continue
    - provide other variables in the same way
    - ask for saving.
    My code:
    SET SERVEROUTPUT ON
    set verify off
    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
    declare
    do_save varchar2(240) ;
    v_ename varchar2(50);
    v_job varchar2(50);
    v_sal number;
    v_hiredate date;
    v_tmp varchar(50);
    begin
    DBMS_OUTPUT.put_line('Provide name:');
    v_tmp := '&val_ename';
    v_ename := v_tmp;
    DBMS_OUTPUT.put_line('Provide salary:');
    v_tmp := '&val_sal';
    begin
    v_sal := cast(v_tmp as number);
    exception when others then
    DBMS_OUTPUT.put_line('Incorrect salary format.');
    end;
    DBMS_OUTPUT.put_line('Provide data:');
    v_tmp := '&val_hiredate';
    begin
    v_hiredate := to_date(v_tmp);
    exception when others then
    DBMS_OUTPUT.put_line('Incorrect date format.');
    end;
    INSERT INTO EMP(ENAME, SAL, HIREDATE)
    VALUES (v_ename, v_sal, v_hiredate);
    DBMS_OUTPUT.put_line('Do you want to save? [Y/N]');
    do_save := '&val_save';
    do_save := upper(ltrim(substr(nvl(do_save, 'N'), 1,1)));
    IF do_save = 'Y' THEN
    commit;
    DBMS_OUTPUT.put_line('Data saved.');
    ELSE
    rollback;
    DBMS_OUTPUT.put_line('Data rejected.');
    END IF;
    end;
    /

    user10613699 wrote:
    it is not solving my problem,...Why not? Did you test and also check the documentation link?
    SQL> accept DO_SAVE  prompt 'Do you want to save (Y/N)? ';
    Do you want to save (Y/N)? Y
    SQL> begin
      2    if '&do_save' in ('Y','y') then
      3      commit;
      4    else
      5      rollback;
      6    end if;
      7  end;
      8  /
    old   2:   if '&do_save' in ('Y','y') then
    new   2:   if 'Y' in ('Y','y') then
    PL/SQL procedure successfully completed.
    SQL> Edited by: Sven W. on Nov 17, 2008 4:53 PM

  • Re: SQL Plus Error ORA - 12560 TNS:Protocol Adapter error

    I am using Oracle 9i
    On Windows XP Home
    I am trying to learn and become familiar with Oracle 9i
    I get the above error whenever I try to log on to SQL Plus
    I use the following Id scott
    and the following Password Tiger
    and the above error comes up
    now I can't log on to Oracle9i SQL
    I tried going into Start, Control Panel, Administrative Tools, Services
    I see the Oracle SID which says Automatic, Started
    But I am unable to still logon
    Anyone has a solution
    Assistance would be appreciated
    The solution can be printed here as well as please forward a copy to [email protected]
    Thanks

    Here is the following output of your instructions
    sc query oracleserviceoracle
    SERVICE_NAME: ORACLESERVICEORACLE
    TYPE: 10 WIN32_OWN_PROCESS
    STATE: 4 RUNNING
    (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
    WIN32_EXIT_CODE: 0 (0X0)
    SERVICE_EXIT_CODE: 0 (0X0)
    CHECKPOINT: 0X0
    WAIT_HINT: 0X0
    set | find "ORACLE"
    comes back empty
    set | find "oracle"
    JSERV=J:\oracle\ora92/Apache/Jserv/conf;C:\oracle\ora92/Apache/Jserv/conf
    Path=J:\oracle\ora92\bin;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\MSSQL7\BINN;"C:\Program Files\Zone Labs\ZoneAlarm\MailFrontier";C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Executive Software\DiskeeperLite\;C:\Program Files\CA\PPRT\bin;C:\Program Files\SSH Communications Security\SSH Secure Shell;;J:\Acucobol\BIN
    WV_GATEWAY_CFG=J:\oracle\ora92\Apache\modplsql\cfg\wdbsvr.app
    ebrian
    Yes I realize that the JSERV is pointing in the incorrect are
    the J drive is a flashdrive
    In the Registry I have just deleted the 2nd Orahome directory which was on the J drive
    so all I have now left is the Orahome directory on the C drive
    how do I make corrections so that from now on the JSERV, Path, and WV_Gateway._CFG point to the C drive

  • X.column.getStringVal() throws "invalid column name", works in SQL*Plus.

    The subject sums it up pretty well... I have a query that works fine from SQL*Plus, but throws a JDBC exception with "ORA-00904 invalid column name" if I create a PreparedStatement from it and call executeQuery().
    The query itself is substantially similar to:
    SELECT foo, t.bar.getStringVal() from some_table t
    where "Some table" is an oracle 9i table, "foo" is a varchar2 column, and "bar" is a column that used to be varchar2 before I dropped and re-created the table with an xmltype column instead. "t" is an alias for the table that I didn't used to need (since it's only one table), but apparently is required for getStringVal() to work.
    ... And, of course, .getStringVal() is being used as a convenient way to treat technically LOB-like xmltype columns as big ersatz varchar2 columns so I won't have to screw around with stream i/o just to read a 4,001-byte value into a String ;-)
    I'm using the ojdbc14.jar thin driver and a fairly recent j2sdk (1.4.1_02, I think). I made a point of anihilating every copy of classes12.zip on my PC just to make sure it wasn't lurking in a classpath somewhere to screw things up.
    Strangely enough, it DOES work from within Netbeans' database explorer (itself connecting to the same Oracle database using the ojdbc14.jar thin driver).
    For the sake of being comprehensive, here's an example of the actual JDBC code that won't work:
    public ResultSet doQuery(Connection conn, int val) throws SQLException {
    String sql = "SELECT foo, t.bar.getStringVal() from some_table t where anothercolumn = ?";
    PreparedStatement sth = conn.prepareStatement(sql);
    sth.setInt(1, val);
    ResultSet rs = sth.executeQuery();
    // everything past this point is moot,
    // because sth.executeQuery throws an exception...
    // however, the ResultSet would ultimately be
    // returned to the method's caller, and
    // its values read using getString(fieldname)
    // including 'bar', the xmltype field...

    OK, this particular problem was my fault. The original table was on a server running 8i. To spare myself the grief of having to deal with CLOBs on 8i's terms and take advantage of 9i's new conveniences for handling them, I created a new table on our other server that's running 9i and updated the app's config settings to reflect the new server. Unfortunately, I forgot that the debugging/testing main() method had the URL of the old database hardcoded (it was written before the rest of the class). Ergo... it was still looking at the old database. Oops. (*blush*).

Maybe you are looking for