Search for records in a table on the basis of a function

Hi,
How is it possible to use a function as search criteria in a sql query ?
For example, I have the following query :
select a.job_name JOB_NAME, substr(a.job_name,instr(a.job_name,'.',-1)+1) as AUTNAME
FROM autosys.job a
where a.job_name like %PRD%' and a.command like '%dsjob%'
and a.command not like 'substr(a.job_name,instr(a.job_name,'.',-1)+1)';
This is now working because of the use of function "substr" on the right side of the query.
How can I write the query so as to find the same result as using this function ?
Can someone help me out on this ?
Thanks

Among other things, you have the quotes in the wrong place in the NOT LIKE predicate. As posted, you are searching for records where command does not contain the literal string substr(a.job_name,instr(a.job_name,'.',-1)+1). I don't think that is really what you are after. You need to concatenate the operators to the results of the SUBSTR function. Something more like:
SELECT a.job_name job_name,
       SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1) as autname
FROM autosys.job a
WHERE a.job_name LIKE 'HP.TM.%PRD.%' and
      a.command LIKE '%dsjob.sh%' and
      a.command NOT LIKE '%'||SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1)||'%'; John

Similar Messages

  • Search for records in the event viewer after the last run (not the entire event log), remove duplicate - Output Logon type for a specific OU users

    Hi,
    The following code works perfectly for me and give me a list of users for a specific OU and their respective logon types :-
    $logFile = 'c:\test\test.txt'
    $_myOU = "OU=ABC,dc=contosso,DC=com"
    # LogonType as per technet
    $_logontype = @{
        2 = "Interactive" 
        3 = "Network"
        4 = "Batch"
        5 = "Service"
        7 = "Unlock"
        8 = "NetworkCleartext"
        9 = "NewCredentials"
        10 = "RemoteInteractive"
        11 = "CachedInteractive"
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0""
    or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>" -ComputerName
    "XYZ" | ForEach-Object {
        #TargetUserSid
        $_cur_OU = ([ADSI]"LDAP://<SID=$(($_.Properties[4]).Value.Value)>").distinguishedName
        If ( $_cur_OU -like "*$_myOU" ) {
            $_cur_OU
            #LogonType
            $_logontype[ [int] $_.Properties[8].Value ]
    #Time-created
    $_.TimeCreated
        $_.Properties[18].Value
    } >> $logFile
    I am able to pipe the results to a file however, I would like to convert it to CSV/HTML When i try "convertto-HTML"
    function it converts certain values . Also,
    a) I would like to remove duplicate entries when the script runs only for that execution. 
    b) When the script is run, we may be able to search for records after the last run and not search in the same
    records that we have looked into before.
    PLEASE HELP ! 

    If you just want to look for the new events since the last run, I suggest to record the EventRecordID of the last event you parsed and use it as a reference in your filter. For example:
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4624 and
    EventRecordID>46452302)]]</Select>
        <Suppress Path="Security">*[EventData[Data[@Name="SubjectLogonId"]="0x0" or Data[@Name="TargetDomainName"]="NT AUTHORITY" or Data[@Name="TargetDomainName"]="Window Manager"]]</Suppress>
      </Query>
    </QueryList>
    That's this logic that the Server Manager of Windows Serve 2012 is using to save time, CPU and bandwidth. The problem is how to get that number and provide it to your next run. You can store in a file and read it at the beginning. If not found, you
    can go through the all event list.
    Let's say you store it in a simple text file, ref.txt
    1234
    At the beginning just read it.
    Try {
    $_intMyRef = [int] (Get-Content .\ref.txt)
    Catch {
    Write-Host "The reference EventRecordID cannot be found." -ForegroundColor Red
    $_intMyRef = 0
    This is very lazy check. You can do a proper parsing etc... That's a quick dirty way. If I can read
    it and parse it as an integer, I use it. Else, I just set it to 0 meaning I'll collect all info.
    Then include it in your filter. You Get-WinEvent becomes:
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624 and EventRecordID&gt;$_intMyRef)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0"" or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>"
    At the end of your script, store the last value you got into your ref.txt file. So you can for example get that info in the loop. Like:
    $Result += $LogonRecord
    $_intLastId = $Event.RecordId
    And at the end:
    Write-Output $_intLastId | Out-File .\ref.txt
    Then next time you run it, it is just scanning the delta. Note that I prefer this versus the date filter in case of the machine wasn't active for long or in case of time sync issue which can sometimes mess up with the date based filters.
    If you want to go for a date filtering, do it at the Get-WinEvent level, not in the Where-Object. If the query is local, it doesn't change much. But in remote system, it does the filter on the remote side therefore you're saving time and resources on your
    side. So for example for the last 30 days, and if you want to use the XMLFilter parameter, you can use:
    <QueryList>
    <Query Id="0" Path="Security">
    <Select Path="Security">*[System[TimeCreated[timediff(@SystemTime) &lt;= 2592000000]]]</Select>
    </Query>
    </QueryList>
    Then you can combine it, etc...
    PS, I used the confusing underscores because I like it ;)
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Search for records by Remote Key or Remote System in Data Manager

    Hi all,
    We have a requirement to search for records by Remote key and/or Remote System at the main table level. Is it possible to do this using the Data Manager? If so, how?
    Thanks in advance!
    Lavanya.

    Hi,
    I crosschecked with MDM 5.5 and Don't think it is possible through Data Manager. How ever using APIs you can search records using remote key/ remote system.
    Regards,
    Shiv

  • Help-ColdFusion - enabling a user to search for records in a database by entering a startand end date - (CREATEODBCDATE)

    I want to enable a user to enter a start and end date to
    define the period they want to search for records of members who
    joined on certain dates. Funny thing is...I've got it to work half
    of the time. For e.g. I have 4 records between 26/10/2005 and
    1/08/2006. When I enter 01/01/2005 as startDate and 31/08/2006 as
    endDate, I get the 4 records. However, if I alter the endDate to
    01/09/2006 I get every record in the database!!!??? Why's this? I
    can't get my head around it!
    Here's my code:
    First the code for the form the user input the search
    criteria on:
    <html>
    <body>
    <FORM action="memberJDateSearch.cfm" method="post">
    <p>Start Date: <input type="text"
    name="startDate">
    <br>End Date: <input type="text" name="endDate">
    <input type="reset" value="Clear">
    <input type="submit" value="Submit">
    </FORM>
    </body>
    </html>
    Simple enough. Now the code for the process and display page:
    <html>
    <body>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>
    <table border=1 bgcolor="beige" cellpadding="3"
    cellspacing="0">
    <tr>
    <th>Member ID</th>
    <th>Name</th>
    <th>Sex</th>
    <th>Date of Birth</th>
    <th>Address</th>
    <th>Email</th>
    <th>Date Joined</th>
    </tr>
    <CFOUTPUT Query="memberJDateSearch">
    <tr>
    <td><center>#memberID#<center></td>
    <td width="15%">#forename# #initial#
    #surname#</td>
    <td>#sex#</td>
    <td width="10%">#disp('#dob#')#</td>
    <td>#address#, #town#, #county#, #postCode#</td>
    <td>#email#</td>
    <td width="10%">#disp('#joinDate#')#</td>
    </tr>
    </CFOUTPUT>
    </table>
    <hr><p>End of members list.</p>
    </body>
    </html>
    any ideas? please help me.

    Try formatting your dates first (before the CreateODBCDate
    call). I just tried this on my test page and it worked properly. I
    removed the DateFormat calls, keeping the dates in your format and
    it didn't work. See if something like the following will help:
    <cfset startDate =
    DateFormat("31/01/2006","dd/mm/yyyy")/>
    <cfset endDate =
    DateFormat("01/09/2007","dd/mm/yyyy")/>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>

  • How we can restrict record in CTL file on the basis of other table ?

    Hello all,
    How we can restrict record in CTL file on the basis of other table ?
    Eg.
    I have following control file to load the records in the table through the sql loader.
    LOAD DATA
    INTO TABLE THIST APPEND
    FIELDS TERMINATED BY "|" TRAILING NULLCOLS
    LNUM POSITION(1) Char "substr(:LOAN_NUM, 4, 13)",
    TSRNUM Char "rtrim:TRAN_SR_NUM)" ,
    TPROCDT Char "to_char(to_date rtrim:TRAN_PROC_DT), 'MMDDYYYY'), 'YYYYMMDD')"      
    I have another table c all TFILE in which I have LNUM. I want to import only those records from input text file using the control file and sql loader in which LNUM is exist in the TFILE.
    So how i can restrict it in the Control File.
    Thanks
    Kamlesh Gujarathi
    [email protected]

    Hello Satyaki De.
    Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
    Thanks
    Kamlesh Gujarathi
    [email protected]

  • Search for "A word or phrase in the file" in .trc files gives no result

    Hi
    When i Search through Explorer using search for "A word or phrase in the file" in .trc files I get no result.
    Probably because these files are of type "Microsoft Network Monitor Document".
    But I can open them using Notepad, so why can't I search for a word in these files?
    I there another way to search?
    Normally I ofcourse use Visual Admin. but there are a lot of trace files so it would be nice to do this kind of search
    br Peter

    Hi Peter,
    This is a known problem, see http://support.microsoft.com/kb/309173
    An alternative is to use other tools which search even faster than the slow MS search does.
    Hope it helps
    Detlev

  • I phone is keeping searching for network even if i take the Sim out and i did reset but no use also it cant make software update - and the modem firmware has no number also

    i phone is keeping searching for network even if i take the Sim out and i did reset but no use also it cant make software update - and the modem firmware has no number also

    Either your phone is broken, or it was jailbroken. You can try a DFU restore.

  • I can't search for apps by pulling down on the home screen. Today view in Notification Center is turned off, but today view comes up when I pull down, not Spotlight Search.

    I can't search for apps by pulling down on the home screen. Today view in Notification Center is turned off, but today view comes up when I pull down, not Spotlight Search.

    Pull down starting in the middle of the home page, not at the top.

  • I have iPhone 4 but its very slow when i wright message or search for name finally when i use the keyboard its coming very slow

    i have iPhone 4 but its very slow when i wright message or search for name finally when i use the keyboard its coming very slow

    Try Settings > General > Reset > Reset All Settings.

  • When I search for sent mail, I only see the sender of the mail (me). I want to see the receiver. How can I change that?

    When I search for sent mail, I only see the sender of the mail (me). I want to see the receiver. How can I change that?

    What kind of mail? gmail?
    Maybe this:
    Sent folder only show senders name in mail apps

  • To upload a data into SAP Table with the help of RFC function in BODS

    Hi,
    Please provide me step-by-step solution to upload data into any SAP table with the help of RFC function in Data Services.
    I have created RFC function that upload data into SAP table. RFC Function contains one table that has same structure as my database table.
    In the data services how can i filled the table of RFC function, i am using this function in query transform of data services but it gives me error.
    I am also follow link http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsDataServicesTipsand+Tricks
    but it did not help me.
    Thanks,
    Abhishek

    Hi Abhishek,
    Did you import the function module in the SAP datastore first? When you open the SAP datastore, the function should be listed in the 'functions' section. If not, import it. Make sure your function is remote executable.
    Once the function is there, you can use it in a transformation. In 'Schema Out' right-click on 'Query' (top level) and choose 'New Function Call'. You can then select a datastore and a function in the datastore. The wizard will show you which output parameters are available. I believe you have to add at least one and can select as many as you like.
    After confirming your selection the function and the output parameters appear in Schema Out. You can then right-click on the function and choose 'Modify function call'. A popup will appear where you can specify the input parameters.
    I hope this helps.
    Jan.

  • Can I use a deactivated verizon G'zOne Ravine phone for its nonphone properties such as the alarm and other functions? Do I have to do anything special?

    Can I use a deactivated verizon G'zOne Ravine phone for its nonphone properties such as the alarm and other functions?
    Do I have to do anything special?

    Just charge it

  • Search a record from Multiple Tables

    Is there a pl/sql command or way that searches for a specific record (text, number) in multiple tables? Given that you don't know the column you are searching from.

    There is no built in method, but you can roll your own.
    I posted one way Re: How to find out a tablename
    HTH
    John

  • How to delete duplicate records in all tables of the database

    I would like to be able to delete all duplicate records in all the tables of the database. Many of the tables have LONG columns.
    Thanks.

    Hello
    To delete duplicates from an individual table you can use a construct like:
    DELETE FROM
        table_a del_tab
    WHERE
        del_tab.ROWID <> (SELECT
                                MAX(dups_tab.ROWID)
                          FROM
                                table_a dups_tab
                          WHERE
                                dups_tab.col1 = del_tab.col1
                          AND
                                dups_tab.col2 = del_tab.col2
                          )You can then apply this to any table you want. The only differences will be the columns that you join on in the sub query. If you want to look for duplicated data in the long columns themselves, I'm pretty sure you're going to need to do some PL/SQL coding or maybe convert them to blobs or something.
    HTH
    David

  • Dynamic call for records in a table

    hI,
    Im having a ztable, the structure is as follows:
    tabold fldold tabnew fldnew
    The records in this table is are:
    1.yvbap  posnr xvbap posnr
    2.yvbak  auart xvbak auart
    3.yvbak  augru xvbak augru.
    Now, i have to use this table dynamically to check each and every record in the program:mv45afzz.
    So, my problem is that, i have to dynamically pass these records which contains table name and its field name.
    i can write as: xvbap-posnr = yvbap-posnr for all the three records (the values will come from sales order tranx, report: mv45afzz)
    but in future if the records are added then i have to again change the code, so this shouldn't happen.
    It should dynamically call all the records in this table and check the condition.
    Thanx
    Rohith

    Hello Rohith
    What is your question???
    You described a few ingredients of your scenario (not all of them) and do not really explain your requirements.
    Given the descriptions of the Z-table fields I assume you need to check whether OLD values are equal to NEW values.
    If this assumption is correct then the solution is quite simple (except for XVBAP / YVBAP: Does this mean single entries or looping over all entries?)
    DATA:
      lt_ztable     TYPE STANDARD TABLE OF zstructure,
      ls_ztable     TYPE zstructure.
      FIELD-SYMBOLS:
        <lt_tab>     TYPE table,
        <ls_struct_old>    TYPE any,
        <ls_struct_new>   TYPE any,
        <ld_old>    TYPE any,
       <ld_new>    TYPE any.
    " Read entries from z-table
      SELECT * FROM ztable INTO table lt_ztable.
      LOOP AT lt_ztable INTO ls_ztable.
        ASSIGN (ls_ztable-tabold) TO <ls_struct_old>.
        ASSIGN (ls_ztable-tabnew) TO <ls_struct_new>.
        ASSIGN COMPONENT (ls_ztable-fldold) OF STRUCTURE <ls_struct_old> TO <ld_old>.
        ASSIGN COMPONENT (ls_ztable-fldnew) OF STRUCTURE <ls_struct_new> TO <ld_new>.
        IF ( <ld_old> = <ld_new> ).
          " do something...
        ENDIF.
      ENDLOOP.
    For the sake of simplicity I did not add the required statements for checking successful ASSIGN's.
    Regards
      Uwe

Maybe you are looking for