Sql Like statement

how can i get all records starting with % ?

Something that I found here (
SQL Tutorial) might
help:
The optional ESCAPE sub-clause specifies an escape character for
the pattern, allowing the pattern to use '%' and '_' (and the
escape character) for matching. The ESCAPE value must be a single
character string. In the pattern, the ESCAPE character precedes any
character to be escaped.
For example, to match a string ending with '%', use:
x LIKE '%/%' ESCAPE '/'
..or here
Using
SQL Escape Sequences
... or here
How
to escape a wildcard in an SQL order with ORACLE.
Phil

Similar Messages

  • SQL LIKE statement in JSP

    I tried to write a query in jsp page using LIKE statement. However, Apache Tomcat report back an error in the query string. I tried to run the same query style in MS Access and it works. Can someone please tell me where is the error in jsp code:
    JSP Code:
    sql = "SELECT tblStudent.firstName, tblStudent.lastName, tblStudent.studentID FROM tblStudent WHERE (((tblStudent.firstName) LIKE '%" + g_firstNameInput + "%')) ORDER BY tblStudent.firstName";
    MS Acccess:
    SELECT tblStudent.firstName, tblStudent.lastName, *
    FROM tblStudent
    WHERE (((tblStudent.firstName) Like '*e*'))
    ORDER BY tblStudent.firstName;
    PS: I tried changing from '%' to '*' already, but still does not work
    Thanks

    Don't use JSP for SQL querries... to complicated.
    1) Write a Java application that does what you want (as far as interacting with the database
    2) Isolate the database access code into its own class/classes
    3) Double check that you can then use those isolated classes inside a command line application
    4) Adapt the code you used in 3) to use those same classes from a JSP - preferrably using Java Beans and DTOs

  • Complex query using 'sql like' statement.

    Given the following basic class structure.
    public class Project {
         private String name;
         private Architecture architecture;
         private Resources resources;
         public Architecture getArchitecture();
         public void setArchitecture(Architecture architecture);
         public Resources getResources();
         public void setResources();
         public String getName();
         public void setName(String name);
    public Architecture {
         private String name;
         public String getName();
         public void setName(String name);
    public Resources {
         private String name;
         public String getName();
         public void setName(String name);
    we want to be able to do a query like:
         find all Projects where (Project.name.indexOf("a") > 0) &&
    (Project.architecture.name.indexof("b") > 0)
    In essence a "like" comparison across String properties of the JDO objects.
    Is it supported in KODO?? Anyone tried it out? Also, is it possible to
    generate SQL type query in KODO?
    rgds
    NK

    Note that this relies on a current bug in Kodo -- we should escape out the
    '%' character, but we don't.
    Some day, we'll fix that bug. But, before then, we will introduce a proper,
    supported mechanism for finding records that have a string field that
    contains some substring.
    -Patrick
    On 5/30/02 6:12 PM, "Andrew" <[email protected]> wrote:
    Hi,
    I wanted to perform a LIKE statement to get records where the partial string
    existed in a field -> eg. select a where a.field LIKE "SPRING" - 2 records,
    SpringSteen & MindSprings
    I did it like this:
    setFieldName("Spring");
    String sFilter = "field.startsWith(%\" + getFieldName() + \"%)"; -
    Extent anExtent = pm.getExtent(this.getClass(), true);
    Query aQuery = pm.newQuery(this.getClass(), anExtent, sFilter);
    return (Collection) aQuery.execute();
    Hope it helps. oh, don't know about the generating sql query.
    Nitin Kanani wrote:
    Given the following basic class structure.
    public class Project {
    private String name;
    private Architecture architecture;
    private Resources resources;
    public Architecture getArchitecture();
    public void setArchitecture(Architecture architecture);
    public Resources getResources();
    public void setResources();
    public String getName();
    public void setName(String name);
    public Architecture {
    private String name;
    public String getName();
    public void setName(String name);
    public Resources {
    private String name;
    public String getName();
    public void setName(String name);
    we want to be able to do a query like:
    find all Projects where (Project.name.indexOf("a") > 0) &&
    (Project.architecture.name.indexof("b") > 0)
    In essence a "like" comparison across String properties of the JDO
    objects.
    Is it supported in KODO?? Anyone tried it out? Also, is it possible to
    generate SQL type query in KODO?
    rgds
    NK
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • SQL "LIKE" statement isn't working right -- help please!

    Good day everyone,
    I thought about putting this in the "SQL on Oracle" forum, but it looked like those messages were geared more toward the Oracle platform itself, so here I am.  I apologize if this isn't the best forum.
    I have the following SQL statement:
      SELECT zzreporting_ut1
             zzreporting_ut2
             zzreporting_ut3
             zzreporting_ut4
             zzreporting_ut5
          UP TO 1000 ROWS
          INTO TABLE it_gmia_gmgrresp_data
            FROM gmspprogram
       WHERE ( ( zzreporting_ut1 LIKE '4011%'   OR
                 zzreporting_ut1 LIKE '4012%'   OR
                 zzreporting_ut1 LIKE '4013%' ) OR
               ( zzreporting_ut2 LIKE '4011%'   OR
                 zzreporting_ut2 LIKE '4012%'   OR
                 zzreporting_ut2 LIKE '4013%' ) OR
               ( zzreporting_ut3 LIKE '4011%'   OR
                 zzreporting_ut3 LIKE '4012%'   OR
                 zzreporting_ut3 LIKE '4013%' ) OR
               ( zzreporting_ut4 LIKE '4011%'   OR
                 zzreporting_ut4 LIKE '4012%'   OR
                 zzreporting_ut4 LIKE '4013%' ) OR
               ( zzreporting_ut5 LIKE '4011%'   OR
                 zzreporting_ut5 LIKE '4012%'   OR
                 zzreporting_ut5 LIKE '4013%' ) ).
    All I want to do is bring back the rows where one of those 5 "ut" fields begins with 4011, 4012, or 4013.  However, when I run it, it brings back anything:  rows where all 5 "ut" fields are empty, where the ut1 field begins with 4014, etc.
    Does anyone know what I'm doing wrong in my SQL statement?
    Thank you!  And as always, points awarded for ALL HELPFUL answers!
    Dave
    Edited by: Dave Packard on Jul 1, 2008 2:18 PM

    Hi Dave,
    because I don't know such a table named gmspprogram I'm not sure what to say.
    According to boolean expression syntax you do not need any of the brackets because the only operator used is OR.
    I'd suggest.
    data: lt_pattern_range type range of gmspprogram-zzreporting_ut2.
    perform insert_range using 'ICP':
      '4011*' '' changing lt_pattern_range,
      '4012*' '' changing lt_pattern_range,
      '4013*' '' changing lt_pattern_range.
    SELECT
      zzreporting_ut1
      zzreporting_ut2
      zzreporting_ut3
      zzreporting_ut4
      zzreporting_ut5
      UP TO 1000 ROWS
      INTO CORRESPONDING FIELDS OF TABLE it_gmia_gmgrresp_data
      FROM gmspprogram
      WHERE zzreporting_ut1 in lt_pattern_range
         OR zzreporting_ut2 in lt_pattern_range
         OR zzreporting_ut3 in lt_pattern_range
         OR zzreporting_ut4 in lt_pattern_range.
    * need form
    *&      Form  insert_range
    *       insert selection range - handles any range type "CLI20061218
    FORM insert_range  USING    p_signopt     TYPE c            "#EC CALLED
                                p_low         TYPE any
                                p_high        TYPE any
                       CHANGING pt_range      TYPE table.
      FIELD-SYMBOLS:
        <range>                               TYPE ANY,
        <sign>                                TYPE ANY,
        <option>                              TYPE ANY,
        <low>                                 TYPE ANY,
        <high>                                TYPE ANY.
      DATA:
        lv_ref                                TYPE REF TO data.
      CHECK NOT (
                  p_low     IS INITIAL AND
                  p_high    IS INITIAL ).
      CREATE DATA lv_ref                      LIKE LINE OF pt_range.
      ASSIGN lv_ref->* TO <range>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>.
      CHECK sy-subrc                          = 0.
      <sign>                                  = p_signopt(1).
      <option>                                = p_signopt+1(2).
      <low>                                   = p_low.
      <high>                                  = p_high.
      READ TABLE pt_range WITH KEY table_line = <range> BINARY SEARCH
        TRANSPORTING NO FIELDS.
      CHECK sy-subrc                          <> 0.
      INSERT <range> INTO pt_range INDEX sy-tabix.
    ENDFORM.                    " insert_range
    At least - I think - this looks better. And you may reuse the FORM insert_range whereever you want.
    Regards,
    Clemens

  • SQL LIKE statement to text field fomr CF MX 6.1

    Hi.
    Here's my scenario. I am running SQL Server 2000 SP4 on a
    Windows 2003 Server running IIS 6. Using ColdFusion MX 6.1 Updater
    version.
    I am storing HTML page code (some complete, some just clips)
    in a text type field.
    I need to check to see if someone has already saved that
    exact code already before. So I do the following query:
    <cfquery name="checkforexisting"
    datasource="mydatasource">
    SELECT smallfieldtogetareturn
    FROM MyTable
    WHERE MyTextField LIKE '%#mystringoflongdata#%'
    </cfquery>
    Then to see if it posted:
    <cfif checkforexisting.RecordCount GT 0>
    do the don't clip optional processing
    </cfif>
    What is killing me is that it finds the match SOMETIMES. Just
    not ALL the time. I have tried no percent signs when passing the
    ColdFusion variable, only one on the right (which has solved these
    types of problems before).
    If I pull the record back OUT of the database in a page by
    itself (retrieving it by key field), it finds every other copy of
    the code EVERY time.
    I have put this into a stored procedure, which seemed to help
    I even have resorted to creating a temp table first with the
    clip, then running a query to retrieve the record that was just put
    in, and comparing THAT to my primary table (both have text type
    fields). The reason for this, is that if I write a single page that
    has just the retrieval of the temp record, and that compare is run,
    it finds EVERY copy of it in the primary table. I also thought that
    maybe there was a strong problem (I had tried HTMLEditFormat,
    HTMLCodeFormat, JavaCast since it was coming from a java program on
    the browser end).
    I am not terribly familiar with using large text fields, or
    dealing with these large pieces of HTML code as something to
    compare!
    - Mike

    MichaelSJudd wrote:
    As Dan indicated your most likely issue is slight differences
    in
    capitalization and|or white space or other 'invisible'
    difference
    between your strings. One can have nearly infinite variety in
    HTML code
    that will display identically in a browser, the standard is
    very
    forgiving of formatting differences.
    Something I have done in the past to compare HTML content is
    to use the
    hash() function. It will not help you eliminate the
    differences but it
    would show when something is different then it appears to be.
    #hash(mystringoflongdata)# will return a hexadecimal number
    representing
    the string. Two *exactly* the same strings will produce the
    same
    number. Then it is very easy to compare these numbers to see
    if two
    long strings are the same.
    To use this with your database data, you would probably have
    to store
    the hash value of the string in a field when you store the
    HTML data.
    HTH
    Ian

  • SQL LIKE statement help

    Hi all,
    I want to select all values from prps-usr00 where the field contains XXX-XXXX...where X is any letter or number. How in the world do I do that?
    Thanks,
    Mat

    Hi,
    SELECT SOMETHING INTO VARIABLE FROM TABLE
                                         WHERE PARAM1 LIKE '%-%'.
    Or
    If you know that there will be exactly 2 char in front of '-' and 2 char after. then use.
    SELECT SOMETHING INTO VARIABLE FROM TABLE
                                     WHERE PARAM1 LIKE '__-__'.
    Regards
    madhu
    Edited by: madhu tatikonda on Jun 27, 2008 9:08 PM

  • T-sql case statement in a select

    When I execute the following t-sql 2012 statement, the "NO Prod' value is not
    being displayed from the sql listed below:
    SELECT DISTINCT
    IsNull(cs.TYPE,'') as type,
    CASE IsNull(Course.TYPE,'')
    WHEN 'AP' then 'AP Prod'
    WHEN 'IB' then 'IB Prod'
    WHEN 'HR' then 'HR Prod'
    WHEN '' then 'NO Prod'
    END AS label
    FROM CustSection cs
    INNER JOIN dbo.Person p on P.personID = cs.personID
    Left join customCustomer cs564 on cs564.personID = p.personID and
    cs564.attributeID ='564'
       where ( cs.type is null and cs564.attributeID = null)    
         or
        (cs.type IN ('HR','AP') OR
          (cs.type='IB' AND SUBSTRING(cs.code,1,1)='3'))  
    ORDER BY label
    What I want is for 'NO Prod' to be displayed when
    cs.type is null and cs564.attributeId  is null.
    Thus can you tell me how to fix query above so the 'NO Prod'  value is displayed in the
    select statement listed above?

    There is no CASE statement in SQL; we have a CASE expression. We do not use the old 1970's Sybase*- ISNULL(); we have  COALESCE().
    There is no such thing as a magic generic “type” in RDBMS. There is no such thing as a generic “code” in RDBMS. They have to to be “<something in particular>_type” and “<something in particular>_code” in a valid data model. How about blood_type
    and postal_code?? 
    There is no such thing as a generic “person” table in RDBMS. First of all, do you really have only one person, as you said?? But the important point is that these persons play a role in the data model – customers, students, etc. You are doing the wrong thing
    and doing it badly.  This table should not exist any more than a  table of “Things” such exist. 
    And the reason you are beyond any real help is “attribute_id” which tell us that your schema is a total disaster of data and meta data mixed together in a non-RDBMS written in awful SQL. Based on cleaning up bad SQL for 30 years, it looks like you are an OO
    programmer who never unlearned his prior mindset. 
    Why did you allow an encoding schema with blanks? Why do you have so many NULL-able columns? 
    SELECT DISTINCT is very rare in a properly designed schema. The DRI references assure that rows cam be matched. To get you started, look at this skeleton:
    CREATE TABLE Products
    (product_gtin CHAR(15) NOT NULL PRIMARY KEY, 
     product_type CHAR(2) DEFAULT 'XX' NOT NULL
      CHECK (product_type IN ('AP', 'IB', 'HR', 'XX'))
    The table name is a plural noun because it models a set (NOT an OO class).
    The GTIN is an industry standard identifiers, and not have to invent our own.
    The product_type (not blood_type, not automobile_body_type!) has a constraint that assures it is never NULL and never blank; I invented 'XX' as a default. 
    You need more help than you can get in a forum, but if you will follow Netiquette and post the DDL, we can get you started.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • SQL CASE statement in XML template- End tag does not match start tag 'group

    Hi All,
    I am developing a report that has the SQL CASE statement in the query. I am trying to load this into RTF with report wizard and it gives me below error
    oracle.xml.parser.v2.XMLParseException: End tag does not match start tag 'group'
    Does XML publisher support CASE statement?
    My query is something like this
    SELECT customercode,
    SUM(CASE WHEN invoicedate >= current date - 30 days
    THEN balanceforward ELSE 0 END) AS "0-30",
    SUM(CASE WHEN invoicedate BETWEEN current date - 60 days
    AND current date - 31 days
    THEN balanceforward ELSE 0 END) AS "31-60",
    SUM(CASE WHEN invoicedate < current date - 60 days
    THEN balanceforward ELSE 0 END) AS "61>",
    SUM(balanceforward) AS total_outstanding
    FROM MyTable
    GROUP BY customercode
    ORDER BY total_outstanding DESC
    Please advice if the CASE statement or the double quotes are causing this error
    Thanks,
    PP

    I got this to work in the XML but the data is returning zeros for all the case statements. When I run this in toad I get results for all the case conditions but when ran in XML the data displayed is all zeros. I am not sure what I am missing. Can someone shed some light on this please
    Thanks!
    PP

  • Parsing an OPEN SQL select statement

    Hi all,
      I want to parse an open SQL select statement to get the list of tables and the corresponding fields in the select statement.
      Is there some ABAP-internal syntax from the SAP Database Interface that does this? or is the only option to do this is to manually break the statement?
    Thanks.
    Girish

    Hi,
    I doubt if there is something like that available to use. It think you will have to write a parser for yourself.
    Regards

  • Java.sql.SQLException: Statement cancelled, probably by transaction timing

    Hi all,
    I have a problem with transaction handling over 2 applications. I have 2 EAR files (*A.ear* and B.ear) which are deployed on a WLS 12.1. The WLS contains a XA datasource which is connected to a Oracle XE database. Both applications are using the same datasource. The datasource is configured to use the driver oracle.jdbc.xa.client.OracleXADataSource.
    EAR A contains a Remote EJB which is is calling a local EJB. The local EJB calls a Remote EJB from EAR B.
    Here is an example how the code looks like:
    @Remote
    @Stateless(mappedName = "AnyRemote", name = "AnyRemote")
    public class AnyRemoteBean implements AnyRemote {
        @EJB
        private AnyLocal anyLocal;
        @Override
        public void doIt() {
            anyLocal.doSomething();
    @Local
    @Stateless(mappedName = "AnyLocal", name = "AnyLocal")
    public class AnyLocalBean implements AnyLocal {
        @PersistenceContext(unitName = "A")
        private EntityManager entityManager;
        @EJB(mappedName = "AnyCompositeService")
        private AnyCompositeService anyCompositeService;
        @Override
        @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
        public boolean doSomething() {
                try {
                     // do some stuff and save to database within another local EJB
                    anyCompositeService.doSomethingOnEAR_B();
                    return true;
                } catch (final AnyException e) {
                    LOGGER.error("doSomething failed", e);
                    return false;
        @Override
        @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
        public boolean stayOnEar_A() {
                // do some stuff and save to database within another local EJB
                return true;
    }AnyCompositeService located in EAR B looks like this:
    @Remote
    @Stateless(mappedName = "AnyCompositeService ", name = "AnyCompositeService ")
    public class AnyCompositeServiceBean implements AnyCompositeService {
        @Override
        public boolean doSomethingOnEAR_B() throws AnyException {
            // do some calls to some local EJBs and some other remote EJBs and save something to database
            return true;
    }In this process of EAR B I'm using the entitiy manager:
        @PersistenceContext(unitName = "B")
        private EntityManager entityManager;persistence.xml for EAR A looks like this
        <persistence-unit name="A" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>MyDatasource</jta-data-source>
           <!-- some entities -->
            <properties>
                <property name="hibernate.transaction.jta.platform"
                    value="org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform" />
                <property name="hibernate.max_fetch_depth" value="3" />
                <property name="hibernate.connection.characterEncoding" value="UTF-8" />
                <property name="hibernate.connection.charSet" value="UTF-8" />
                <property name="hibernate.connection.useUnicode" value="true" />
                <property name="hibernate.default_batch_fetch_size" value="20" />
            </properties>
        </persistence-unit>
    </persistence>persistence.xml for EAR B looks like this
        <persistence-unit name="B" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>MyDatasource</jta-data-source>
           <!-- some entities -->
            <properties>
                <property name="hibernate.transaction.jta.platform"
                    value="org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform" />
                <property name="hibernate.max_fetch_depth" value="3" />
                <property name="hibernate.connection.characterEncoding" value="UTF-8" />
                <property name="hibernate.connection.charSet" value="UTF-8" />
                <property name="hibernate.connection.useUnicode" value="true" />
                <property name="hibernate.default_batch_fetch_size" value="20" />
            </properties>
        </persistence-unit>
    </persistence>As you can see the method doSomething() defines the transaction attribute TransactionAttributeType.REQUIRES_NEW.
    When I execute AnyRemote.doIt() I get the following exception:
    Caused By: java.sql.SQLException: Statement cancelled, probably by transaction timing out
         at weblogic.jdbc.wrapper.Statement.postInvocationHandler(Statement.java:69)
         at weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePreparedStatementWrapper.clearBatch(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
         at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
         at $Proxy452.clearBatch(Unknown Source)
         at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:163)
         at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.release(AbstractBatchImpl.java:197)
         at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:139)
         at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.close(TransactionCoordinatorImpl.java:276)
         at org.hibernate.internal.SessionImpl.close(SessionImpl.java:349)
         at org.hibernate.ejb.EntityManagerImpl.close(EntityManagerImpl.java:137)
         at weblogic.persistence.TransactionalEntityManagerProxyImpl.close(TransactionalEntityManagerProxyImpl.java:117)
         at weblogic.persistence.BasePersistenceContextProxyImpl$PersistenceContextCloser.afterCompletion(BasePersistenceContextProxyImpl.java:213)
         at weblogic.transaction.internal.ServerSCInfo.doAfterCompletion(ServerSCInfo.java:1068)
         at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:1012)
         at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:3074)
         at weblogic.transaction.internal.ServerTransactionImpl.afterRolledBackStateHousekeeping(ServerTransactionImpl.java:2954)
         at weblogic.transaction.internal.ServerTransactionImpl.setRolledBack(ServerTransactionImpl.java:2930)
         at weblogic.transaction.internal.ServerTransactionImpl.globalRetryRollback(ServerTransactionImpl.java:3172)
         at weblogic.transaction.internal.ServerTransactionImpl.globalRollback(ServerTransactionImpl.java:2920)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:374)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:268)
         at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:332)
         at weblogic.ejb.container.internal.BaseLocalObject.__WL_postInvokeTxRetry(BaseLocalObject.java:202)
         at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:44)As long as the process only calls EJBs from EAR A only there is no issue. But if the process calls the method doSomethingOnEAR_B() on EAR B the call fails with above exception. If the process throws AnyException the rollback takes place as expected for transaction in EAR B and EAR A.
    Does anybody know what is the issue here? Is there any configuration I have overseen?

    That is a WLS internal message. The statement did get cancelled,
    probably as a part of the process of rolling back the transaction it
    was involved in. If you don't find your core problem, open an
    Oracle support SR, and we could help debug this further.

  • Not Like statement in Crystal?

    In SQL server there is a statement that goes along the lines of (field1) not like '09%'
    In Crystal Reports there is a statement "Like".  Is there any statement in Crystal that is "Not Like"?
    I'm trying to get a wildcard of 09 to work in Crystal so far I have......
    (field1) <> "09*"
    But it needs to be something like the following ........
    (field1) not like "09*"
    Does Crystal have a Not Like statement?  What are my choices if Crystal does not have that statement?
    Thanks

    I'm looking for anything that does not contain any thing like "09".  The actual "09" field is "09xx", and the report will need to pull back everything that is not "09"
    I used the * symbol to try and do a wildcard that would not pull back anything that is like "09".
    I was wondering if the * symbol was Crystal Reports answer to "Not Like"?

  • Convert sql select statement to oracle

    Hi All,
    Can anyone help me converting this Sql select statement to oracle ....
    -----------------------------------------Query--------------------------------------------------------------
    select emp_master.emp_code ,
    emp_master.dept_cd ,
    attendance_master.daily_attn_code ,
    attendance_master.linked_column ,
    case when location.payroll_status <> 'N' and eDocsNetEmployeesLeave.StartDate < dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))     
    then
    dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))
    when eDocsNetEmployeesLeave.StartDate < convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01')     
    then convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01') else eDocsNetEmployeesLeaveDetails.StartDate           
    end ,
    eDocsNetEmployeesLeaveDetails.NoOfDays,          
    case when eDocsNetEmployeesLeave.StartDate > location.next_pay_date     
    then convert(datetime , convert(varchar, dateadd(ss,-1, dateadd(mm, 1, convert(datetime , datename(yy,eDocsNetEmployeesLeave.StartDate)+ '/' + datename(mm,eDocsNetEmployeesLeave.StartDate)+ '/01') )),106) )     
    else      
    case when location.payroll_status <> 'N'
    then dateadd(mm,1,location.next_pay_date)      
    else location.next_pay_date
    end      
    end as PaymentDate               ,
    isnull(grade_master.leave_type,'C') ,
    eDocsNetEmployeesLeave.StartDate ,          
    eDocsNetEmployeesLeaveDetails.LeaveType
    from eDocsNetEmployeesLeave ,
    eDocsNetEmployeesLeaveDetails ,
    eDocsNetLeaveTypes ,
    emp_master ,
    grade_master ,
    attendance_master ,
    location
    where eDocsNetEmployeesLeaveDetails.RequestID     = eDocsNetEmployeesLeave.RequestID and
    eDocsNetEmployeesLeave.EmployeeID = emp_master.emp_code and
    eDocsNetEmployeesLeaveDetails.LeaveType = eDocsNetLeaveTypes.LeaveTypeID and
    eDocsNetLeaveTypes.loc_cd = emp_master.loc_cd and
    location.loc_cd = emp_master.loc_cd and
    attendance_master.loc_cd = emp_master.loc_cd and
    attendance_master.linked_column = eDocsNetLeaveTypes.LinkedAttendance and
    grade_master.loc_cd = emp_master.loc_cd and
    grade_master.grade_cd = emp_master.grade_cd and
    eDocsNetEmployeesLeaveDetails.RequestID      = @RequestID
    order by eDocsNetEmployeesLeaveDetails.StartDate
    Thanks in Advance
    Smiley

    Seems like you want to convert a SQL statement from the ??? dialect to the Oracle dialect. *(It would be useful to indicate the non-ANSI standard SQL you are starting with.)
    Part of the problem is that you use several date related functions. Some are unnecessary in Oracle and some need to translated into Oracle functions as found in the Functions section (chapter 5) of the SQL Reference manual at http://www.oracle.com/pls/db102/homepage
    Note that columns and expressions of type 'date' in ORacle always contain all of "yyyy mm dd hh mi ss" and you need to format and trauncate as necessary.
    Also note that '09-JAN-31' is NOT an Oracle date, but rather a character representation of a date which must be converted to/from a date expression. You will often need to use the to_date() and to_char() functions with a format mask as the second parameter. This is also descreibed in the first 2 chapters of the SQL Reference manual.

  • Sql - execute statement problems

    I have a "try" with a "catch" that contains an sql execute statement, and some statements after that, but it doesn't execute any of the following statements. It successfully compiles and has no errors when I run it. It just doesn't insert the information and it stops every command that follows. When I remove the execute state (the one with the asterist next to it), the following statements execute fine. Any information on what I might be missing would be greatly appreciated. Thanks.
    try{
    new JdbcOdbcDriver();
    String url = "jdbc:odbc:javadb";
    String user = "";
    String password = "";
    Connection con =
    DriverManager.getConnection(url, user, password);
    Statement stmt = con.createStatement();
    System.out.println("Made the Connection");
    *stmt.executeUpdate("INSERT INTO tbl VALUES ('bradley')");
    System.out.println("Made the Connection");
    JOptionPane.showMessageDialog(this, "Data Inserted");
    }catch(Exception e)
    e.printStackTrace();
    }

    Look in your log file. When you perform "e.printStackTrace()" the stack is sent to the System.out, which JSP has already redirected to the log.
    If you're having trouble finding the log (it depends on what webserver you're using), try changing that to:
    out.println("<h3>We have an error: " + e + "</h3>");
    (Notice the absense of "System." here. We're using the pre-defined JSP "out" object that's going to the client browser.)
    That will print the error message, plus the reason for the error, on your client as 2nd level header.
    Personally, I always print out my error messages in this manner. I find that having a full, complete, extensive stack trace is next to useless. It's like asking for the definition of the word "Java", and having the Oxford Unabridged Dictionary dropped in your lap.

  • ODI Error: java.sql.SQLException: statement is not in batch mode

    Greetings Gurus!
    Would anybody know why changing a SQL view from
    AND hapf.attribute1 LIKE '%Active%'
    To
    AND (hapf.attribute1 LIKE '%Active%' or hapf.attribute1 = ‘Frozen’)
    cause ODI to fail?
    This is the error message from ODI:
    ODI-1228: Task SrcSet0 (Loading) fails on the target SUNOPSIS_ENGINE connection SUNOPSIS_MEMORY_ENGINE.
    Caused By: java.sql.SQLException: statement is not in batch mode
    at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
    at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
    at org.hsqldb.jdbc.Util.sqlExceptionSQL(Unknown Source)
    at org.hsqldb.jdbc.JDBCPreparedStatement.executeBatch(Unknown Source)
    at oracle.odi.runtime.agent.execution.sql.SQLCommand.end(SQLCommand.java:267)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.endExecution(SQLExecutor.java:156)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.endExecution(SQLExecutor.java:1)
    at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:113)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:558)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
    at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.hsqldb.HsqlException: statement is not in batch mode
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    ... 19 more
    Thank you!
    Ray

    Looks like the single quotes around Frozen are not ascii single quotes. They seem to be a copy paste job from MSWord.
    It should be 'Frozen' and then you shouldnt have that issue
    >
    AND hapf.attribute1 LIKE '%Active%'
    To
    AND (hapf.attribute1 LIKE '%Active%' or hapf.attribute1 = ‘Frozen’)
    >
    Devil is in the details ;)

  • Generate SQL Insert Statements

    Hello,
    I am testing generating insert statements for which I have a function which will return a sql statement.
    This sql statement when I execute would results as sql insert statements.
    What I am trying to acheive through a procedure is when I execute function, the result I would like to execute automatically and then the second sql I would like to store to a control file or sql file.
    How can I acheive this?
    Any help is very helpful
    Regards
    Edited by: user20090209 on Aug 20, 2009 11:34 AM

    Here is the function to generate sql
    CREATE OR REPLACE function insert_sql(v_table_name varchar2)
    return varchar2 as
    b_found boolean := false;
    v varchar2(32000);
    v1 varchar2(32000);
    v2 varchar2(32000);
    begin
    for s in (
    select *
    from all_tables
    where table_name=upper(v_table_name)
    --and owner=upper(v_owner)
    ) loop
    b_found := true;
    for ss in (
    select *
    from all_tab_columns
    where table_name = s.table_name
    order by column_id
    ) loop
    if ss.data_type='NUMBER' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||to_char('||ss.column_name||')||''''''';
    end if;
    if ss.data_type in ('VARCHAR2','CHAR') then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||replace(replace('||ss.column_name||','''''''',''''''''''''),''&'','''')||''''''';
    end if;
    if ss.data_type='DATE' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',to_date(''''''||to_char('||ss.column_name||',''dd.mm.yyyy hh:mi:ss'')||'''''',''''dd.mm.yyyy hh:mi:ss'''')';
    end if;
    end loop;
    v:='select ''insert into '||s.table_name||' (';
    v:=v||substr(v1,2,9999)||') '||chr(10)||' values ('||substr(v2,2,9999)||'); '' txt from '||s.table_name;
    end loop;
    if not b_found then
    v:='- Table ' || v_table_name || ' not found';
    else
    v:=v;
    end if;
    return v;
    end;
    /And I am calling like
    CREATE OR REPLACE PROCEDURE test_gen_script_exec IS
    type v_ref_cur is REF CURSOR;
    v_ref_cur_var v_ref_cur;
    v_temp_sql VARCHAR2(4000);
    v_sql varchar2(4000);
    begin
    v_sql := insert_sql('table_name');--change here
    open v_ref_cur_var for v_sql;
    loop
    fetch v_ref_cur_var into v_temp_sql;
    exit when v_ref_cur_var%notfound;
    execute immediate v_temp_sql;
    end loop;
    close v_ref_cur_var;
    end;
    /Edited by: user20090209 on Aug 20, 2009 1:24 PM

Maybe you are looking for

  • Unable to Create Entity Model from existing oracle database

    Hi, I am using Visual Studio 2013, .net framework 4.5, entity framework 5.0 and oracle 11g database. Issue Description: I need to develop WCF service to exposing the account information which needs to get the data from 20 oracle tables. Trying to cre

  • ITunes saying cannot read and write on iPod Touch 3rd gen 64Gb

    I just got an iPod Touch 64Gb and synched with my iTunes 9 on my MacBook Pro running Snow Leopard. Getting error message after about 6Gb into the synch saying that it cannot access read or write to the memory of the iPod. Went already at the Apple St

  • REST API usign ajax

    Hello I am trying to make use of REST API using ajax, but its failing giving the error message: "NetworkError: 403 Forbidden - https://secure.eloqua.com/API/REST/1.0/data/contact/123" Below is the javascript code I am using: <script>     jQuery.ajax(

  • Show results from the database to html tables?

    Hi, I am a PHP programmer and did a successful CMS program for a company. Now I have another project which is a web based system. I basically know how to do it and finish it in PHP.. but I am trying to do it using J2EE.. I am trying to learn J2EE now

  • Use of Supply Chain Engineer

    Hi,   What's the use of Supply Chain Engineer (Tcode:/SAPAPO/SCC07)? Does the APO implementation project really needs it? And let me know in which case do we generally use it. - Ram.