Database Auditing to record DELETE operation on a schema for all tables.

Hi,
I am using ORACLE DATABASE 11g. I want to apply the AUDIT feature to record all the DELETE operations happening on the schema tables.
I did the following steps but dint got the proper output :-
I logged into the SYS as sysdba user and set
alter system set audit_trail=DB,EXTENDED scope=spfile;then i executed this command to record the sql which will use the DELETE privileges
AUDIT DELETE ANY TABLE;Then i bounced back my DB and for testing purpose i created a table in SCOTT schema and inserted 10 rows in it and then DELETE all the rows from it.
As per expectation i check the view
select * from aud$
where spare1 like '%MACHINE1%'
and USERID='SCOTT'
order by ntimestamp#;The output i got is :-
34     168368     1     1          SCOTT     I-DOMAIN\MACHINE1     MACHINE1     100     0                                                                      Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=2565))          MACHINE1                    5          21-DEC-11 07.02.58.621000 AM               0     928:5024     0000000000000000               983697018     <CLOB>     <CLOB>     But here i don't see the SQL generated in the last column.
What i was expecting is that if i fire a DELETE statement in the schema it will get logged here and with the help of this view i will be able to see that which user from which machine executed a DELETE statement and what that statement was?
Please let me know what step i have missed here.
PS:- The ACTION# column shows 100 , is it the code for DELETE action. I also accessed the DBA_AUDIT_TRAIL view but din't found any usefull info their.
Thanks in advance.

Try instead:
audit delete table;AUDIT DELETE ANY TABLE is auditing use of DELETE ANY TABLE privilege.

