Removing a row from SQL query results when there is a duplicate hostname

I have a query created for a software usage report in SCCM. When there are multiple versions of the same software (Acrobat) installed on the same machine, I will receive duplicate results for the same machine. For example, it will come back with Acrobat
9 and another Acrobat 10 for HOSTNAME1. However, only Acrobat 10 has a usage count. Is it possible to delete the row for Acrobat that has a software usage count of "0/null" if there is another Acrobat results showing up that actually has a usage
count? Let me know if I need to clarify. Any suggestions would be appreciated.

It is more complicated than doing just "Where usage count >0 and usage is not NULL"
because I still want results that have a 0 usage count. I just don't want to have duplicate machines show up for the same software IF one of them returns a usage count of 0.
SELECT DISTINCT
abc.SECTOR
,abc.BA
,abc.SITE
,abc.HOSTNAME as 'Name0'
,rs.ResourceID
,CASE
WHEN mf.OriginalFileName = 'dwrcc.exe' THEN 'DameWare'
WHEN mf.OriginalFileName = 'matlab.exe' THEN 'MathWorks'
WHEN mf.OriginalFileName IN ('encoder.exe','expressionweb.exe','exprwd.exe','mappoint.exe','winproj.exe','visio.exe','devenv.exe','VBExpress.exe','VCExpress.exe','VCSExpress.exe','VWDExpress.exe','excel.exe','groove.exe','infopath.exe','msaccess.exe','mspub.exe','onenote.exe','outlook.exe','powerpnt.exe','winword.exe','communicator.exe')
THEN 'Microsoft'
WHEN mf.OriginalFileName IN ('acrobat.exe','Acrobat Elements.exe','AfterFX.exe','Audition.Exe','Adobe Audition.Exe','AdobeCaptivate.exe','CFReportBuilder.exe','Coldfusion.Exe','Contribute.exe','director.exe','Projector.exe','dreamweaver.exe','Adobe
Encore.exe','Adobe Encore Dvd.Exe','Encoredvd.Exe','Fireworks.exe','FlashBuilder4.exe','flash.exe','Flex Builder.exe','FlexBuilder.exe','Framemaker.Exe','framemaker+sgml.exe','illustrator.exe','HomeSite+.exe','homesite4.exe','homesite45.exe','Homesite5.exe','InDesign.exe','Lightroom.exe','Adobe
OnLocation.exe','Pm65.Exe','Pm70.Exe','pm.exe','pm4.exe','pm5.exe','pm6.exe','photoshop.exe','Photosle.exe','Photoshopelementsorganizer.Exe','Photoshopelementseditor.Exe','photoshp.exe','Lightroom.exe','Adobe Premiere Elements.Exe','Adobe Premiere Elements
8.0.Exe','Adobe Premiere Elements 10.Exe','Adobe Premiere Elements 9.Exe','Adobe Premiere Elements 7.0.exe','Premiere.Exe','Adobe Premiere Pro.Exe','Adobe-Pr-Vc.Exe','Robohelp.Exe','robodemo.exe','roboinfo.exe','Adobe Soundbooth CS5.exe','Adobe Soundbooth
CS4.exe','Adobe Soundbooth CS3.exe','Adobe Media Encoder.exe','speedgrade.exe','adobe prelude.exe') THEN 'Adobe'
ELSE 'OTHER'
END as 'Publisher'
,(CASE mf.OriginalFileName
WHEN 'acrobat.exe' THEN 'Acrobat'
WHEN 'Acrobat Elements.exe' THEN 'Acrobat Elements'
WHEN 'AfterFX.exe' THEN 'After Effects'
WHEN 'Audition.exe' THEN 'Audition'
WHEN 'Adobe Audition.exe' THEN 'Audition'
WHEN 'AdobeCaptivate.exe' THEN 'Captivate'
WHEN 'CFReportBuilder.exe' THEN 'Coldfusion Builder'
WHEN 'Coldfusion.exe' THEN 'Coldfusion Standard'
WHEN 'Contribute.exe' THEN 'Contribute'
WHEN 'dwrcc.exe' THEN 'DameWare Mini Remote Control'
WHEN 'director.exe' THEN 'Director'
WHEN 'Projector.exe' THEN 'Director'
WHEN 'dreamweaver.exe' THEN 'Dreamweaver'
WHEN 'Adobe Encore.exe' THEN 'Encore'
WHEN 'Adobe Encore Dvd.exe' THEN 'Encore'
WHEN 'Encoredvd.exe' THEN 'Encore'
WHEN 'encoder.exe' THEN 'Expression'
WHEN 'expressionweb.exe' THEN 'Expression'
WHEN 'exprwd.exe' THEN 'Expression'
WHEN 'Fireworks.exe' THEN 'Fireworks'
WHEN 'FlashBuilder4.exe' THEN 'Flash Builder'
WHEN 'flash.exe' THEN 'Flash Pro'
WHEN 'Flex Builder.exe' THEN 'FlexBuilder'
WHEN 'FlexBuilder.exe' THEN 'FlexBuilder'
WHEN 'Framemaker.exe' THEN 'FrameMaker'
WHEN 'framemaker+sgml.exe' THEN 'FrameMaker'
WHEN 'HomeSite+.exe' THEN 'Homesite'
WHEN 'homesite4.exe' THEN 'Homesite'
WHEN 'homesite45.exe' THEN 'Homesite'
WHEN 'Homesite5.exe' THEN 'Homesite'
WHEN 'illustrator.exe' THEN 'Illustrator'
WHEN 'InDesign.exe' THEN 'InDesign'
WHEN 'Lightroom.exe' THEN 'Lightroom'
WHEN 'mappoint.exe' THEN 'MapPoint'
WHEN 'Adobe Media Encoder.exe' THEN 'Media Encoder'
WHEN 'Adobe OnLocation.exe' THEN 'OnLocation'
WHEN 'Pm65.exe' THEN 'PageMaker'
WHEN 'Pm70.exe' THEN 'PageMaker'
WHEN 'pm.exe' THEN 'PageMaker'
WHEN 'pm4.exe' THEN 'PageMaker'
WHEN 'pm5.exe' THEN 'PageMaker'
WHEN 'pm6.exe' THEN 'PageMaker'
WHEN 'photoshop.exe' THEN 'Photoshop'
WHEN 'Photosle.exe' THEN 'Photoshop'
WHEN 'Photoshopelementsorganizer.exe' THEN 'Photoshop Elements'
WHEN 'Photoshopelementseditor.exe' THEN 'Photoshop Elements'
WHEN 'photoshp.exe' THEN 'Photoshop Elements'
WHEN 'Lightroom.exe' THEN 'Photoshop Lightroom'
WHEN 'adobe prelude.exe' THEN 'Prelude'
WHEN 'Adobe Premiere Elements.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 8.0.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 10.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 9.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 7.0.exe' THEN 'Premiere Elements'
WHEN 'Premiere.exe' THEN 'Premiere Pro'
WHEN 'Adobe Premiere Pro.exe' THEN 'Premiere Pro'
WHEN 'Adobe-Pr-Vc.exe' THEN 'Presenter'
WHEN 'winproj.exe' THEN 'Project'
WHEN 'Robohelp.exe' THEN 'RoboHelp'
WHEN 'robodemo.exe' THEN 'RoboHelp'
WHEN 'roboinfo.exe' THEN 'RoboHelp'
WHEN 'Adobe Soundbooth CS5.exe' THEN 'Soundbooth'
WHEN 'Adobe Soundbooth CS4.exe' THEN 'Soundbooth'
WHEN 'Adobe Soundbooth CS3.exe' THEN 'Soundbooth'
WHEN 'speedgrade.exe' THEN 'Speedgrade'
WHEN 'visio.exe' THEN 'Visio'
WHEN 'devenv.exe' THEN 'Visual Studio'
WHEN 'VBExpress.exe' THEN 'Visual Studio'
WHEN 'VCExpress.exe' THEN 'Visual Studio'
WHEN 'VCSExpress.exe' THEN 'Visual Studio'
WHEN 'VWDExpress.exe' THEN 'Visual Studio'
WHEN 'WinWord.exe' THEN 'Word'
WHEN 'matlab.exe' THEN 'MATLAB'
ELSE mf.OriginalFileName
END) as 'ProductName'
,mf.OriginalFileName
,sf.FileDescription
,CASE
WHEN sf.FilePath like '%acrobat%' and sf.FileVersion != '' THEN left(sf.FileVersion,patindex('%.%',sf.FileVersion)-1)
ELSE sf.FileVersion
END AS 'FileVersion'
,sf.FilePath
,mf.MeteredFileID
,ISNULL(mus.UsageTime, '') as 'USAGETIME'
,ISNULL(mus.UsageCount, '') as 'USAGECOUNT'
,mus.LastUsage
--,ISNULL(CONVERT(VARCHAR,mus.LastUsage,21),'') as 'Last Used'
,CASE
WHEN mus.LastUsage IS NULL and
sf.FilePath like '%\Program Files\Hewlett-Packard\%'
or sf.FilePath like '_:\Windows\%'
or sf.FilePath like '% old %'
or sf.FilePath like '%[_]old[_]%'
or sf.FilePath like '%backup%'
or sf.FilePath like '_:\Data\%'
or sf.FilePath like 'C:\Users\%'
or sf.FilePath like 'C:\Documents and Settings\%'
or (sf.FileName = 'acrobat.exe' and sf.FileDescription IS NULL)
THEN 'FALSE'
ELSE 'TRUE'
END as 'VALID'
,ISNULL(ui.UserName,scum.TopConsoleUser0) as 'PrimaryUser'
FROM
v_MeteredFiles mf
INNER JOIN v_GS_SoftwareFile sf on mf.MeteredFileID = sf.FileID
--LEFT JOIN v_SoftwareFile sfi on sfi.FileID = sf.FileID
LEFT JOIN v_R_System rs on sf.ResourceID = rs.ResourceID and rs.Obsolete0 = 0 and rs.Active0 = 1
LEFT JOIN v_CH_ClientSummary ch on ch.ResourceID = rs.ResourceID
INNER JOIN [CUSTOM].[dbo].[ABC_SITES] abc on rs.Name0 = abc.HOSTNAME and abc.SERV_FL = 'N'
LEFT JOIN (
SELECT ResourceID,FileID,SUM(UsageCount) as 'UsageCount',MAX(MeteredUserID) as 'UserID',SUM(UsageTime) as 'UsageTime',MAX(LastUsage) as 'LastUsage'
FROM v_MonthlyUsageSummary
GROUP BY ResourceID,FileID
) mus on mus.ResourceID = sf.ResourceID and mus.FileID = mf.MeteredFileID
LEFT JOIN v_Users ui on ui.UserID = mus.UserID
LEFT JOIN v_GS_SYSTEM_CONSOLE_USAGE_MAXGROUP scum on scum.ResourceID = rs.ResourceID
WHERE
(ch.LastActiveTime >= GETDATE()-30 or bae.LOGON_TMSP >= GETDATE()-30)
and mf.OriginalFileName != 'WinWord.exe'
--Exclude files in Recycle Bin
and sf.FilePath not like '_:\$Recycle.Bin%'
--Exclude invalid flash FileID's:
and sf.FileID not in ('216172782114109353','216172782113863960','216172782113863969','216172782114336737','216172782114337853','216172782114009539','216172782114088205','216172782114148960','216172782114088174','216172782114109319','216172782113854316','216172782114045303','216172782114103331','216172782114318673','216172782113997536','216172782114103319','216172782114035585','216172782114035580','288230376151905593','288230376152414835','288230376152326390','288230376152414762','288230376152752371','288230376152238194','288230376151864114','288230376152221470','288230376152194417','288230376152452591','288230376152433530','288230376151826881','288230376151905590','288230376151993886','288230376152142718','288230376151766967','288230376151949862','288230376151870700','288230376151805491','288230376151796019','288230376152041232','288230376152068486','288230376152330596','288230376151982279','288230376151982277','288230376152126901','288230376151864098','288230376152129697','288230376152055728','216172782113836986','288230376152068474','288230376152068500','288230376151754145','288230376152241787','216172782113974892','288230376152107352','288230376152049272','288230376152367258','288230376152014270','288230376152423348','288230376151777614','288230376152137355','288230376152699042','288230376151777252','288230376152025890','288230376152688217','216172782113850093','216172782113850201','216172782114478326','216172782114139161','216172782113976965','216172782114084839','216172782114084848','288230376151766956','288230376152068464','288230376151766948','288230376152068455','288230376151903237','288230376151857402','288230376151933218','216172782113888320','216172782113867157','216172782113798401','216172782113884867')
and sf.FileDescription not like '%PackageForTheWeb%'
and sf.FileDescription not like '%Projector%'
and sf.FileDescription not like '%Adobe Reader%'
and sf.FileDescription not like '%Netopsystems%'
and abc.SECTOR in (@Sector)
and abc.BA in (@Business_Area)
and abc.SITE in (@Site)
and (CASE mf.OriginalFileName
WHEN 'acrobat.exe' THEN 'Acrobat'
WHEN 'Acrobat Elements.exe' THEN 'Acrobat Elements'
WHEN 'AfterFX.exe' THEN 'After Effects'
WHEN 'Audition.exe' THEN 'Audition'
WHEN 'Adobe Audition.exe' THEN 'Audition'
WHEN 'AdobeCaptivate.exe' THEN 'Captivate'
WHEN 'CFReportBuilder.exe' THEN 'Coldfusion Builder'
WHEN 'Coldfusion.exe' THEN 'Coldfusion Standard'
WHEN 'Contribute.exe' THEN 'Contribute'
WHEN 'dwrcc.exe' THEN 'DameWare Mini Remote Control'
WHEN 'director.exe' THEN 'Director'
WHEN 'Projector.exe' THEN 'Director'
WHEN 'dreamweaver.exe' THEN 'Dreamweaver'
WHEN 'Adobe Encore.exe' THEN 'Encore'
WHEN 'Adobe Encore Dvd.exe' THEN 'Encore'
WHEN 'Encoredvd.exe' THEN 'Encore'
WHEN 'encoder.exe' THEN 'Expression'
WHEN 'expressionweb.exe' THEN 'Expression'
WHEN 'exprwd.exe' THEN 'Expression'
WHEN 'Fireworks.exe' THEN 'Fireworks'
WHEN 'FlashBuilder4.exe' THEN 'Flash Builder'
WHEN 'flash.exe' THEN 'Flash Pro'
WHEN 'Flex Builder.exe' THEN 'FlexBuilder'
WHEN 'FlexBuilder.exe' THEN 'FlexBuilder'
WHEN 'Framemaker.exe' THEN 'FrameMaker'
WHEN 'framemaker+sgml.exe' THEN 'FrameMaker'
WHEN 'HomeSite+.exe' THEN 'Homesite'
WHEN 'homesite4.exe' THEN 'Homesite'
WHEN 'homesite45.exe' THEN 'Homesite'
WHEN 'Homesite5.exe' THEN 'Homesite'
WHEN 'illustrator.exe' THEN 'Illustrator'
WHEN 'InDesign.exe' THEN 'InDesign'
WHEN 'Lightroom.exe' THEN 'Lightroom'
WHEN 'mappoint.exe' THEN 'MapPoint'
WHEN 'Adobe Media Encoder.exe' THEN 'Media Encoder'
WHEN 'Adobe OnLocation.exe' THEN 'OnLocation'
WHEN 'Pm65.exe' THEN 'PageMaker'
WHEN 'Pm70.exe' THEN 'PageMaker'
WHEN 'pm.exe' THEN 'PageMaker'
WHEN 'pm4.exe' THEN 'PageMaker'
WHEN 'pm5.exe' THEN 'PageMaker'
WHEN 'pm6.exe' THEN 'PageMaker'
WHEN 'photoshop.exe' THEN 'Photoshop'
WHEN 'Photosle.exe' THEN 'Photoshop'
WHEN 'Photoshopelementsorganizer.exe' THEN 'Photoshop Elements'
WHEN 'Photoshopelementseditor.exe' THEN 'Photoshop Elements'
WHEN 'photoshp.exe' THEN 'Photoshop Elements'
WHEN 'Lightroom.exe' THEN 'Photoshop Lightroom'
WHEN 'adobe prelude.exe' THEN 'Prelude'
WHEN 'Adobe Premiere Elements.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 8.0.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 10.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 9.exe' THEN 'Premiere Elements'
WHEN 'Adobe Premiere Elements 7.0.exe' THEN 'Premiere Elements'
WHEN 'Premiere.exe' THEN 'Premiere Pro'
WHEN 'Adobe Premiere Pro.exe' THEN 'Premiere Pro'
WHEN 'Adobe-Pr-Vc.exe' THEN 'Presenter'
WHEN 'winproj.exe' THEN 'Project'
WHEN 'Robohelp.exe' THEN 'RoboHelp'
WHEN 'robodemo.exe' THEN 'RoboHelp'
WHEN 'roboinfo.exe' THEN 'RoboHelp'
WHEN 'Adobe Soundbooth CS5.exe' THEN 'Soundbooth'
WHEN 'Adobe Soundbooth CS4.exe' THEN 'Soundbooth'
WHEN 'Adobe Soundbooth CS3.exe' THEN 'Soundbooth'
WHEN 'speedgrade.exe' THEN 'Speedgrade'
WHEN 'visio.exe' THEN 'Visio'
WHEN 'devenv.exe' THEN 'Visual Studio'
WHEN 'VBExpress.exe' THEN 'Visual Studio'
WHEN 'VCExpress.exe' THEN 'Visual Studio'
WHEN 'VCSExpress.exe' THEN 'Visual Studio'
WHEN 'VWDExpress.exe' THEN 'Visual Studio'
WHEN 'WinWord.exe' THEN 'Word'
WHEN 'matlab.exe' THEN 'Matlab'
ELSE mf.OriginalFileName
END) IN (@MeteredProduct)
ORDER BY
abc.SECTOR
,abc.BA
,abc.SITE
,abc.HOSTNAME

Similar Messages

  • How to remove database name from SQL query

    We have an MS SQL server with several databases that are of the same schema but have different data.  We do this for testing different environments.  We are using Crystal reports for the first time and we are having trouble changing the database location in the designer.  If update the data source location to the same database server, but different database name, the data still comes from the original database used when creating the report.  We look at the SQL query and it contains the database name and does not change when updating the data source.  Therefore the data always comes from the database used when originally creating the report.
    How can I remove the database name from the SQL query so the proper database is used when testing the report?

    Hi C F
    Please ensure you have followed the procedure mentioned below:
    In Crystal Reports, there are two ways to set the location of the data source your report points to, depending on your connection type.
    For ODBC and Native Connections:
    1. On the 'Database' menu, click 'Set Datasource Location'.
    2. In the 'Current Data Source' section, click the data source to be changed. You must click each individual table in the data source one by one. If the data source is a stored procedure you will not see individual tables.
    NOTE     In Crystal Reports 10, XIR1, and XIR2, if you are mapping from a data source such as a stored procedure where the report designer can not determine which fields should be mapped automatically, you will see a 'Mapping' dialog box where you can manually map fields, as in the procedure cited above.
    3. In the 'Replace with' section, click the data source you want the report to use.
    4. Click 'Update'.
    5. Close the 'Set Datasource Location' window.
    The report now points to the new location.
    For Native Connections Only:
    1. On the 'Database' menu, click 'Set Datasource Location'.
    2. In the 'Current Data Source' section, click 'Properties' to expand it and right-click 'Database Name: <path to database>'.
    3. Click 'Edit' and then type the path to the
    new data source location.
    4. Close the 'Set Datasource Location' window.
    The report now points to the new location.
    Regards
    Girish

  • Make Dynamic Form from sql query

    Hi... i'm trying to create a VO with sql query, but the attributes for this Vo are should made from rows from sql query not from columns, how i can do this?
    example
    NOMCAMPODATOS -- ORDENBLKWEB
    PLANMINFIANZAS --
    SERIEID -- 5
    CODREMOLQUE -- 4
    CODFORMPAGO -- 24
    CODCIUDAD -- 13
    DIREC -- 10
    EMAIL -- 17
    FECFINVIG -- 20
    VO example
    attributes:
    PLANMDIANZAS NUMBER
    SERIEID NUMBER
    CODREMOLQUE NUMBER
    ETC..
    Edited by: JLopezJujuy on 18-dic-2012 10:01

    Try a PIVOT operator in your SELECT command, or one of the other ways to turn rows into columns. Look in the SQL manual for more information, or ask in the SQL and PL/SQL forum.
    By the way, this doesn't sound like a very good database design. Have a look at this "Ask Tom" thread for a discussion about what is wrong with it - http://asktom.oracle.com/pls/apex/f?p=100:11:0::NO::P11_QUESTION_ID:10678084117056

  • Getting zero-sized reply error when running report from SQL query

    Hi,
    I have a Report from SQL Query in Portal. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

    Problem comes when any of the filter is applied in any one of the cases selected from the GUI.Do you mean that the problems only shows when you run the report in your browser via 9iAS?
    Which version are you using?
    Can you post the before report trigger?

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Getting session hang When calling Function from SQL query

    Hi All,
    I am using Oracle 8.1.7.4.0. I have a fucntion in a Package and I am calling it from the SQL query. When I am firing the query my oracle session is going to hang position and I am not able to any thing. I have to kill the session.
    But this same thing is working fine in Oracle 9.i.
    There are no out parameter and no DML, DDL and DCL statement in this fucntion.
    Could you please get back me what is the problem on it.
    Regards
    SUN

    Check why your session hangs.
    Just a few ideas:
    * Blocking locks?
    * Endless loop?
    * Performance (maybe it is just slow in orac8i and you have to wait a bit longer). Check the execution plans of the SQL statements in your function.
    * Don't use a function, but direct SQL, it is faster in both versions.

  • How do I remove a row from the database?

    Guys and Gals,
    I'm using Studio Edition Version 11.1.1.3.0.
    The code below will delete a row from my table, but how do I actually delete the row from the database as well?
        DCBindingContainer dcbc = (DCBindingContainer)getBindings();
        DCIteratorBinding dcib = dcbc.findIteratorBinding("TipsSelectorIterator");
        dcib.removeCurrentRow();
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable()); In this post, I believe Frank sums up what I should do: Remove row from af:table
    >
    The problem in your case is that this removes the row from the iterator but not your business service. EJB exposes explicit methods to remove an entity. A method lime removeEmployees(employee) >expsed on the EJB model must be called.
    You can drag and drop the "removeEmployees" method then as a button to your page. Rename the text label to "Remove" or "Delete". In the opened dialog box, point the method argument to the >following EL #{bindings.iteratorName.currentRow.dataProvider}. Next time you press the button, the row is deleted from the iterator and the business service
    Huh? So to delete the row, I need to expose a method. But where? Do I do this in the AppModuleImpl so I can expose it to the Client Interface? But then how do I access entities? And what data type is the #{bindings.iteratorName.currentRow.dataProvider}?
    If anyone could point me in a general direction, it'd be great.

    Frank and Shay,
    Thank you both for your posts. I'm amazed there's such a great place to get help. Between the forums, ADF code corner, Not Yet Documented ADF Samples, various blogs and tutorials, it's obvious you guys really care about what you do.
    On my example, that approach doesn't seem to work. I tried following it like so in one of the video tutorials by Shay: http://blogs.oracle.com/shay/2010/04/doing_two_declarative_operatio.html. Following Shay's approach, in my particular case, deletes only from the table. Perhaps it is due to my iterator / collection setup?
    TipsSelector (1 to 1) -> TipsView (1 to *)-> DependentBom -(1 to * Recursive)> RecursiveBom
    TipsSelector references the same View Object as TipsView, but it is set as a 1 to 1 relationship so that I can show TipsView on the page one record at a time. This is the same setup as Tuhra2's hierarchy veiwer example. TipsView / DependentBom is a classic parent / child setup. RecursiveBom is DependentBom referencing itself. Think of it as departments within departments within departments etc...
    I have dragged TipsSelector's Named Criteria (All Queriable Attributes) onto my page and created an ADF Query with Table. A remove button on the table's toolbar calls the two actions, Delete (from TipsSelector's iterator) and then Commit. I have modified the code slightly from my previous post but the end result seems to be the same.
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Delete");
        operationBinding.execute();
        bindings = getBindings();
        operationBinding = bindings.getOperationBinding("Commit");
        operationBinding.execute();
        AdfFacesContext adffacesctx = AdfFacesContext.getCurrentInstance();
        adffacesctx.addPartialTarget(this.getQueryTable());Page Def file
        <action id="Commit" InstanceName="AppModuleDataControl"
                DataControl="AppModuleDataControl" RequiresUpdateModel="true"
                Action="commitTransaction"/>
        <action IterBinding="TipsSelectorIterator" id="Delete"
                InstanceName="AppModuleDataControl.TipsSelector"
                DataControl="AppModuleDataControl" RequiresUpdateModel="false"
                Action="removeCurrentRow"/>On ppr of the query table, the row is gone. However, when I press the Search button on the query again, the record reappears.
    This is beyond me. Am I somehow deleting from the query results but not the database?

  • SQL Query results to CSV as two worksheets

    I'm trying to take two SQL queries and get the results sent to a CSV file on two worksheets.  Looking online I have not found a solid example of using the Excel ComObject to create a CSV then add a new worksheet to the CSV file.  An added bonus
    would be using AutoFit on the columns so everything is easily visible.
    Code found online got me the following script which does work, however it takes 12 minutes to pipe the SQL queries to Excel.  Switching to a CSV and the script executes in 5 seconds.
    This is another nice to have, I was also looking the best way to look at the results (only 1 column) and depending on the length of the data, insert what Excel would call a Cell thereby shifting cells RIGHT but so far have found no clear examples of how
    to accomplish that.  My guess would be modifying my SQL queries but I've posted a question on StackOverFlow and someone suggested modifying the PowerShell Table created from the SQL dataset.Tables
    Code:
    $docs = "C:\Scripts\Output.xlsx"
    If (Test-Path $docs){Remove-Item $docs}
    Function Run-Query {
    param([string[]]$queries,[string[]]$sheetnames)
    ## - Create an Excel Application instance:
    $xlsObj = New-Object -ComObject Excel.Application
    $xlsObj.DisplayAlerts = $false
    $xlsWb = $xlsobj.Workbooks.Add(1)
    ## - Create new Workbook and Sheet (Visible = 1 / 0 not visible)
    $xlsObj.Visible = 0
    $time = 2
    for ($i = 0; $i -lt $queries.Count; $i++){
    $percentage = $i / $time
    $remaining = New-TimeSpan -Seconds ($time - $i)
    $message = "{0:p0} complete" -f $percentage, $remaining
    Write-Progress -Activity "Creating Daily Reboot Spreadsheet" -status $message -PercentComplete ($percentage * 100)
    $query = $queries[$i]
    $sheetname = $sheetnames[$i]
    $xlsSh = $xlsWb.Worksheets.Add([System.Reflection.Missing]::Value, $xlsWb.Worksheets.Item($xlsWb.Worksheets.Count))
    $xlsSh.Name = $sheetname
    ### SQL query results sent to Excel
    $SQLServer = 'ServerName'
    $Database = 'DataBase'
    ## - Connect to SQL Server using non-SMO class 'System.Data':
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $Database; Integrated Security = True"
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $query
    $SqlCmd.Connection = $SqlConnection
    ## - Extract and build the SQL data object '$Table2':
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $SqlConnection.Close()
    $Table1 = $DataSet.Tables["Table"]
    ## - Build the Excel column heading:
    [Array] $getColumnNames = $Table1.Columns | SELECT ColumnName
    ## - Build column header:
    [Int] $RowHeader = 1
    foreach ($ColH in $getColumnNames)
    $xlsSh.Cells.item(1, $RowHeader).font.bold = $true
    $xlsSh.Cells.item(1, $RowHeader) = $ColH.ColumnName
    $RowHeader++
    ## - Adding the data start in row 2 column 1:
    [Int] $rowData = 2
    [Int] $colData = 1
    foreach ($rec in $Table1.Rows)
    foreach ($Coln in $getColumnNames)
    ## - Next line convert cell to be text only:
    $xlsSh.Cells.NumberFormat = "@"
    ## - Populating columns:
    $xlsSh.Cells.Item($rowData, $colData) = $rec.$($Coln.ColumnName).ToString()
    $ColData++
    $rowData++; $ColData = 1
    ## - Adjusting columns in the Excel sheet:
    $xlsRng = $xlsSH.usedRange
    [void] $xlsRng.EntireColumn.AutoFit()
    }#End For loop.
    #Delete unwanted Sheet1.
    $xlsWb.Sheets.Item('Sheet1').Delete()
    #Set Monday to Active Sheet upon opening Workbook.
    $xlsWb.Sheets.Item('Cert').Activate()
    ## ---------- Saving file and Terminating Excel Application ---------- ##
    $xlsFile = "C:\Scripts\Output.xlsx"
    [void] $xlsObj.ActiveWorkbook.SaveAs($xlsFile)
    $xlsObj.Quit()
    ## - End of Script - ##
    start-sleep 2
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsRng)) {'cleanup xlsRng'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsSh)) {'cleanup xlsSh'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsWb)) {'cleanup xlsWb'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsObj)) {'cleanup xlsObj'}
    [gc]::collect() | Out-Null
    [gc]::WaitForPendingFinalizers() | Out-Null
    }#End Function
    $queries = @()
    $queries += "Query1"
    $queries += "Query2"
    $sheetnames = @('Cert','Prod')
    Run-Query -queries $queries -sheetnames $sheetnames

    Here's what I ended up with that accomplishes my goal.  I learned it's not possible to create a CSV with two worksheets since Excel will allow this but the CSV cannot be saved with the second worksheet.  Instead, I create two CSV files then merge
    them into one Excel workbook, one CSV per worksheet.  In my case, this happens in 5 seconds.  There is one thing which must be mentioned, I've seen this script fail the first time it is run but will successfully run the second time.
    Also note, after much trial and error, this code correctly cleans up the Excel ComObject!!  -Thanks go to JRV.
    $docs = "D:\Scripts\MonthlyReboots.xlsx"
    IF (Test-Path $docs){Remove-Item $docs}
    $csv1 = "D:\Scripts\Cert.csv"
    IF (Test-Path $csv1){Remove-Item $csv1}
    $csv2 = "D:\Scripts\Prod.csv"
    IF (Test-Path $csv2){Remove-Item $csv2}
    Function Run-Query {
    param([string[]]$queries,[string[]]$sheetnames,[string[]]$filenames)
    Begin{
    $SQLServer = 'ServerName'
    $Database = 'DataBase'
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $Database; Integrated Security = True"
    $Excel = New-Object -ComObject Excel.Application
    $Excel.Visible = 0
    $dest = $Excel.Workbooks.Add(1)
    }#End Begin
    Process{
    For($i = 0; $i -lt $queries.Count; $i++){
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $queries[$i]
    $SqlCmd.Connection = $SqlConnection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $DataSet.Tables[0] | Export-Csv -NoTypeInformation -Path "D:\Scripts\$($sheetnames[$i]).csv" -Force
    }#end for loop.
    }#End Process
    End{
    $SqlConnection.Close()
    #Excel magic test!
    For($i = 0; $i -lt $queries.Count; $i++){
    $loopy = (Resolve-Path -Path $filenames[$i]).ProviderPath
    $Book = $Excel.Workbooks.Open($loopy)
    $next = $Excel.workbooks.Open($loopy)
    $next.ActiveSheet.Move($dest.ActiveSheet)
    $xlsRng = $dest.ActiveSheet.UsedRange
    $xlsRng.EntireColumn.AutoFit() | Out-Null
    $dest.sheets.item('Sheet1').Delete()
    $xlsFile = "D:\Scripts\MonthlyReboots.xlsx"
    [void] $Excel.ActiveWorkbook.SaveAs($xlsFile)
    $Excel.Quit()
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsRng)) {'cleanup xlsRng'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($next)) {'cleanup xlsSh'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($Book)) {'cleanup xlsWb'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)) {'cleanup xlsObj'}
    [gc]::collect() | Out-Null
    [gc]::WaitForPendingFinalizers() | Out-Null
    }#End end block.
    }#End function run-query.
    $queries = @()
    $queries += @'
    Select * from table1
    $queries += @'
    Select * from table2
    $sheetnames = @("Cert","Prod")
    $filenames = @("D:\Scripts\Prod.csv","D:\Scripts\Cert.csv")
    Run-Query -queries $queries -sheetnames $sheetnames -filenames $filenames
    Start-Sleep -Milliseconds 50
    Invoke-Item D:\Scripts\MonthlyReboots.xlsx

  • Grouping rows from a query

    Hi everyone!
    I want to know if it's posible to group the rows from a query into a unique row. Example:
    SELECT Field_1 FROM Table_1
    Returns the following fileds:
    Field_1
    A
    B
    C
    D
    I would want to modify my query so that the result obtained would be a single row containing all the others. In the previous example the result would be "ABCD".
    Thanks in advance. Best regards,

    -- For anyone who wants to test this,
    -- just copy this entire post as is,
    -- save it to a .sql file, then start that file.
    -- Before doing this,
    -- make sure that you don't already have
    -- a table named table_1 that would be dropped
    -- or a .sql file named query.sql that would be overwritten.
    -- If you do, then change the names below to avoid any conflicts.
    -- In order to understand what the code is doing,
    -- please read all of the comments included in this file,
    -- as not everything is displayed when you run it.
    -- I have gone into great detail with this
    -- because I have posted similar things before
    -- and a lot of people have total missed the fact
    -- that it is not a static query,
    -- that the results are dependent upon the number of rows,
    -- and that it works for any number of rows,
    -- even when the number of rows is unknonwn.
    -- test data:
    DROP TABLE table_1
    CREATE TABLE table_1
      (field_1 VARCHAR2 (1))
    INSERT INTO table_1 (field_1)
    VALUES ('A')
    INSERT INTO table_1 (field_1)
    VALUES ('B')
    INSERT INTO table_1 (field_1)
    VALUES ('C')
    INSERT INTO table_1 (field_1)
    VALUES ('D')
    COMMIT
    SELECT * FROM table_1
    -- Running the code below will create and start
    -- a file named query.sql which will contain the query below,
    -- which will produce the results below that:
    -- query that will be created:
    -- SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))                                      
    -- ||MAX(DECODE(ROWNUM,2,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,3,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,4,field_1,NULL))                                           
    -- FROM table_1 GROUP BY NULL;                                                    
    -- results that will be produced:
    -- ABCD
    -- Notice that in this example,
    -- there are only four values concatenated
    -- because there are only four rows in the table. 
    -- If there were more rows, it would concatenate more values. 
    -- The number of concatenated values
    -- is dependent upon the number of rows.
    -- The following dynamic sql uses a single query,
    -- which produces and executes a single query,
    -- whose number of concatenated values is dependent
    -- upon the number of rows in the table.
    -- Because the echo is set off in the first line,
    -- you won't see this code when you run it,
    -- just the query that it creates.
    SET     ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF
    SPOOL   query.sql
    -- This is the start of the single query:
    SELECT  text
    FROM    (SELECT 1                                             AS orderby,
                    'SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))'   AS text
             FROM   DUAL
             UNION
             -- This section is the part that dynamically creates
             -- one additional concatenated value
             -- for each additional row after the first row.
             -- This is just a subquery within the single query.
             SELECT rn                                            AS orderby,
                    '||MAX(DECODE(ROWNUM,'||rn||',field_1,NULL))' AS text
             FROM   (SELECT ROWNUM rn
                     FROM   table_1)
             WHERE  rn > 1
             UNION
             SELECT COUNT (*) + 1                                  AS orderby,
                    'FROM table_1 GROUP BY NULL;'                  AS text
             FROM   table_1)
    ORDER BY orderby;
    -- This is the end of the single query.
    SPOOL    OFF
    START    query
    SET      ECHO ON
    -- If you want to see the file containing
    -- the single query that was created, then just:
    -- SQL> EDIT query.sql

  • Query based Report (Reports From SQL Query)

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    Can i increase a timeout of portal page, how i can do this?
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    Can you post the URL that is giving you the page not found error ? I am not sure if I can be of much help though.
    In order to increase your chances to get a reply you should also post your question in the Portal Forum - Oracle Application Server Portal
    Edited by: Rodolfo Ferrari on Jun 16, 2009 3:49 PM

  • Getting Zero Sized Reply error in report from SQL query

    Hi,
    I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

    Hi,
    I have a Report from SQL Query in Portal 3.0.9. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
    ERROR
    The requested URL could not be retrieved
    While trying to retrieve the URL: <data suppressed>
    The following error was encountered:
    Zero Sized Reply
    Squid did not receive any data for this request.
    Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
    Thanks,
    Lorena

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Report from SQL Query -Excel format only show the first page

    Hi,
    I have some Reports from SQL Query. In the display options, I choose Excel as default format. The Excel documents only show the first page. If I choose HTML as default format, it shows every rows.
    Please advise on how to have a complete Excel document as HTML format does.
    Thanks a lot.
    Lina Han

    I beleive when you export Oracle reports to Excel it is the Data that is transferred along with Column Names.
    You cannot export the variables defined on the report.
    Hence you will not be able to export the Footer to excel. (Still looking into it will let you know if i find anything interesting)
    Regards,
    Bhushan Salgar

  • Report from sql query invalid date condition

    Hi, I created a Reports From SQL Query. My sql is like
    "select column1, column2
    from myschema.tablename
    where mydate > :p_date1 and mydate < :p_date2"
    I am using portal with turkish and english option. If I pass p_date paramaters 'dd-MON-yyyy' format
    (for example p_date1 = 23-MAR-2003 p_date2 = 26-APR-2003) in english mode portlet is return correct result,
    in turkish mode 'No Row Returned'. I changed my sql statement with
    "select column1, column2
    from myschema.tablename
    where to_date(mydate,'dd/mm/yyy') > to_date(:p_date1,'dd/mm/yyy') and to_date(mydate) < to_date(:p_date2,'dd/mm/yyyy')"
    and I pass p_date parameters 'dd/mm/yyyy' format (for example p_date1 = 23/03/2003 p_date2 = 26/04/2003)
    but now turkish and english mode No row returned.
    How may I write correct sql statament. My database NLS_DATE_FORMAT=DD/MM/YYYY and NLS_LANGUAGE=TURKISH.
    thanks.

    Hi,
    Try this for turkish mode:
    Case 1: the 'mydate' column has a kind of a char data type (like char, varchar or varchar2)
    and a value like '30/03/2003'
    "select column1, column2
    from myschema.tablename
    where
    to_date(mydate,'DD/MM/YYYY') > :p_date1
    and
    to_date(mydate,'DD/MM/YYYY') < :p_date2"
    Case 2: the mydate column has a date type:
    "select column1, column2
    from myschema.tablename
    where
    mydate > :p_date1
    and
    mydate < :p_date2"
    In both cases use the following parameter values:
    p_date1 = 23/03/2003
    p_date2 = 26/04/2003
    This should work
    Thanks
    Peter

  • How to remove a row from a rowset obtained via a CachedRowSetDataProvider

    I have a table filled from a database that it is bound to.
    I have the CachedRowSetDataProvider that supplies the rows.
    I want to remove a row from the result set and can't figure out how.
    There is a method ... removeRow(RowKey row).
    and there is a method ... getRowKey(java.lang.String rowId)
    How do I determine what the string id is for, say, row 3?
    thanks
    jim murray

    Thats the tutorial I am working with.
    My problem is that the statement tripDataProvider.refresh();
    executed when the person drop down changes doesn't seem to clearing the previous persons results.
    So I want to clear the rowset myself by deleting the rows individually.
    I can find a method to delete a row if I supply the RowKey.
    There is a method to get the rowkey if I know the RowID, which is a string.
    Unfortunately I dont know the string to use for an arbitrary row.
    There should be a simpler way to clear the data from a rowset.
    regards
    jim murray

Maybe you are looking for

  • Zero Rows suppression is not working in Webi report.

    Hello Gurus, I have created a Web' report on top of BEx query. I am getting the report with Zero values. I want to suppress the rows with Zero values. When I ran the same query in BEx it is suppressing the zeros. (I have the property to suppress the

  • How to use FaceTime using an email address

    How can you use multiple email addresses for FaceTime purposes?

  • Transactions report "Could not connect to daemon"

    Currently evaluationg ZLM 66, and am running into a problem with transactions. All appropriate modules are installed on client, and rcd is running correctly (as far as I can tell). Client activated to my ZLM server just fine, so I know communication

  • I have reset, uninstalled, reinstalled and still it keeps not responding, why?

    The last update has caused me nothing but problems. If I uninstall Firefox everything runs fine. With it installed I am having issues with all programs. They stop responding, I do school online and have to keep my laptop running, if this is not solve

  • Scopes Not Displaying

    My scopes are not displaying in the viewer window, only the video. I used Color with the scopes about a week ago, but maybe someone else changed something on the same computer. How can I get my scopes back?