Using LIKE in a conditional statement

I'm trying to color code a column if another column is LIKE "1-%" but there isn't a like option. How is this accomplished?

there is a workaround for this.
say you have 2 column
A---------------------B
1-A----------------ABC
1-C----------------bcd
2-E----------------xyz
create a dummy column which will have only first two characters of column A for ex
A---------------------B--------------C
1-A----------------ABC-----------1-
1-C----------------bcd------------1-
2-E----------------xyz-------------2-
now implement the conditional formatting using this dummy column and hide this in your report. you wil get wat you need.

Similar Messages

  • Using Like Clause in Prepared Statement

    Hi,
    I want to use LIKE clause in prepared statement. This is not returning any record.
    This is the query. Please help me in this.
    SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE ? AND EMPLYR_GRP = ?
    This is giving Oracle SQL Error.
    SELECT EMPLYR_GRP,EMPLYR_GRP_NAME FROM EMPLOYER_GROUP WHERE EMPLYR_GRP_NAME LIKE %?% AND EMPLYR_GRP = ?

    The first variant should work just fine as long as you use stmt.setString(1, '%' + pattern + '%') to set the parameter. The second query is just plain wrong.
    Alin.

  • Problem in using LIKE addition in SELECT statement

    HI Experts,
    Have a small query for you :
    While selecting from Database I want to fetch all records which have the field name like "HR_".
    I wrote following select query :
    l_tsobj TYPE tst01-dname VALUE 'HR_%',
    SELECT * INTO TABLE ltst01 FROM tst01 WHERE dname LIKE l_tsobj.
    During debugging it shows me all records like HR_ & all records like HRL.
    Not sure why it is fetching records like HRL from database .
    In table tst01 total number of records having HR_ = 1231
    but the above query select in total 1231 + 2000( records having HRL ..... pattern also ).
    I want to restrict data selection at database level only & not at internal table level . Please suggest.
    Thanks,
    Abhinav.

    Hi,
    you have to use ESCAPE statement.
    DATA:     
      l_tsobj TYPE tst01-dname VALUE 'HR/_%'.
    SELECT *
      INTO TABLE ltst01
      FROM tst01
      WHERE dname LIKE l_tsobj ESCAPE '/'.
    Regards Marcel

  • Using like Operator in Prepeared Statement

    PreparedStatement s2=dbcon.prepareStatement("Select phone,dnc_message from gsw_donotcall_list_tab where phone=? or dnc_message like ?");
    s2.setString(1,number);
    s2.setString(2,"%"+smessage+"%");
    ResultSet result=s2.executeQuery();
    rowfound=result.next();
    (Using SQL Server, I am Accepting Parameters from the User by a HTML Page, the user may enter full or partial message, but need to display all the records Satisfying the Criterai
    I tried this but dosnt work for DNC_message Field
    Can anyone help me i am in great need of this

    The problem with that is it produces the following query:
    UPDATE COFFEES SET SALES = 75 WHERE COF_NAME LIKE 'Colombian'Which they also show as a normal Statement (rather than a PreparedStatement) and they claim it will work. Well, in most databases it will work, only if COF_NAME contains exactly "Columbian", just like an "=". If you also want it to return "Columbian Prime" or "Wild Columbian" or whatever, your out of luck without the wildcards, and PreparedStatement does not insert them. If you don't belive it works this way, then test it yourself:
    create table TEST_IT (
      Bogus VARCHAR(20) Primary Key
    insert into TEST_IT values ('AAA');
    insert into TEST_IT values ('ABA');
    insert into TEST_IT values ('ABC');
    SELECT * From Test_It Where Bogus LIKE 'A';
    SELECT * From Test_It Where Bogus LIKE 'AAA';
    SELECT * From Test_It Where Bogus LIKE '%A%';And inspect what the three select statements return.
    Edit: I must apologise, and ask the OP what Driver he is using. This may be somewhat Driver dependent. Using the MySQL 3.1.6 Driver and MySQL 4.1.9, it did not escape the "%" symbols and so
    setString(1, "%A%");returned 3 rows. So the reason yours is not, may be dependent on the Driver and/or vendor. But in any case, the example shown in the tutorial (the Statement version) would still not work (at least in most DBs).

  • Trying to retrieve content from a text field & use it in a conditional statement

    Hi Everyone,
    I have a form with a text field and a button. The  text field is called "orderNo", and the button is called "genOrder".
    Initially  the text field is empty, and clicking on the button fills the text  field with an appropriate order number.
    I need to check the text  field for data (content) before writing the order number to it, this  way if an order number is already present in the text field it will not  be over written.
    My intention is to use an if / else structure to  perform the testing, however I don't know how to retrieve the content  of the text field (if content is present!).
    If anybody can  suggest how I can go about retrieving the content of the text field and  then use it in an if / else statement it will be greatly appreciated.
    Kind  Regards,
    Davo

    Hi try67,
    Thanks for your assistance. I have posted in this http://www.acrobatusers.com/forums/aucbb/viewtopic.php?pid=70276#p70276 forum asking for further assistance if your able to help more.
    Once again thanks for your time.
    Cheers
    Davo

  • Using Type Input in Conditional Statement

    If the user types "ball" in the input textfield, instance
    name: name_txt, I want to move to the next frame and stop. Can
    somebody tell me, what I am doing wrong here? Thank you!
    submit_btn.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
    if(name_txt.text == "ball")
    gotoAndStop(2);
    --Jamesabth, thnx for your last reply!

    for some reason, it is not waiting for me to type in "ball"
    into the input text field, instance name: name_txt, and just going
    to frame 2.
    submit_btn.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
    if(name_txt.text.toLowerCase() == "ball")
    nextFrame();
    thnx for helping me.

  • How to write statement using LIKE statement in jsp

    hi
    I am new to jsp. I would like to retrive the data from database using like command. But my query dosen't work well. Can you help me in this topic.
    String name = request.getParameter("username");
    int i = st.executeQuery("select * from emp where empname LIKE '%name%'");
    Plase help me..
    Thanking you
    sure...

    Using LIKE :
    ==========
    The following SQL statement will return persons with first names that start with an 'O':
    SELECT * FROM Persons
    WHERE FirstName LIKE 'O%'
    The following SQL statement will return persons with first names that contain the pattern 'la':
    SELECT * FROM Persons
    WHERE FirstName LIKE '%la%'
    Hope this might have helped you
    REGARDS,
    RaHuL

  • OMP_SET_NUM_THREADS in a conditional statement?

    I am having problems using OMP_SET_NUM_THREADS in a conditional statement. For example a code like following will make the program to hang indefinitely after starting to execute a parallel DO loop:
    if(mybool.eq.0) then
    call OMP_SET_NUM_THREADS(iprocessors)
    else
    call OMP_SET_NUM_THREADS(1)
    endif
    Is there a problem using this function in conditional statements?
    I am using Forte Studio 7 under Solaris 8 and 10 (I know that it is old but for the moment this is what I have to use...).
    Thanks,
    Rak

    This is probably a bug in Forte 7.
    Can you isolate the problem in a small test case and post the code here. We'll try it on the latest compiler and see if it works or not.
    You know you can download Sun Studio 12 and run it on Solaris 10. (SS 12 is not supported on Solaris 8)

  • Using CONSTANT in Condition Statement

    Hi
    What I am trying to do is put CONSTANT into IN Condition Statement.
    When I use Bind variables just like :bind, It works properly
    But What if I use as a CONTANT, It doesn't work.
    In my opinion, parenthesis is not work well.
    Please help me out
    thanks in advance and below is PL/SQL CODE
    PROCEDURE PROC_MAIN
    iUserID          IN     VARCHAR2,
    iJobID IN VARCHAR2
    ) AS
    C_AGENT CONSTANT VARCHAR(20) := '10,11';
    C_staff CONSTANT VARCHAR(20) := '40';
    C_newStaff CONSTANT VARCHAR(20) := '50';
    C_ETC CONSTANT VARCHAR(20) := '20,30';
    BEGIN
    vJobId :=
    CASE iJobID
    WHEN '41' THEN C_AGENT
    WHEN '42' THEN C_staff
    WHEN '43' THEN C_newStaff
    WHEN '40' THEN C_ETC
    END;
    insert into tbl_monthly
    (emp_no, salary)
    select emp_no, salary from tbl_emp
    where Staff_cat in vJobId ;
    end;
    Message was edited by:
    allbory

    Hi,
    Please check the changes:
    Note: table_name is changed to test.
    CREATE OR REPLACE PROCEDURE PROC_MAIN
    iUserID IN VARCHAR2,
    iJobID IN VARCHAR2
    ) AS
    C_AGENT CONSTANT VARCHAR(20) := '10,11';
    C_staff CONSTANT VARCHAR(20) := '40';
    C_newStaff CONSTANT VARCHAR(20) := '50';
    C_ETC CONSTANT VARCHAR(20) := '20,30';
    vJobId          VARCHAR2(20);BEGIN
    vJobId :=
    CASE iJobID
    WHEN '41' THEN C_AGENT
    WHEN '42' THEN C_staff
    WHEN '43' THEN C_newStaff
    WHEN '40' THEN C_ETC
    END;
    EXECUTE IMMEDIATE 'INSERT INTO tbl_monthly(empno, salary) SELECT empno, sal FROM scott.emp WHERE deptno IN ('||vJobId||')' ;
    END;

  • Using conditional statements stored inside a variable

    I'm trying to store the body of different emails inside of my
    database to use in email sent with cfmail. The content of the
    emails has conditional statements using cfif and other variables
    based on a query running. If I set the content as a variable and
    then place that inside of the cfmail tag it does not process the
    cold fusion code. Is there a way that I can process this code so
    that the final output is what is placed within the cfmail tag or is
    it not possible to do what I'm trying to accomplish? Thanks in
    advance for any ideas.

    Here is a sample taken from the text file. The output created
    by the cfsavecontent tag is identical to the text file.
    Dear <cfif IsDefined(GetData.strFirstName) AND
    GetData.strFirstName IS NOT
    "">#GetData.strFirstName#<cfelse>Member</cfif>,
    Thank you for joining xxxxxxxxx. We're glad to
    have you as a member and appreciate your support. Your
    membership
    application has been processed and your member packet will
    arrive soon.
    Your new membership number is #GetData.strCustomerID#. This
    number is useful
    when buying product from our online store, renewing your
    membership or
    contacting us with questions or comments.
    <cfif GetData.ExpirationDate IS "9999-12-1">We are
    especially grateful for your commitment to xxxxxxxx
    through your Life Membership.<cfelse>Your membership is
    current through #DateFormat(GetData.ExpirationDate, "MMMM
    YYYY")#.</cfif>

  • How to use Conditional statements in SQL Loader control file

    Hi,
    I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
    My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
    How to achieve this with the conditional statement or using any Oracle function?
    Any help or suggestion is greatly appreciated.
    Thanks in advance.

    Hi there,
    I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
    )

  • HT1918 hi, i used to live in the states, since 7 years ago came back to my country Ecuador, I wuold like to change my payment info but since I have $0.08 cents in my account I cannot proceed with the changes..please help.

    hi there, i need help with my itunes acrcount, i used to live in the States but I cambe back yo my country seven years ago (ecuador).  Now i would like to change my account info but I can't, because I have $0.08 cents and i need to clear that balance to chance my info payment...but there's nothing i can but for $0.08 cents and obviously I don't have a credit card with a Unite States address please help meeeee!!!

    Try contacting iTunes support and see if they can remove the balance from your account : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Conditional statement in html

    This is actually not a JSP question but an HTML question. I could'nt find any good html forum sites out there, and since I received excellent replies in my previous post, I am hoping that those of you who know JSP also know html. Heres my question, is there any conditional statement in html (I don't want to use scripts)? The only conditional statement I found was the logic:equal (not equal) statement. And it seems to only work for forms. I am using JSP in conjunction with html so I used an inner html variable declaration in my JSP function. This variable will be used by my html code. And I would like to check the value of that variable in html.
    Heres my JSP function containing the inner html declaration:
    function showItemEdit(field)
    var elements = editWindowDiv.document.all;
    elements("editWindowField").value = "";
    fieldhtml.innerHTML = field;
    var retVal = null;
    retVal = window.showModalDialog("javascript:document.write(window.dialogArguments.innerHTML);editWindowInit();",editWindowDiv,
    "dialogWidth:335px;dialogHeight:185px;scroll:no;status:no;unadorned:no");
    if (retVal == "OK")
    alert("OK");
    else
    alert("Cancel");
    The inner html variable, fieldhtml.innerHTML, is the value I would like to check in my html code.
    This is what I woul like to accomplish in my html code:
    if fieldhtml == register then
    <tr>
    <td class="bodymd">  <bean:message key="label.register"/>:</td>
    <td><input type="text" name="editWindowField" value="" maxlength="5"></td>
    </tr>
    else
    <tr>
    <td class="bodymd">  <bean:message key="label.shift_no"/>:</td>
    <td><input type="text" name="editWindowField" value="" maxlength="3"></td>
    </tr>
    end if
    I am not sure how to accomplish if-else statements in html. I would appreciate any help. Thanks!

    You are mixing things a bit. There is no JSP in your example. You cannot do conditional statements in HTML. However, you can use JavaScript to output HTML:
    if(someCondition){
    document.write("<yourHTMLTags>whatever</yourHTMLTags>");
    else{
    document.write("<yourHTMLTags>something else</yourHTMLTags>");
    }

  • How to use i for if condition in a for i in loop?

    Hi friends,
    I have a question on how to use i for IF condition in a loop, in order to get an efficient programming and results. Here is outlined SQL:
    cursor is
    select c1,c2,c3 from table1; -- 100 rows returned.
    open cursor
    loop
    fetch c1,c2,c3 into v1,v2,v3;
    for i in 1..3 loop
    if 'v'||i between 90 and 100 then
    v_grade := 'Excellent';
    elsif 'v'||i between 80 and 89 then
    elsif 'v'||i between 50 and 59 then
    end if;
    end loop;
    close cursor;
    This way, I don't need to use a lot of if..then for hard code v1,v2,v3,.... actually I have more v..
    But Oracle gave an error of this usage of 'if 'v'||i' or 'v'||to_char(i).
    Thanks for any advice in advance!

    user508774 wrote:
    Thanks for comments and advices. But I didn't get your inputs clearly. Are you saying I don't need to use PL/SQL to achieve this?Correct. Ronel and John showed you the basic approaches. SQL is not a mere I/O language for making read and write calls. It is a very capable, flexible and powerful language. One can solve a problem with a few lines of SQL code, that will take 100's of lines of PL/SQL or Java code.
    So do not underestimate what can be done in SQL.
    v_cmd := 'UPDATE parts_categ_counts SET w1='||v1||', w2='||v2||...||v9||' WHERE seq='||vseq||';
    EXECUTE IMMEDIATE v_cmd;This code is also wrong. Besides the fact that there is no need for dynamic SQL, this approach creates a brand new SQL statement each loop iteration.
    SQL is source code. It needs to be parsed (compiled). The end result is an executable program that is called a cursor. This cursor needs to be stored in server memory (the SQL Shared Pool in the SGA).
    The problem with your code is that it is slow and expensive - it generates lots of unique SQL statements that need CPU for parsing and server memory for storage.
    These add up to a very significant performance overhead. That is the wrong approach. The correct approach is the same one that you would use in any other programming language.
    Let's say you need to use Java to process a bunch of CSV files - exact same CSV layout used by each file. A file needs to be read, processed, and a log file created.
    Will you write a Java program that loops through the files, for each file found, write a Java program for processing that file, compile it, then execute it?
    Or would you write a Java program that takes the name of the file as input, and then process that file and writes the log file?
    The 2nd approach provides a program that can process any of those CSV files - one simply needs to pass the filename as an input parameter.
    Your code and approach use the 1st method. Not the 2nd. And that is why it is wrong.
    To create a SQL program with parameters is done by using bind variables. Instead of
    v_cmd := 'UPDATE parts_categ_counts SET w1='||v1||', w2='||v2||...||v9||' WHERE seq='||vseq||';
    The following SQL source code should be created:
    v_cmd := 'UPDATE parts_categ_counts SET w1=:v1, w2=:v2 ..., w9=:v9 WHERE seq= :vseq';
    The tokens with the colon prefix (such as :v1), are bind variables. Think of these as the parameters to the SQL cursor.
    The server parses this SQL into a cursor. You can now execute the same cursor over and over again, using different bind variables. (just like the 2nd approach above that one would use in Java)
    In PL/SQL, this is made even easier as you can code native SQL code with PL/SQL code and use PL/SQL variables in it. The PL/SQL compiler is clever enough to do the SQL parsing, variable binding, and cursor execution for you. So in PL/SQL, you would use:
    UPDATE parts_categ_counts SET w1=v1, w2=v2 ..., w9=v9 WHERE seq= vseq;
    Where v1 and the others are PL/SQL variables.
    That all said - PL/SQL is only used for data crunching, when the processing of data is too complex for the SQL language to deal with. And this is very seldom the case.
    The main reason for using PL/SQL it to provide processing flow control, conditional processing and error handling, for SQL code. As the SQL language does not have these features.

  • Java programming standard for conditional statement

    Hi,
    Is it proper Java standard to use constants first in a conditional statement? I've never seen coding in this way, even when I was in college I never saw it in any of our books.
    example:
    String x = null;
    if (null==x){
    //Do some stuff
    }

    kevjava wrote:
    yawmark wrote:
    ...hence, more work.Not if "NAME_KEY" (i.e., the literal value) changes.
    ~If some wise guy resets it to null, then you've lost all benefit of making a constant out of it to begin withIf that happens, you've got some people problems to deal with! Anyways, if it's really a constant, it'll be final, right?
    .... and I was sort-of reiterating that it was a self-named constant... you're right, of course, but I guess I'm just peaved at having to see stuff like...
    private String JAN="JAN";
    private String FEB="FEB";
    // ...and on and on...
    // later...
    if (FEB.equals(month)) {
    // do stuff
    } else {
    // do stuff
    }Have you ever actually seen code like that in production? I wonder, what are you up to that a class needs its own, private, set of months?
    My point is that the three-letter abbreviation is always going to be "FEB" (yes, i18N and language specializations aside)Why put them aside, though? They're not exactly corner cases

Maybe you are looking for

  • What is the use of Alternative Calculation Type =2 and 4

    Dear Friends In pricing procedure in gross value, Net value for Item and Net value has Alternative calucation type is 2. What is the use of it? Without using it these value line are also fetching net value then what is the work of it. Please give me

  • Pre-built website businesses how to get into dreamweaver?

    Hello, I just purchased a monthly  membership to a website that is selling "scripts". Pre-built website businesses  that I am able to download and edit as i like. I also recently dowloaded  dreamweaver and look forward to learning how to use it. I'm

  • Control Break appearance in Interactive Report

    Hi guys, I'm using a control break on 3 columns in my report, but when doing this Apex shows the columns comma-separated, like: Column A: value, Column B: value, Column C: value But I would like it to look like: Column A: value Column B: value Column

  • Need help with interpreting tablespace usage script

    Hi, I have a script to find all the used and free spaces of a datafiles. The script is as below: SELECT Substr(df.tablespace_name,1,20) "Tablespace Name", Substr(df.file_name,1,40) "File Name", Round(df.bytes/1024/1024,2) "Size (M)", Round(e.used_byt

  • Homescreen images are blurry in iOS4

    I'm liking iOS4 however one thing I noticed is that all my homescreen wallpapers look fuzzy, like they have been blown up too big (they didn't with iOS3). I know you can "squeeze" them smaller but not that much smaller. It's still fuzzy. Anyone havin