Query registry with powershell for certain value

Hi,
Ever since Windows 7 we are having trouble with USB-printers. For some reason they get disabled ever so often.
The only solution we have then, (that works) is to fully remove and re-install the device.
However, we give our printer a specific name "loketprinter". If you remove the printer, some values with "Loketprinter" remains in the registry. These are located in various locations troughout the registry.
Therefore i'm looking for a fast way to query and delete values or keys that contain "loketcomputer".
I want to search the whole register.
Could you please get me on my way?

after some googeling and reading the help file i've created the following: 
Get-ChildItem HKCU:, HKLM: -Recurse -Include *Loket* -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
This only find parts of it, but at least its something.
Its really slow though

Similar Messages

  • Stacked 100% bar chart - Problem with datatips for zero value data points

    I have a stacked 100% bar chart that shows datatips in Flex 4.   However, I don't want it to show datatips for
    data points with zero values.   Flex 4 shows the datatip for a zero value data point on the left side of a bar if the data point is not the first in the series.
    Here's the code that illustrates this problem.    Of particular concern is the July bar.    Because of the zero value data point problem, it's not possible to see the datatip for "aaa".
    Any ideas on how we can hide/remove the datatips for zero value data points ?        Thanks.
    <?xml version="1.0"?>
    <s:Application
    xmlns:fx="
    http://ns.adobe.com/mxml/2009"xmlns:mx="
    library://ns.adobe.com/flex/mx"xmlns:s="
    library://ns.adobe.com/flex/spark"creationComplete="initApp()"
    height="
    1050" width="600">
    <s:layout>
    <s:VerticalLayout/>
    </s:layout>
    <fx:Script><![CDATA[ 
    import mx.collections.ArrayCollection;[
    Bindable] 
    private var yearlyData:ArrayCollection = new ArrayCollection([{month:
    "Aug", a:1, b:10, c:1, d:10, e:0},{month:
    "July", a:1, b:10, c:10, d:10, e:0},{month:
    "June", a:10, b:10, c:10, d:10, e:0},{month:
    "May", a:10, b:10, c:10, d:0, e:10},{month:
    "April", a:10, b:10, c:0, d:10, e:10},{month:
    "March", a:10, b:0, c:10, d:10, e:10},{month:
    "February", a:0, b:10, c:10, d:10, e:10},{month:
    "January", a:10, b:10, c:10, d:10, e:10}]);
    private function initApp():void {}
    ]]>
    </fx:Script>
    <s:Panel title="Stacked Bar Chart - Problems with DataTips for Zero Value Items" id="panel1">
    <s:layout>
    <s:HorizontalLayout/>
    </s:layout>
    <mx:BarChart id="myChart" type="stacked"dataProvider="
    {yearlyData}" showDataTips="true">
    <mx:verticalAxis>
     <mx:CategoryAxis categoryField="month"/>
     </mx:verticalAxis>
     <mx:series>
     <mx:BarSeries
    xField="a"displayName="
    aaa"/>
     <mx:BarSeries
    xField="b"displayName="
    bbb"/>
     <mx:BarSeries
    xField="c"displayName="
    ccc"/>
     <mx:BarSeries
    xField="d"displayName="
    ddd"/>
     <mx:BarSeries
    xField="e"displayName="
    eee"/>
     </mx:series>
     </mx:BarChart>
     <mx:Legend dataProvider="{myChart}"/>
     </s:Panel>
     <s:RichText width="700">
     <s:br></s:br>
     <s:p fontWeight="bold">The problem:</s:p>
     <s:p>Datatips for zero value data points appear on left side of bar (if data point is not the first point in series).</s:p>
     <s:br></s:br>
     <s:p fontWeight="bold">For example:</s:p>
     <s:p>1) For "June", eee = 0, mouse over the left side of the bar to see a datatip for "eee". Not good.</s:p>
     <s:br></s:br>
     <s:p>2) For "July", eee = 0 and aaa = 1, can't see the datatip for "aaa", instead "eee" shows. Real bad.</s:p>
     <s:br></s:br>
     <s:p>3) For "Feb", aaa = 0, datatip for "aaa" (first point) does not show. This is good.</s:p>
     <s:br></s:br>
     <s:p>4) For "Mar", bbb = 0, datatip for "bbb" shows on the left side of the bar. Not good.</s:p>
     <s:br></s:br>
     <s:p fontWeight="bold">Challenge:</s:p>
     <s:p>How can we hide/remove datatips for zero value data points?</s:p>
     <s:br></s:br>
     </s:RichText></s:Application>

    FYI.
    Still have the issue after upgrading to the latest Flex Builder 4.0.1 with SDK 4.1.0 build 16076.   
    Posted this as a bug in the Adobe Flex Bug and Issue Management system.     JIRA
    http://bugs.adobe.com/jira/browse/FLEXDMV-2478
    Which is a clone of a similar issue with Flex 3 ...
    http://bugs.adobe.com/jira/browse/FLEXDMV-1984

  • How to Query remote PC's registry by OU for 2 values and export to CSV file.

    I'm new to scripting and to Powershell but this is what I have managed to put together so far. Of course it fails. We have two custom entries in the registry that I want to query remote workstations for these values, Monitor 1 and Monitor 2. Output to a
    CSV along with the workstations name. Because of our AD structure I figured its just easier to input the OU individually as seen in the script. That portion of the script seems to work. I get the following error in bold when I run the script: I've Google'd
    and tinkered with this for a week now with no resolution and seem to be going in circles.  And yes, I had help to get this far.
    Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
    At C:\utils\RegMonitor2.ps1:33 char:5
    +     $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$result.pro ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : IOException
    Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
    At C:\utils\RegMonitor2.ps1:33 char:5
    +     $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$result.pro ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : IOException
    # 1) Searches Active Directory for all Computers under said OU
    # 2) Searches remote registry of those machines for the mentioned Monitor and Monitor2 subkeys.
    # 3) Exports CSV (Can be opened and saved as excel format later) with ordered columns Computername, Monitor1 value, monitor2 value.
    # ================================================================
    $SearchPath = "OU=XXX,OU=XXX,OU=XXX,DC=XXX,DC=XXX,DC=XXX"
    $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
    $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$SearchPATH")
    $objSearcher.PageSize = 1000
    $objSearcher.Filter = "(objectClass=computer)"
    $objSearcher.SearchScope = "Subtree"
    $colProplist = "name"
    $colResults = $objSearcher.FindAll()
    $Store = @()
    $Hive = [Microsoft.Win32.RegistryHive]"LocalMachine";
    foreach ($result in $colResults)
    # Use $result.properties.name to retreive ComputerName
    $obj = New-Object PsObject
    $obj | Add-member -type noteproperty -name "Computername" -Value $result.properties.name
    $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$result.properties.name);
    $ref = $regKey.OpenSubKey("SYSTEM\CurrentcontrolSet\control\Session Manager\Environment");
    $obj | Add-member -type Noteproperty -name "Monitor1" -value $ref.OpenSubKey("Monitor")
    $obj | Add-member -type Noteproperty -name "Monitor2" -value $ref.OpenSubKey("Monitor2")
    $store += $obj
    $store | Select-Object Computername,Monitor1,Monitor2 | Export-CSV -noTypeInformation -Path "Pathtosave.csv"
    People are always promising the apocalypse. They never deliver.
    Ok, I have modified the end of the script a bit, and no more error: Instead I get an unexpected output.
    foreach ($result in $colResults)
        # Use $result.properties.name to retreive ComputerName
        $obj = New-Object PsObject
        $obj | Add-member -type noteproperty -name "Computername" -Value $result.properties.name
        $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$result.properties.name);
        $ref = $regKey.OpenSubKey("SYSTEM\CurrentcontrolSet\control\Session Manager\Environment");
        $obj | Add-member -type Noteproperty -name "Monitor1" -value $ref.OpenSubKey("Monitor")
        $obj | Add-member -type Noteproperty -name "Monitor2" -value $ref.OpenSubKey("Monitor2")
        $store += $obj
    $store | Select-Object Computername,Monitor1,Monitor2 | Export-CSV -noTypeInformation -Path "C:\Utils\Data.csv"
    Unexpected output:
    "Computername","Monitor1","Monitor2"
    "System.DirectoryServices.ResultPropertyValueCollection",,
    "System.DirectoryServices.ResultPropertyValueCollection",,
    "System.DirectoryServices.ResultPropertyValueCollection",,

    Hi,
    What do your registry values look like in the Monitor and Monitor2 subkeys?
    EDIT: This might help:
    # Retrieve list of computers using Get-ADComputer and process each
    Get-ADComputer -Filter * -SearchBase 'OU=Test PCs,DC=domain,DC=com' | ForEach {
    # Verify PC is alive
    If (Test-Connection $_.Name -Quiet -Count 1) {
    # Connect to registry
    $remoteHive = [Microsoft.Win32.RegistryHive]“LocalMachine”;
    $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($remoteHive,$($_.Name))
    # Open the Environment key
    $ref = $regKey.OpenSubKey('SYSTEM\CurrentcontrolSet\control\Session Manager\Environment')
    # Create an ordered hashtable with the data from string values named 'String Value One/Two' in Monitor and Monitor2 subkeys
    # You'll need to adjust these values based on your actual data
    # If you are running v2, remove [ordered] below (so the line reads $props = @{)
    $props = [ordered]@{
    Computer=$_.Name
    Monitor =$ref.OpenSubKey('Monitor').GetValue('String Value One')
    Monitor2=$ref.OpenSubKey('Monitor2').GetValue('String Value Two')
    # Create a custom object based on the hashtable above
    New-Object PsObject -Property $props
    } | Sort-Object Computer | Export-Csv .\MonitorRegistryCheck.csv -NoTypeInformation
    # The line above sorts the output object by the computer name and then exports the object to a CSV file
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Detail page only for certain values

    I have a page that searches a few tables.
    its a overall search, but there are records we dont want to
    allow anyone to
    edit based on a value.
    So my question is... i have a results page which is already
    setup to display
    all records found.. with a link(go to detail page) how can i
    code it so if
    any of the results have a certain value that link is not
    available?
    Example
    Name Phone Email
    Contact Details
    John 555-555-5555 [email protected] Yes View
    Dave 222-333-4545 [email protected] No
    Jess 854-896-7852 [email protected] Yes View
    Using ASP, SQL2005 and DW8

    Can anyone help with this one?
    I just want to disable the link to the detail page if the
    value for Contact
    is NO then disable Details link
    Using ASP, SQL2005 and DW8
    "Daniel" <[email protected]> wrote in message
    news:f2d35r$806$[email protected]..
    >I have a page that searches a few tables.
    >
    > its a overall search, but there are records we dont want
    to allow anyone
    > to edit based on a value.
    >
    > So my question is... i have a results page which is
    already setup to
    > display all records found.. with a link(go to detail
    page) how can i code
    > it so if any of the results have a certain value that
    link is not
    > available?
    >
    > Example
    >
    > Name Phone Email Contact Details
    > John 555-555-5555 [email protected] Yes View
    > Dave 222-333-4545 [email protected] No
    > Jess 854-896-7852 [email protected] Yes
    > View
    >
    >
    >
    > --
    > Using ASP, SQL2005 and DW8
    >

  • Query Issue with adding a static value

    I have written a query in SAP that works the way I need it to. I am going to schedule it so that SAP does a file transfer of the output to another area where the data will be accumulated.
    My problem is that I want the name of the system to appear at the end of each line but it is not in any table I can find to match up with the userid.
    EX:
    UserID        Group                          System
    JDOE         HR Query Group            P201
    The field for system is not in any tables but I want to add it and give it a constant/static value all the time in the output.
    Any ideas?
    Thanks!
    Justin Dauby -- SAP Security Analyst
    Kimball International Inc.,

    The name of the system is not in a table, but rather a structure called SYST. You can evaluate it using the system field sy-sysid.
    Another option is to call function module RFC_SYSTEM_INFO. The export parameter RFCSI_EXPORT will deliver the system id from component RFCSYSID of the structure RFCSI.
    Cheers,
    Julius

  • Unable to query records with data in exponential value ? ?

    Hello,
    I have a strange problem here, hope someone can answer my query.
    I have 2 tables where the 1st col is a seq with datatype NUMBER(22) and NOT NULL constraint. Now, the value within that col is quite large and hence when I query the table in TOAD/SQL developer it displays output in exponential form. Now the issue is this, In one table I'm able to find/search a particular row by using the exp value within where clause and the same is not possible in other table.
    The sample data is here.
    I'm able to search record by using the below values in 1 table but same is not possible in another.
    1200000211600013
    1.20000021160001E15
    Can anybody tell me what could be the possible reason for this or where should I look for to find an answer?
    Thanks in Advance!!
    Toufiq

    Seems there's no problem in Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    with
    numbers as
    (select 1200000211600013330 the_number from dual union all
    select 1200000211600013333 from dual
    select n.the_number,s.search_string
      from numbers n,
           (select :your_number search_string
              from dual
           ) s
    where n.the_number(+) = to_number(s.search_string)
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    1200000211600013333
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    1.200000211600013333E18
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    12000002116.00013333E+8
    THE_NUMBER
    SEARCH_STRING
    1200000211600013330
    1.20000021160001333E+18
    THE_NUMBER
    SEARCH_STRING
    1.20000021160001333E17
    Even implicit conversion seems to work
    select n.the_number,s.search_string,dump(s.search_string,16) search_dump,dump(n.the_number) result_dump
      from numbers n,
           (select :your_number search_string
              from dual
           ) s
    where s.search_string = n.the_number(+)
    THE_NUMBER
    SEARCH_STRING
    SEARCH_DUMP
    RESULT_DUMP
    1200000211600013330
    1.20000021160001333E18
    Typ=1 Len=22: 31,2e,32,30,30,30,30,30,32,31,31,36,30,30,30,31,33,33,33,45,31,38
    Typ=2 Len=11: 202,2,21,1,1,22,17,1,2,34,31
    Regards
    Etbin

  • ADF Query page with validation on input values

    Hi All,
    I have following requirements to create a search page with 4 input vaules (they are directly mapped to tables/VO) where the last 2 parameters are date values.
    1. Default value for 3rd date input should be sysdate - 30 and the default value for 4th date parameter should be current date.
    2. 4th date parameter should greater than 3rd Parameter
    3. Either enter two date parameters or none should be enter in search criteria. The search should not with one date parameter at a time.
    Also keep in mind the data parameters are with time stamps.
    Any help is appriciated.

    Thanks Frank,
    But could you please elaborate more? How to create another listener to replace with the existing queryListener?
    Do you have any sample, please post here.
    Thanks in advance.

  • Dealing with exponents for double values...

    Hi all,
    I've been putzing around with the NumberFormat class, as well as the Double api, but I can't seem to find a solution on how to remove exponents from double values.
    For example:
    double x = Double.MIN_VALUE;
    Might return 4.9E-123
    How do I remove the E, or any of those special characters, and just retrieve the exact, unshortened value?

    For example:
    double x = Double.MIN_VALUE;
    Might return 4.9E-123It doesn't return 4.9E-123. It returns a double. If you print it out it will look like that.

  • HTML tags for certain values in a report

    Hi, I have built a report with a list of patient visit to a doctor. This is roughly a custom calendar with the names of the patients at different predefined hours.
    I am now trying to display a canceled visit by adding a strike through line for the patient in question.
    The overall look will be list with patient's names and some of them will be strike through-ed if they canceled it.
    So I changed my select for the report to look like this:
    select '<del>' || patient || '</del>' where canceled = 1 ...
    But the report still looks the same - no lines through the names.
    I also tried with bold tag but it seems that the tags are just dropped off somewhere in the process of rendering.
    Could anyone help?

    For using tags in the calendar see this link:
    http://apex.oracle.com/pls/otn/f?p=31517:116
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How do I change the default "open with" application for certain files??  I've tried EVERYTHING!!

    Hi guys!
    PLEASE PLEASE PLEASE someone help me!!!  I have been trying for ages to change this!!  It is SO frustrating!!  I recently bought a new MacBook Pro 13" after my old one (2009) got stolen.  Went from Snow Leopard to 10.8.2, restored all my apps and files etc (thanks goodness I backed up).
    NOW I have a problem!  All my .xls and .doc files open up with Pages and Numbers, and not OpenOffice.  NO MATTER WHAT I DO!!!
    The basic "change open with" "always use this application" story doesn't work.  It always reverts back to Pages or Numbers.  I also tried a Terminal Command I found on this forum from way back in 2010.  But that doesn't work either.  I also tried a .pst deletion but I don't have a .com.apple.launches.pst file!
    PLEASE GUYS.  PLEASE!  SOMEONE HELP ME HERE!!!!!!!!!!  It's driving me nuts!!!!!  LIKE NUTS!!!!!!!

    Here is what I would do:
    Update OpenOffice to the latest Mac OS X version for improved compatibiity with Mountain Lion.
    Boot into Safe Mode to clear caches, verify/repair permissions, and rebuild font database, etc.
    Reboot, holding down the shift key until you see a progress bar on the grey boot screen.
    At the login prompt, and before you click the right arrow button to login, press and hold shift again.
    Reboot normally.
    Now follow sig's advice, and specify OpenOffice as the can opener for Word and Excel files.
    If OpenOffice installs into a /Applications folder as individual writer, and sheet applications, then use these names respectively for Word and Excel files.
    LibreOffice (what I use) only offers the LibreOffice application choice.

  • Having trouble with inner for loop values in my procedure

    Hi ...
    I am using oracle 10g and here is my procedure ...
    create or replace procedure sales_information is
    v_qty number(10);
    rem_qty number(10):=0;
    cursor pck_quantity is
    select * from sales_info;
    cursor no_of_labels is
    select ceil(sum(nvl(total_quantity,actual_quantity))/400) from sales_info;
    begin
    for j in no_of_labels
    loop
    for i in pck_quantity
    loop
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    if v_qty>=i.packed_quantity and rem_qty=0 then
    insert into sales_order values------------
    rem-qty:=v_qty-i.packed_quantity;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>=400 then
    insert into sales_order values-----------
    rem_qty:=v_qty-rem_qty;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>0 then
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    insert into sales_order values-----------
    else if v_qty is null and rem_qty>0 and then
    insert into sales_order values-----------
    else if v_qty<i.packed_quantity and rem_qty:=0 then
    rem_qty:=v_qty;
    else if v_qty<i.packed_quantity and rem_qty>0 then
    if (v_qty+rem_qty)>400 then
    insert into sales_order values-----------
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    end if;
    end if;
    end loop;
    end loop;
    The inner for loop will retrieve the same values of v_qty for every iteration of outer for loop when it runs the following select statement:
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    and thus loses the previously computed values of v_qty and rem_qty
    in the previous iteration of outer for loop whereas i want the inner for loop to iterate over it's previously computed values of v_qty and rem_qty but cant think of a workaround.

    h4. Thanks Dave for explanation. Hope I understood your requirement and below code resolves that
    -- Creating table SALES_INFO
    CREATE TABLE SALES_INFO
    (    S_NO             NUMBER(1),
         ACTUAL_QUANTITY  NUMBER(10),
         TOTAL_QUANTITY   NUMBER(10),
          PACKED_QUANTITY  NUMBER(10)
    -- Creating table sales_order
    CREATE TABLE SALES_ORDER
    (    S_NO             NUMBER(1),
         LABEL            VARCHAR2(30),
         ORDER_QUANTITY   NUMBER(10)
    -- Push SALES_INFO data
    INSERT INTO SALES_INFO VALUES(1,1000,800,400);
    INSERT INTO SALES_INFO VALUES(2,800,600,400);
    INSERT INTO SALES_INFO VALUES(3,800,NULL,400);
    INSERT INTO SALES_INFO VALUES(4,NULL,600,400);
    CREATE OR REPLACE PROCEDURE populate_sales_order AS
    CURSOR get_sales_info IS
    SELECT s_no,
               NVL(total_quantity,actual_quantity) total_quantity,
            packed_quantity
    FROM   sales_info;
    v_s_no          PLS_INTEGER := 0;
    v_rem_qty     PLS_INTEGER := 0;
    v_label_num   PLS_INTEGER := 1;
    BEGIN
    FOR rec IN get_sales_info LOOP
        v_rem_qty := rec.total_quantity + v_rem_qty;
        v_s_no    := rec.s_no;
         WHILE v_rem_qty >= rec.packed_quantity LOOP
           INSERT INTO sales_order( s_no, label, order_quantity)
           VALUES ( v_s_no, 'LABEL' || v_label_num, rec.packed_quantity );
           -- Reduce the packed qty from total qty and increment label counter
           v_rem_qty   := v_rem_qty - rec.packed_quantity ;
           v_label_num := v_label_num + 1;
         END LOOP;
    END LOOP;
    -- Put the last lot remaining qty into last carton
    IF v_rem_qty > 0 THEN
    INSERT INTO sales_order( s_no, label, order_quantity)
    VALUES (v_s_no, 'LABEL' || v_label_num, v_rem_qty );
    END IF;
    COMMIT;
    END;
    S_NO    LABEL                                ORDER_QUANTITY
      1          LABEL1                                    400
      1          LABEL2                                    400
      2          LABEL3                                    400
      3          LABEL4                                    400
      3          LABEL5                                    400
      4          LABEL6                                    400
      4          LABEL7                                    400
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Update statement conditioned on two columns but for certain values only

    Hi this is my my sample data:
    with Table_1       
    as
          select '20:00' incident_time, 'WEDNESDAY' Day, 'N' Weekend,  '' Weekend_Alt   from dual
          union all
          select '18:00' incident_time, 'SATURDAY' Day, 'Y' Weekend,  '' Weekend_Alt from dual
          union all
          select '19:00' incident_time, 'FRIDAY' Day, 'N' Weekend, '' Weekend_Alt from dual
          union all
          select '11:00' incident_time, 'FRIDAY' Day, 'N' Weekend, '' Weekend_Alt from dual
    select *
      from Table_1I want to perform an update as seen below
    Update Table_1 tt
    SET Weekend_Alt = (CASE WHEN TO_CHAR(tt.day,'fmDAY') IN ('FRIDAY AND TIME >= 19:00','SATURDAY','SUNDAY') THEN 'Y' ELSE 'N' END)
    I realize the syntax is wrong but just want to give you an idea of what I want to achieve.Final Result should look something like this:
    with Table_1       
    as
          select '20:00' incident_time, 'WEDNESDAY' Day, 'N' Weekend,  'N' Weekend_Alt   from dual
          union all
          select '18:00' incident_time, 'SATURDAY' Day, 'Y' Weekend,  'Y' Weekend_Alt from dual
          union all
          select '19:00' incident_time, 'FRIDAY' Day, 'N' Weekend, 'Y' Weekend_Alt from dual
          union all
          select '11:00' incident_time, 'FRIDAY' Day, 'N' Weekend, 'N' Weekend_Alt from dual
    select *
      from Table_1Thanks in advance!!!
    Banner:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    with Table_1
    as
          select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') incident_date    from dual
          union all
          select to_date('23-MAR-2010 12:12','DD-MON-YYYY HH24:MI') incident_date from dual
          union all
          select to_date('25-JUL-2010 23:30','DD-MON-YYYY HH24:MI') incident_datet from dual
          union all
          select to_date('09-JAN-2010 08:30','DD-MON-YYYY HH24:MI') incident_date from dual
          union all
          select to_date('08-JAN-2010 08:30','DD-MON-YYYY HH24:MI') incident_date from dual
          union all
          select to_date('08-JAN-2010 20:30','DD-MON-YYYY HH24:MI') incident_date from dual
          union all
          select to_date('26-JUL-2010 00:00','DD-MON-YYYY HH24:MI') incident_datet from dual
    select incident_date, to_char(incident_date,'Day'),
        case
            when incident_date between trunc(incident_date,'IW') + 4 + 19/24
                                   and trunc(incident_date,'IW') + 7
            then 'Y' else 'N'
        end
    from Table_1 t;So your update would be
    update table_1 tt
    set weekend_alt =
        case
            when incident_date between trunc(incident_date,'IW') + 4 + 19/24
                                   and trunc(incident_date,'IW') + 7
            then 'Y' else 'N'
        end;But it does lead me to question whether it is a good idea to store this derived data
    Edited by: 3360 on Nov 8, 2011 10:14 AM

  • Aggregate Query Optimization (with indexes) for trivial queries

    Table myTable, which is quite large, has an index on the month column.
    "select max(month) from myTable" uses this index and returns quickly.
    "select max(month) from myTable where 1 = 1" does not use this index, falls through to a full table scan, and takes a very long time.
    Can this possibly be a genuine omission in the query optimizer, or is there some setting or another to convince it to perform the latter query more sanely?

    Oracle 11.2.0.1
    SQL> select table_name, num_rows from dba_tables where table_name = 'DWH_ADDRESS_MASTER';
    TABLE_NAME                                 NUM_ROWS
    DWH_ADDRESS_MASTER                        295729948
    SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER;
    | Id  | Operation                  | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT           |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE            |                        |     1 |     8 |            |          |
    |   2 |   INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
    SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER where 1 = 1;
    | Id  | Operation                   | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE             |                        |     1 |     8 |            |          |
    |   2 |   FIRST ROW                 |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------

  • Pulse train generation fails with certain values for "number of samples"

    I'm generating a retriggerable analog output signal, and so I'm using a counter as the sample clock (see: Retriggerable AI Using Retriggerable Counter). I am finding that, above a certain number of samples, and only for certain values of the number of samples, the counter task gives me error -200305, "Desired finite pulse train generation is not possibe." The error crops up only when actually starting the task.
    The analog signal that I'm trying to generate will be about 800 kHz, so my counter is set to run at the same frequency. I find that the counter task works fine if the number of samples to generate is anywhere between zero and 671,088 samples. Setting the number of samples to 671,089 gives the error above, as does 671,090 samples and so on. However, using 671,096, the counter task works fine. After that, the counter seems to output fine only if the number of samples is divisible by 8.
    The only thing I can think of is that (617088 samples) / (800000 Hz) = 0.839 s. At the internal clock rate of 20 MHz, 0.839 s is 2^24 samples, and it is a 24-bit counter on this hardware. So if it's this internal counter rolling over, that's fine and I can work around that. But if that's the case, what I don't understand is why increasing the number of samples in increments of 8 samples still works.
    The hardware is a PXI-6733 board, running with LabView 7.1.1 and NI-DAQmx 8.1.

    Hmmm,  multiples of 50 & 100?  Now I'm puzzled again.
    Here's how to make sense of the 100 kHz timebase idea though, even if it turns out not to be the right explanation.  For a retriggerable finite pulse train, you actually use a pair of counters.  If you were to program it manually, you could set your output counter to generate a continuous pulsetrain at 800 kHz using the internal 20 MHz timebase.  This output counter would also be configured to use the other counter's output as a digital level-based pause trigger.  So the 800 kHz pulsetrain is only output while the other counter's output is, say, high.
    The other counter is configured for retriggerable pulse generation.  The pulse duration or high time should be set for (# pulses) / (800e3 pulses/sec).  This other counter can be configured to use the 100 kHz timebase, so its high time would then have to be an integer multiple of 10 usec.
    So let's see...  An 800 kHz pulsetrain is possible with a 20 MHz timebase (exactly 25 cycles).  A 700 kHz (28 + 4/7 cycles) or 900 kHz (22 + 2/9 cycles) is not.  So when you request those other frequencies, you actually get a near approximation.  I dunno if DAQmx can be queried for the actual value correctly or not -- I recall an early version that reported back whatever freq you had asked for rather than what it actually used.  Queries based on ticks (rather than time or freq) did return what was actually used, as I recall.
    Let's suppose a request for 700 kHz gets truncated to 28 cycles of the 20 MHz timebase making a 1.4 usec period.  Then 50 of those periods becomes 70 usec, which is evenly divisible by the 100 kHz timebase.  Bingo!  (Note: 70 is the least common multiple of 10 and 1.4)
    Now suppose the request for 900 kHz turns into 22 cycles of the 20 MHz timebase, or a 1.1 usec period.  Now it takes 100 of those periods to get to 110 usec, which is also evenly divisible by the 100 kHz timebase.  Bingo again!  (Note: 110 is the lcm of 10 and 1.1).
    Did you follow the method here?  It should help you figure out expected results for various output freqs and #'s of samples.
    -Kevin P.

  • Execute a query for each value returned by subquery

    Hy, I have a query and a subquery(both of them are selects) and I want the outer query to be executed for each value returned by the subquery but the outer query has to return only one result.
    For example, the following query is right for what I want?:
    the following query finds out which authors live in the same city by looking at the postal code:
    select au_fname, au_lname, city
    from authors
    where city = all
    (select city
    from authors
    where postalcode like "946%")
    I undertand the sentence "select au_fname, au_lname, city from authors where city=" will be executed for each value returned by "select city from authors where postalcode like "946%"". Is this right?
    Thanks

    Hi,
    user13162080 wrote:
    Hy, I have a query and a subquery(both of them are selects) and I want the outer query to be executed for each value returned by the subquery but the outer query has to return only one result. Sorry, I don't understand what you want. What if several rows in the table meet all the criteria? Do you only want some kind of summary of all of them?
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.
    For example, the following query is right for what I want?:
    the following query finds out which authors live in the same city by looking at the postal code:
    select au_fname, au_lname, city
    from authors
    where city = all
    (select city
    from authors
    where postalcode like "946%")As I said earlier, I don't know what you want , but whatever it is, the query above is probably not the right way to get it.
    Perhaps you meant "IN" instead of "= ALL", like this:
    SELECT  au_fname, au_lname, city
    FROM      authors
    WHERE      city     IN          -- ***NOT***  = all
              (   SELECT  city
                  FROM    authors
                  WHERE   postalcode LIKE "946%"
    I undertand the sentence "select au_fname, au_lname, city from authors where city=" will be executed for each value returned by "select city from authors where postalcode like "946%"". Is this right?No; the main query will be executed once, and the sub-query will be executed once. The rows in the main query will be compared to the results of the sub-query, to see if they will be included in the result set or not. This goes both for the original query you posted, and the modified version I posted.
    InoL wrote:
    Maybe I don't understand exactly what you want, or you gave a bad example. But your example is simply:
    select au_fname, au_lname, city
    from authors
    where postalcode like '946%'
    No; consider this data:
    INSERT INTO authors (au_lname, city, postalcode) VALUES ('Virgil',     'Oakland',     '94601');
    INSERT INTO authors (au_lname, city, postalcode) VALUES ('Steinbeck',     'Oakland',     NULL);
    INSERT INTO authors (au_lname, city, postalcode) VALUES ('Grass',     'Emeryville',     '94608');What OP posted would return no rows, because nobody is in both 'Oakland' and 'Emeryville'.
    What you posted would return 'Virgil' and 'Grass'.
    What I posted would reutn all 3 rows, including Steinbeck, whose city is known to be related to a '946%' postalcode, even though his own postalcode is missing.
    Edited by: Frank Kulash on Feb 9, 2011 1:06 PM

Maybe you are looking for