Clarity

  • 1.  Urgently need 2 Queries

    Posted Jun 22, 2012 12:55 PM
    Hello Community!

    I'm in urgent need of two queries: I'm looking to Move some project documents from my Fileshare to another shared drive location.

    1). I need to get a count on all documents related to in-active projects that were closed on or before 12/31/2010.
    2). Non-current versions of documents related to inactive projects that were closed on or before 12/31/2011.

    This is needed for a meeting in 1 hour so any help would be great!


  • 2.  RE: Urgently need 2 Queries

    Posted Jun 22, 2012 01:41 PM
    The tables are as follows:

    clb_dms_files,
    inv_investments
    clb_dms_versions vers, (this table has the size of the documents)
    clb_dms_folders par_fold



    Does anyone have an idea on the Query?


  • 3.  RE: Urgently need 2 Queries
    Best Answer

    Posted Jun 22, 2012 02:38 PM
    Hi,

    Pls modify the query to suit your needs and also test it thoroughly..

    select f.file_id, f.file_name,project_id
    from
    (
    select f.id file_id, f.name file_name,
    ZZ_GET_PROJECT_DOCUMENT(f.id) project_id,
    fo.path_name PARENT_FOLDER_PATH,
    fo.id folder_id,
    fo.folder_type PARENT_FOLDER_TYPE,
    fo.name PARENT_FOLDER_NAME,
    v.byte_size BYTE_SIZE
    from clb_dms_folders fo ,
    clb_dms_versions v ,
    clb_dms_files f
    where
    v.file_id = f.id and
    f.parent_folder_id = fo.id

    )
    f

    where project_id in
    (
    select i.id
    from
    inv_investments i where is_active=0 and schedule_finish <= '31-dec-2010'
    )


    CREATE OR REPLACE FUNCTION "ZZ_GET_PROJECT_DOCUMENT"
    (F_FILEID NUMBER)
    RETURN INTEGER
    IS
    PROJECT_ID NUMBER := 0;

    BEGIN


    SELECT ID INTO PROJECT_ID from inv_investments
    WHERE ID IN
    (
    SELECT
    ASSOC_OBJ_ID
    FROM
    CLB_DMS_FOLDERS
    CONNECT BY



    ID = PRIOR parent_folder_id


    START WITH



    ID = (select parent_folder_id from clb_dms_files where id=F_FILEID)
    ) ;

    RETURN PROJECT_ID;

    EXCEPTION
    WHEN NO_DATA_FOUND THEN RETURN 1;
    WHEN TOO_MANY_ROWS THEN RETURN 3;
    WHEN OTHERS THEN RETURN 2;

    END;
    /


    cheers,
    sundar


  • 4.  RE: Urgently need 2 Queries

    Posted Jun 22, 2012 02:44 PM
    Thanks Sundar! I will try this and then post results.


  • 5.  RE: Urgently need 2 Queries

    Posted Jun 22, 2012 02:55 PM
      |   view attached
    Hi,

    You can use the ER diagram to cross verify.

    cheers,
    sundar


  • 6.  RE: Urgently need 2 Queries

    Posted Jun 25, 2012 11:25 AM
    Hi All

    Does anyone have a suggested Query for the following scenario?
    1.) Non-current versions of documents, where the current version was last accessed on or before 12/31/2011.

    Thanks!