Similar Messages

  • How do I run sp_spaceused for all tables in a database?

    Hi,
    I am struggling to understand how to run the sp_spaceused sproc for all tables in a database.
    I know how to use it for one table but how would I replicate it automatically for each table in a given database?
    Regards,
    Ian.

    I just managed to alter the code of VidyaSagar and have pulled out all the information including Schema name. Below is what it looks like:
    set
    nocount
    on
    select
    'Database Name: ',
    db_name
    if
    exists(select
    name from tempdb..sysobjects
    where name='##tmp'
    drop
    table ##tmp
    create
    table ##tmp(TABLE_SCHEMA
    nvarchar(256),TABLE_NAME
    nvarchar(256),
    num_rows int,
    reserved_KB varchar(15),data_KB
    varchar(15),index_KB
    varchar(15),unsed_KB
    varchar(15
    go
    declare
    @tbl_schema nvarchar(256
    declare
    @tbl_name nvarchar(256
    declare
    @schema_tbl_name nvarchar(256
    declare
    tblname CURSOR
    for
    select
    TABLE_SCHEMA
    TABLE_NAME
    from
    INFORMATION_SCHEMA.TABLES
    where TABLE_TYPE='BASE
    TABLE' 
    open
    tblname
    Fetch
    next
    from tblname
    INTO @tbl_schema,@tbl_name
    WHILE
    @@FETCH_STATUS
    = 0
    BEGIN
    set @schema_tbl_name=@tbl_schema+'.'+@tbl_name
    insert
    into ##tmp(TABLE_NAME
    , num_rows
    , reserved_KB
    ,data_KB
    ,index_KB
    ,unsed_KB
    exec
    sp_spaceused
    @schema_tbl_name
    update ##tmp
    set TABLE_SCHEMA
    =@tbl_schema
    where TABLE_SCHEMA
    is
    NULL
    and TABLE_NAME=@tbl_name
    FETCH
    NEXT
    FROM tblname
    INTO @tbl_schema,@tbl_name 
    END
    CLOSE
    tblname
    deallocate
    tblname
    go
    select
    from
    ##tmp
    drop
    table ##tmp
    Warm Regards, Ajay

  • CREATE and DELETE operations in MI7.1 for PDA

    Hi,
    We are developing a sample scenario for PDA in 7.1. Problem is we are able to implement GETLIST, GETDETAIL and MODIFY operations but not able to implement CREATE and DELETE operations. For GETLIST and GETDETAIL i have created queries. Modify is also simple (i am creating a form to edit and commiting data once i click on save). But to implement CREATE and DELETE we dont have any reference.
    Regards,
    Vinay

    Hi,
    Now i know the answer
    There is a typed method on the service component model class for root node creation. Example for binding a new root instance to a context node:
    wdContext.nodeCurrentEmployee().bind(Collections.singleton(model.createEmployeeSdoEmployee()));
    where model is your webdynpro model.Employee is a context node model bounded to Employee model class.This node has to be manually created in context(and then can be context mapped and bound to elements in view)
    wdContext.nodeCurrentEmployee().setLeadSelection(0);
    Creating a child is done on the root itself, but persisting it is a two step process:
    address = employeeRootNode.createNewAddresss(); <- this only creates the instance in memory
    where employeeRootNode is the model object for which the child has to be created. If the element for which the child has to be created exists in context then it can be got by
    wdContext.nodeEmployee().currentEmployeeElement.model()
    employeeRootNode.addToAddresss(address);  <- this persists the new instance
    wdContext.nodeCurrentAddress().bind(Collections.singleton(address));
    wdContext.nodeCurrentAddress().setLeadSelection(0);
    Delete of a root is also done on the sc model class:
    model.removeEmployeeSdoEmployee(employeeRootNode);
    Delete of a child is done one the root:
    employeeRootNode.removeFromAddresss(address);
    Hope this helps.
    Regards,
    Vinay
    Edited by: Vinay TS on May 5, 2008 8:31 AM

  • Creating sequences for all tables in the database at a time

    Hi ,
    I need to create sequences for all the tables in my database.
    i can create individually ,using toad and sqlplus.
    Can any one give me a code for creating the sequences dynamically at a time for all the tables.
    it is urgent ..
    Regards.

    I need to create sequences for majority of the tables that are having ID column
    which is sequences."The majority" is not the same as all. So you probably want to drive your generation script off the ALL_TAB_COLUMNS view...
    where column_name = 'ID'You need to think about this carefully. You might want different CACHE sizes or different INCREMENT BY clauses for certain tables. You might even (whisper it) want a sequence to be shared by more than one table.
    Code generation is a useful technique, but it is a rare application where one case fits all.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • How to delete existing e-mail signature for all users in outlook 2010

    Dears,
    How to delete existing (or reset to none ) e-mail signature for all users .
    If anyone knows where I can find this script or another way of accomplishing this I would be very thankful.
    outlook Version : 2010
    PS : Not to disable.
    Khaja Hameed

    If you want to manage signatures for multiple users your best bet is to use Group Policy.
    See:
    Setting up a Corporate Signature | HowTo-Outlook
    http://www.howto-outlook.com/howto/corporatesignatures.htm
    <p>Eric Legault (<a href="https:/mvp.support.microsoft.com/default.aspx/profile/legault">MVP: Outlook</a>)<br/> <a href="http://about.me/ericmlegault">About me...</a><br/> <a href="http://www.outlookappins.com/products/social-contacts">Outlook
    Appins</a>: Store Social Media fields in your Outlook Contacts!</p>

  • Delete skype contacts on ipad for all devices/acco...

    Hi there,
    Is it possible to delete Skype contacts on Ipad for the whole account (used on different devices)?
    If I make a change in my skype account on my Ipad will it be changed directly for the rest of my devices/account or just for my Ipad? 
    Hope someone can help me!
    Thanks

    thank you for your response!  I know this sounds crazy, but I don't have the contacts on my computer - I was, for the first time, inputting them onto my iPad.  If that was the only place they were saved, is there any way to restore them?  Do you know why this would have happened and/or how I can prevent it from happening in the future?  I appreciate any help you can offer...

  • SmartView 11.1.1.3 - Web launch operation has been cancelled for all users

    Hi
    I am having issue when he tries to open a Planning web form in SmartView through Workspace, gets the error: “Web launch operation has been cancelled".
    EssbaseOracle Essbase has been added as a server in Shared
    Connections in Smart View, but not working.
    In Smartview can not add server planning, you can only add Essbase server
    How to solve this problem?
    thanks
    Rodrigo

    After installing SmartView, run the Configuration Utility and select Foundation -> Web Configuration to register it correctly with all the other components. OHS will need to be restarted after the Web server configuration task.
    HTH-
    Jasmine.

  • Can I set Mail.app to default "Permanently erase deleted messages when" to Never, for all new accounts?

    When setting up new accounts in Mail.app, I generally remember to set the "Permanently erase deleted messages when:" setting to "Never", in contrast to its harsh default 1-month setting. 
    When I first switched to a Mac years ago (probably around the time of Leopard, or one before), I didn't know of this setting, as it's somewhat buried and not part of the add new account "walkthrough", and I permanently lost serious business mail on a self-hosted mail server, due to this, in my opinion, really stupid default setting. 
    At any rate, as I said, I usually remember to change this, but I recently synched accounts via iCloud to a new machine (a work machine), and for whatever reason, the setting didn't take on one account (just one account; despite being set to "never" on the primary mac from which things sync).  Same problem all over again.
    So, Is there a way I can simply change the default, in the system, so that whenever a new account is created, Mail.app sets the default "erase messages when" time to "Never"? 
    I need to duplicate Gmail (archiving) functionality and thus far this is the best way I have of going about it; leaving those messages in trash on my regular old everyday IMAP servers.
    I did run into this solution – http://support.apple.com/kb/TA22283, though it was for Mail.app in OSX 10.2 (so things have changed now), but I'm willing to bet there is a similar command, more up to date, that might do something similar?  I'd like to run such a command on all of my machines so that ALL new mail accounts created are set to NEVER permanently auto-empty the trash–that should be done when I chose, and when I chose only.

    Open Mail preferences, click on the Accounts icon in the toolbar then select your mail account, click on the Mailbox Behaviours tab on the right. Set the dropdown menu at the bottom for the Never option.
    However, you cannot change the default options set for a newly created account.

  • Delete operation on indexed table taking lot of time

    We are working on 10g R2. We have a script for archiving a table which upon copying into table (say Y a non indexed table); the pre-decided records from a table (say X indexed table).
    After inserting the records into Y the records are deleted from X. There are close to 50 million records to be archived this way.
    While testing the script in development instance for a million records, we find that on avoiding the delete operation the time taken for the script to execute is ~ 45 minutes which otherwise (including the delete operation) takes 2 hours.
    How can we reduce this overhead time.
    Dropping the index and recreating them is not an option!

    My method is logical if you are planing to migrate at least 90% of all data from X to Y. If so
    For the new X table you only need at most 10% of the size of the current X table ( At my previous post by saying "the same as" i did not mean data, i mean only DDL except storage). Moreover, after renaming X to X_ and copying "data not to be copied to Y" from X_ to X, you may drop unnecessary indexes from X_ to free up some space.

  • Finding Deleted operations in a Order

    Hi all,
    I need a way to find the deleted operations in an order for a smartform. if a operation is deleted in a particular order it should not be printed in the form. What i need is where to find the indicator that the operation in the particular order is deleted. It would be great if anyone can help me with this.
    Thank You.

    HI all,
    I have the same problem in PP smartforms, someone has solved? thanks

  • Dulk delete operation

    hi
    I have few tables which needs to be purge every two months once (leaving the last two months data as a backup in the tables). Instead of a script with writing stright forward DELETE statements (DELETE * FROM table_name WHERE condition) for all the tables and COMMIT-ting it finally, is there any other better way in performance point of view is concern.
    thanks
    shakeel.

    I trust that by referring to a bulk delete option, you're not suffering from the delusion that adding another software layer called PL/SQL and using bulk processing to transport data between the PL and SQL engines, are actually faster?
    Assuming you're on Standard Edition (no partitioning), you may want to consider not deleting the data you don't want, but selecting/inserting the data you do want. (the reverse of a detele)
    This is done using a CTAS (Create Table As Select) and can be a lot cheaper if the amount of data to keep is less than the amount of data to delete.
    Remember that is is all about I/O - I/O is what makes transactions slow. The minimum amount of I/O is using a DDL like a drop or truncate partition. Failing that, a CTAS could be a faster option (less I/O) than the delete DML statement.

  • Compress for all operation is New feature of 11g????

    hey to all i'm going to create a table with compress option i used "COMPRESS FOR ALL OPERATIONS" IT does not create table using 10g and when i connect to 11g it create a table
    i read the documentation of 11g managing table but this option is not very well elaborate there plz tell me the difference b/w compress and compress for all operation and either compress for all is supported in 10g or not
    feel free to ask any question
    regards adeel

    Table compression was available in 10g as well.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2128733
    but "COMPRESS FOR ALL OPERATIONS" is new feature in 11g and the description for the same is self-explanatory.
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#i2128733
    <quote>
    * When you enable table compression by specifying either COMPRESS or COMPRESS FOR DIRECT_LOAD OPERATIONS, Oracle Database attempts to compress data during direct-path INSERT operations when it is productive to do so. The original import utility (imp) does not support direct-path INSERT, and therefore cannot import data in a compressed format.
    * When you enable table compression by specifying COMPRESS FOR ALL OPERATIONS, Oracle Database attempts to compress data during all DML operations on the table.
    <quote>

  • How do I search for all "missing" tracks within the iTunes database?

    I found the dreaded ! of death, and sadly I verified the tacks indeed are not on my hard drive.
    Is there a way to sort on this tag so that I can see what else might be missing on my hard drive but remains in the database (sort of similar to how you can search for all tracks that have missing artwork)? 

    Thanks.  It works perfectly.
    URL for anyone else in need:  http://dougscripts.com/123

  • Authorization scheme for users stored in a database table?

    Hello!
    I'm trying to find out how to make an authorization scheme for database users.
    I first made an authentication scheme for my current application, I named it "Authentication for database accounts", and the scheme type is "Database Accounts".
    A word of explanation:_
    I have a table in my database, named "USERS". Inside this table, I have the following columns:
    - USERID (NUMBER)
    - USERNAME (VARCHAR2(50))
    - PASSWORD (VARCHAR2(50))
    - EMAIL (VARCHAR2(200))
    For this question, I'll take an example user. The username is USER and the password is USER. Email and UserID don't matter here, but let's just say the UserID is 1.
    What I want:_
    When you go to the application, and you are requested to log in (page 101), then I want a user to be able to log in with the data that has been stored in the USERS table.
    So, on the login page, the user will enter USER as username, and USER as password. The authorization scheme then needs to check whether or not this username and password match the data in the USERS table. If it does, then it must sign the user in with the credentials the user entered (those being USER and USER).
    I also want the UserID to be stored somewhere in the application (if possible, in an application item).
    How do I do this? I've never made an authorization scheme before... I'm not too good with PL/SQL either, but I'm working on that part.
    Any help is greatly appreciated.

    I'm trying to find out how to make an authorization scheme for database users. I think there may be some confusion here. An authorization scheme gives the user access to different parts of an Apex Application. Database users are the users that you use to login to the database, for example with sqlplus.
    From the rest of your post it sounds like you need a custom authentication scheme to validate users against a custom table. For this you need to create a custom authentication scheme and select use my custom function to authenticate. Exactly how you set up the authentication scheme depends on the version of Apex you are using. But an example of validate user function you could use is given below:
    function validate_login (
       p_username   in   varchar2
    , p_password   in   varchar2) return boolean
    is
    v_result varchar2(1);
    begin
    select null into v_result
    from USERS
    where userid = p_username
    and password = p_password;
    return true;
    when no_data_found then return false;
    end validate_login;Once the user has successfully logged on the userid will be in the APP_USER apex substitution string.
    And for Application Express Account Credentials, does this mean an admin must make each new user by hand?If you using Apex account credentials the user details are stored within the Apex tables. You can create users using the Apex admin application or by using the APEX_UTIL.create_user api.
    Rod West

  • Counting Record Totals Within Query: Totals Output to New Table

    Hi All,
    I'm failry new to PL/SQL... my apologies if this is obvious... I'm trying to count the total number of BI_WRKFLW.BI_LMN_SRV_AREA occurences by each BI_WRKFLW.BI_LMN_SRV_AREA (The Code correspondes to a city name like Sundance, Sheridan, Etc.)
    So, I have a Query that executes fine:
    Query
    /* Begin Querey */
                    SELECT DISTINCT
                        "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD",
                        "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED",
                        "BI_TYPE_SERVICE"."BI_ACCT",
                        "BI_SO_DET_VIEW_1"."BI_SO_NBR",
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_DESC",
                        "BI_SO_TYPE_REF"."BI_SO_TYPE_DESC",
                        "BI_SRV_STAT_REF"."BI_SRV_STAT_DESC",
                        "BI_DIST_OFC_REF"."BI_DIST_NAME",
                        "BI_CNTY_REF"."BI_COUNTY_DESC",
                        "BI_SO_DET_VIEW_1"."BI_CLOSE_DT",
                        "BI_WRKFLW_TASKS"."BI_EVENT_DT_TM",
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD",
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_AREA",
                        "BI_SO_MASTER"."BI_WO_WORKORD"
                    FROM
                        ((((((((("XXXXXX"."BI_SO_MASTER" "BI_SO_MASTER"
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SO_DET_VIEW_1" "BI_SO_DET_VIEW_1"
                    ON
                        "BI_SO_MASTER"."BI_SO_NBR"="BI_SO_DET_VIEW_1"."BI_SO_NBR")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_TYPE_SERVICE" "BI_TYPE_SERVICE"
                    ON
                        "BI_SO_DET_VIEW_1"."ACCT_NBR"="BI_TYPE_SERVICE"."BI_ACCT")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_WRKFLW" "BI_WRKFLW"
                    ON
                        "BI_SO_DET_VIEW_1"."BI_WRKFLW_KEY"="BI_WRKFLW"."BI_WRKFLW_KEY")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SO_TYPE_REF" "BI_SO_TYPE_REF"
                    ON
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"="BI_SO_TYPE_REF"."BI_SO_TYPE_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_WRKFLW_TASKS" "BI_WRKFLW_TASKS"
                    ON
                            "BI_WRKFLW"."BI_WRKFLW_KEY"="BI_WRKFLW_TASKS"."BI_WRKFLW_KEY")
                    AND (
                            "BI_WRKFLW"."BI_WORK_EVENT_CD"="BI_WRKFLW_TASKS"."BI_WORK_EVENT_CD"))
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_DIST_OFC_REF" "BI_DIST_OFC_REF"
                    ON
                        "BI_WRKFLW"."BI_DIST_OFC_CD"="BI_DIST_OFC_REF"."BI_DIST_OFC_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_LMN_SRV_REF" "BI_LMN_SRV_REF"
                    ON
                        "BI_WRKFLW"."BI_LMN_SRV_AREA"="BI_LMN_SRV_REF"."BI_LMN_SRV_AREA")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SRV_LOC" "BI_SRV_LOC"
                    ON
                        "BI_TYPE_SERVICE"."BI_SRV_LOC_NBR"="BI_SRV_LOC"."BI_SRV_LOC_NBR")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SRV_STAT_REF" "BI_SRV_STAT_REF"
                    ON
                        "BI_TYPE_SERVICE"."BI_SRV_STAT_CD"="BI_SRV_STAT_REF"."BI_SRV_STAT_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_CNTY_REF" "BI_CNTY_REF"
                    ON
                        "BI_SRV_LOC"."BI_CNTY_CD"="BI_CNTY_REF"."BI_CNTY_CD"
                    WHERE
                            "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='030'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='040'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='041'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='080'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='108'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='140'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='141'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='400'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='401'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='460'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHR'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS')
                    AND "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD"='O'
                    AND (
                            "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ANNEXATION'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='AVIAN'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CAPVERIF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMRETIRE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMSERVCHG'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CONTSERVD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUSTBLD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUTOFF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='DVCM'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ENERGIZE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPCHANG'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPVALID'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='HIGHLOAD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='LOCATE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MAINT-EQ'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MSYSTEMMGT'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NCBM'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEWRES-WF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEW-WF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='POWER QUAL'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECONIDLE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECVERIF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE1'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE2'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SERVCHANGE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SPECIALPRJ'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SUBD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SYSTEMMGT'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TREE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TRFX')
                    ORDER BY
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_DESC" DESC,
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"
                        /* End Querey */That is wrapped within a counting Block that is giving me trouble:
    SELECT
        WOCOUNT.Office,
        WOCOUNT.WOCOUNT
    FROM
            SELECT
                CASE
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
                    THEN '1-SUNDANCE'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
                    THEN '2-GILLETTE'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
                    THEN '3-SHERIDAN'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
                    THEN '4-West/Central'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
                    THEN '5-East/Central'
                    ELSE '0-OTHER'
                END                                AS Office,
                COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
            FROM
                    /* Begin Querey */
                    /* End Querey */
                ) T2
            JOIN
                BI_SO_DET_VIEW_1
            ON
                T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
            GROUP BY
                BI_WRKFLW.BI_LMN_SRV_AREA
                 )WOCOUNTThis is the 2 blocks together:
    SELECT
        WOCOUNT.Office,
        WOCOUNT.WOCOUNT
    FROM
            SELECT
                CASE
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
                    THEN '1-SUNDANCE'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
                    THEN '2-GILLETTE'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
                    THEN '3-SHERIDAN'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
                    THEN '4-West/Central'
                    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
                    THEN '5-East/Central'
                    ELSE '0-OTHER'
                END                                AS Office,
                COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
            FROM
                    /* Begin Querey */
                    SELECT DISTINCT
                        "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD",
                        "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED",
                        "BI_TYPE_SERVICE"."BI_ACCT",
                        "BI_SO_DET_VIEW_1"."BI_SO_NBR",
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_DESC",
                        "BI_SO_TYPE_REF"."BI_SO_TYPE_DESC",
                        "BI_SRV_STAT_REF"."BI_SRV_STAT_DESC",
                        "BI_DIST_OFC_REF"."BI_DIST_NAME",
                        "BI_CNTY_REF"."BI_COUNTY_DESC",
                        "BI_SO_DET_VIEW_1"."BI_CLOSE_DT",
                        "BI_WRKFLW_TASKS"."BI_EVENT_DT_TM",
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD",
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_AREA",
                        "BI_SO_MASTER"."BI_WO_WORKORD"
                    FROM
                        ((((((((("XXXXXX"."BI_SO_MASTER" "BI_SO_MASTER"
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SO_DET_VIEW_1" "BI_SO_DET_VIEW_1"
                    ON
                        "BI_SO_MASTER"."BI_SO_NBR"="BI_SO_DET_VIEW_1"."BI_SO_NBR")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_TYPE_SERVICE" "BI_TYPE_SERVICE"
                    ON
                        "BI_SO_DET_VIEW_1"."ACCT_NBR"="BI_TYPE_SERVICE"."BI_ACCT")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_WRKFLW" "BI_WRKFLW"
                    ON
                        "BI_SO_DET_VIEW_1"."BI_WRKFLW_KEY"="BI_WRKFLW"."BI_WRKFLW_KEY")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SO_TYPE_REF" "BI_SO_TYPE_REF"
                    ON
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"="BI_SO_TYPE_REF"."BI_SO_TYPE_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_WRKFLW_TASKS" "BI_WRKFLW_TASKS"
                    ON
                            "BI_WRKFLW"."BI_WRKFLW_KEY"="BI_WRKFLW_TASKS"."BI_WRKFLW_KEY")
                    AND (
                            "BI_WRKFLW"."BI_WORK_EVENT_CD"="BI_WRKFLW_TASKS"."BI_WORK_EVENT_CD"))
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_DIST_OFC_REF" "BI_DIST_OFC_REF"
                    ON
                        "BI_WRKFLW"."BI_DIST_OFC_CD"="BI_DIST_OFC_REF"."BI_DIST_OFC_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_LMN_SRV_REF" "BI_LMN_SRV_REF"
                    ON
                        "BI_WRKFLW"."BI_LMN_SRV_AREA"="BI_LMN_SRV_REF"."BI_LMN_SRV_AREA")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SRV_LOC" "BI_SRV_LOC"
                    ON
                        "BI_TYPE_SERVICE"."BI_SRV_LOC_NBR"="BI_SRV_LOC"."BI_SRV_LOC_NBR")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_SRV_STAT_REF" "BI_SRV_STAT_REF"
                    ON
                        "BI_TYPE_SERVICE"."BI_SRV_STAT_CD"="BI_SRV_STAT_REF"."BI_SRV_STAT_CD")
                    LEFT OUTER JOIN
                        "XXXXXX"."BI_CNTY_REF" "BI_CNTY_REF"
                    ON
                        "BI_SRV_LOC"."BI_CNTY_CD"="BI_CNTY_REF"."BI_CNTY_CD"
                    WHERE
                            "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='030'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='040'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='041'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='080'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='108'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='140'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='141'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='400'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='401'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453A'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='460'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHR'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS')
                    AND "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD"='O'
                    AND (
                            "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ANNEXATION'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='AVIAN'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CAPVERIF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMRETIRE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMSERVCHG'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CONTSERVD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUSTBLD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUTOFF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='DVCM'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ENERGIZE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPCHANG'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPVALID'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='HIGHLOAD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='LOCATE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MAINT-EQ'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MSYSTEMMGT'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NCBM'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEWRES-WF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEW-WF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='POWER QUAL'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECONIDLE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECVERIF'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE1'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE2'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SERVCHANGE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SPECIALPRJ'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SUBD'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SYSTEMMGT'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TREE'
                        OR  "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TRFX')
                    ORDER BY
                        "BI_LMN_SRV_REF"."BI_LMN_SRV_DESC" DESC,
                        "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"
                        /* End Querey */
                ) T2
            JOIN
                BI_SO_DET_VIEW_1
            ON
                T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
            GROUP BY
                BI_WRKFLW.BI_LMN_SRV_AREA
                 )WOCOUNTThe last error I received is: [Error Code: 904, SQL State: S0022] [Oracle][ODBC][Ora]ORA-00904: "T2"."BI_WRKFLW_KEY": invalid identifier
    I want the final Output to be something similar to:
    OFFICE          WOCOUNT 
    0-OTHER         44.0       
    1-SUNDANCE      14.0     
    2-GILLETTE      29.0       
    3-SHERIDAN      11.0        
    4-West/Central  37.0       
    5-East/Central  58.0       Thanks for your help,
    :) John

    Hi, John,
    Johnbr (Oracle11G) wrote:
    Hi All,
    I'm failry new to PL/SQL... That's okay; there's no PL/SQL involved in this problem, and there's no PL/SQL needed, only SQL.
    That is wrapped within a counting Block that is giving me trouble:
    SELECT
    WOCOUNT.Office,
    WOCOUNT.WOCOUNT
    FROM
    SELECT
    CASE
    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
    THEN '1-SUNDANCE'
    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
    THEN '2-GILLETTE'
    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
    THEN '3-SHERIDAN'
    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
    THEN '4-West/Central'
    WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
    THEN '5-East/Central'
    ELSE '0-OTHER'
    END                                AS Office,
    COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
    FROM
    /* Begin Querey */
    /* End Querey */
    ) T2
    JOIN
    BI_SO_DET_VIEW_1
    ON
    T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
    GROUP BY
    BI_WRKFLW.BI_LMN_SRV_AREA
    )WOCOUNT
    The sub-query called wocount only involves 2 "tables", namely
    (1) T2
    (2) BI_SO_DET_VIEW_1
    (I put "tables" in quotes because T2 isn't really a table; it's an in-line view. Judging by the name, I'm guessing BI_SO_DET_VIEW_1 isn't really a table, either, but it doesn't matter. You have 2 things that serve as tables, so I'll just call them tables.)
    Since those are the only 2 tables, you can't reference BI_WRKFLW in WOCOUNT. That table is known inside T2, but not outside of T2.
    You can include "BI_WRKFLW"."BI_LMN_SRV_AREA" in the SELECT clause of T2, assuming that doesn't make more rows distinct. T2 will then look like this:
    ...             SELECT DISTINCT
                        BI_SO_DET_VIEW_1.BI_SO_STAT_CD
                        BI_SO_MASTER.BI_WO_WORKORD,
                  BI_WRKFLW.BI_LMN_SRV_AREA          -- New column added
                    FROM ...Then, inside WOCOUNT, you can use BI_LMN_SRV_AREA like this:
    ...         CASE
                    WHEN BI_LMN_SRV_AREA = '1'
                    THEN '1-SUNDANCE'
                    WHEN BI_LMN_SRV_AREA = '2'
                    THEN '2-GILLETTE'
                    WHEN BI_LMN_SRV_AREA = '3'
                    THEN '3-SHERIDAN'
                    WHEN BI_LMN_SRV_AREA = '4'
                    THEN '4-West/Central'
                    WHEN BI_LMN_SRV_AREA = '5'
                    THEN '5-East/Central'
                    ELSE '0-OTHER'
                END                                AS Office,or, to save a little typing:
    ...         CASE  BI_LMN_SRV_AREA
                    WHEN  '1'
                    THEN '1-SUNDANCE'
                    WHEN '2'
                    THEN '2-GILLETTE'
                    WHEN '3'
                    THEN '3-SHERIDAN'
                    WHEN '4'
                    THEN '4-West/Central'
                    WHEN '5'
                    THEN '5-East/Central'
                    ELSE '0-OTHER'
                END                                AS Office, 
    Speaking of saving on typing:
    Instead of
    WHERE
                            "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
                        OR  "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS'
                  )you can use the IN operator, like this:
    WHERE              BI_TYPE_SERVICE.BI_PRIM_RATE_SCHED  IN ('001', '001NS', '010', ..., 'RHRNS') 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Simplify the problem as much as possible. For example, you would probably have the same problem if there were only 2 o4 3 tables involved in your query. Try to construct a problem that only has 2 or 3 tables, and post only those tables, and the results you want from them.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

Maybe you are looking for

  • What format do I use for internal drive?

    I want to install a new internal harddrive into my Macbook.  What format should I use for it? Mac OS Extended (Journaled) Mac OS Extended Mac OS Extended (Case-sensitive, Journaled) Mac OS Extended (Case-sensitive) MS-DOS (FAT) ExFAT I know MS-DOS(FA

  • How to avoid Standard text

    Hi All, I want to getrid of the Description for one of the column, i am trying to unselect the checkbox Standard Text even it is default taking the standard text. In my report i want t display blank(with out description) under thatb we will get to se

  • Need help with this Spry "processTokens()" error

    I am using Dreamweaver CS4 Beta, and using the new Spry data set wizard to create a data connection using an HTML file that contains a table of simple data. Getting through the guided steps of creating the data set and the master/detail page is a pie

  • Add jsf2 Custom Component from 3rdparty .jar file

    Hi, everyone. I've got 3rdparty custom component as jar library. It's laid in my classpath. But I can't use it in my custom.taglib.xml. here is taglib: <?xml version="1.0" encoding="UTF-8"?> <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" x

  • Problem getting transparency in Dreamweaver with Flash

    I recently upgraded my Dreamweaver to CS4 and it has has changed the code I had for a site I designed. I used to have transparency in my Flash movie so that the browser background could be seen through the movie. I have now lost this. Could someone p