IS POSSIBLE USE 'IF' IN QUERY WITH DB ACCESS?

Hi, I'd like to use:
SELECT IF(send = 1, 'YES', 'NO') FROM post
to take records from a dbaccess.
I used it but I have this proble ... "Function IF not definited"
Can I use IF with dbaccess?
Thanks

yes ... the question is to use in Java.
After i put the query in jdbTable.
My db is access mdb.
My query is:
        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
            database1,
            "SELECT DISTINCT ID, IF(send = 1, 'YES', 'NO')  FROM clients ", null, true,
            Load.ALL));I tried also to use 'CASE'
        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
            database1,
            "SELECT DISTINCT ID, case when send = 0 then 'NO' when send = 1 then 'YES' end FROM clients ", null, true,
            Load.ALL));BUT NOTHING.
You suggest to use where ... yes in this way is ok:
        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
            database1,
            "SELECT DISTINCT ID, 'NO' as send FROM clients  WHERE send=0 UNION ALL  SELECT DISTINCT ID, 'YES' as send FROM clients  WHERE send=1", null, true,
            Load.ALL));Yes it's a solution but sometime I have long query and different type of recors for send (0=no send, 1=send, 2=refused, ....)
I'd like to find a better solution.
I Thank you for your replies.

Similar Messages

  • Is it possible to update a query with another query?

    I'm trying to update a query with another query (see attached
    code). Here's my setup: I've got a table in an Access database in
    which I enter a string into a form and update. This string
    corresponds to a single record in another table of the same
    datasource. The first table has only one record to provide the
    second, which has many and will have more. Basically what I'm
    wondering is: Is this a valid thing to do in coldfusion? If not
    please help with an alterate method. I'm still a novice at
    coldfusion.
    The overall effect I'm going for is to display the one record
    as a featured truck profile on the web site:
    www.truckerstoystore.net.
    I currently get an error when I try to display the page with the
    current query setup.
    Check this page to see the error:
    www.truckerstoystore.net/currentTOW2.cfm
    Help on this issue is very much appreciated.
    ------------------------------------------------------------------------------------------ -----------------------------------------------------------------------

    I think this is what you are after
    <!--- this query will get all the records from the DB
    --->
    <cfquery name="cTOW" datasource="tow">
    SELECT *
    FROM currentTOW
    <!--- Do you need to find a particular record in the
    database --->
    <!--- If so, then you need a 'where' clause in here
    --->
    </cfquery>
    <!-- Loop the cTOW query for each record returned -->
    <cfloop query="cTOW">
    <!--- For the record returned from the cTOW query you now
    need to update the table --->
    <!-- Update the table -->
    <cfquery name="currentTOW" datasource="tow">
    UPDATE Your tblName
    SET
    Dataname = cTOW.DataValue
    </cfquery>
    </cfloop>
    thats it
    PS: I think your original query needs modifying. To return
    the exact records that you want to update from the original table.
    ie: Primary and foreign key relationship

  • SQL Query with MS-Access Database

    Hi,
    I have linked my oracle database with MS-Access via a DB LINK. i can access the data from MS-ACCESS, but i have a problem that when i specify the column name or define a where clause in my query it gives me the error ORA-00904: invalid identfier ..
    This query fetch the data without any problem SELECT * FROM TBLREPORT@M_ACCESS but when i run SELECT EMP_ID FROM TBLREPORT@M_ACCESS it gives me the error i mentioned above. (Column name have No problem or mistake of spelling even CASE)
    also when i try to put where clause in the query it gives me same error SELECT * FROM TBLREPORT@M_ACCESS WHERE EMP_ID = '100' (Error)
    is there any change in SQL query for ACCESS database ??
    any clue
    Regards
    Rehman

    Are column/table names in access case sensitive? Issue
    DESC TBLREPORT@M_ACCESS If column EMP_ID actual name shows up in mixed/lower case, enclose it in double quotes and use the exact case. E.g., if column name shows up as Emp_Id, use:
    SELECT "Emp_Id" FROM TBLREPORT@M_ACCESSSY.

  • Using BEA Weblogic Portal with Sun Access Manager

    Hello all,
    I am wondering if anyone has had experience with using Weblogic Portal (versions 8.1 or 9.2) with Sun's Access Manager tool (part of the Identity Management suite).
    In particular, I would like to know what access control tasks were performed through access manager, and which were performed portal-side.
    Any information would be appreciated.
    Thanks!

    Hi
    Has any one explored the below question.
    Is WLP 9.2 compatible with Sun Access Manager?
    If yes, please let know the details.
    Thanks

  • Is there possibility use UCS2 in procedures with out parameters?

    I am trying to use UCS2 character set in my SQL strings. Everything works out nice and smoothly if I am using procedures which require only input parameters (like those which insert data in db).
    But when I try to use procedure containing one output or input/output type parameter, all parameters are shortened by one character (2 bytes) after call. Length of data is ok, but one extra null is set where last character should be. Other characters are like they should be.
    I am using Oracle version 8.1.7 in NT.
    Fist I bind my variables with OCIBindByName and then set OCI_UCS2ID with OCIAttrSet.
    ub2 csid = OCI_UCS2ID;
    m_OCIStatus = OCIAttrSet(
    (dvoid *)handle,
    (ub4) OCI_HTYPE_BIND, (dvoid *) &csid,
    (ub4) 0, (ub4)OCI_ATTR_CHARSET_ID, m_errHndl);
    Am I missing something important or what is wrong?
    Regards
    Mika

    There is no example program. There is extensive help on how to do this. Here's the basics.
    1) There are two ways to define user error codes in LV6.1. If you are using LV6.0 or earlier, only one method is possible.
    2) The 6.0 method involves wiring arrays of error codes and arrays of error code strings to the General Error Handler.vi. These codes will be used to explain any error code which is undefined in LV's internal error code database. Error codes reserved for users which are guaranteed not to be used by NI are from 5000 to 9999.
    3) The 6.1 method allows you to create a specially formatted error code file on disk that will be merged with the LV error code database each time LabVIEW launches. For help on this, go to LV's online help, and in t
    he Index tab, type
    "user-defined error codes, in text files"
    (without the quote marks)
    4) If you want to set an error into the error cluster, use the General Error Handler.vi again. Wire your error code value to the Error Code terminal (the leftmost-topmost corner terminal). Wire the name of your VI to the Error Source terminal, and wire "No Dialog" to the Type of Dialog terminal (left-side, near the bottom). The error code cluster that comes out of this VI will either be the error in (if one was set) or a new error code cluster with your error and the status bit set to TRUE.
    5) The attached demo is written in LV6.0.
    Attachments:
    Error_Demo.vi ‏37 KB

  • SQLEception using Complex SQL Query with Java Studio Creator2 Build(060120)

    I am evaluating Java Studio Creator2 for a WEB base application project that will be making SQL queries to an Oracle Database but I have stumble into a problem using complex SQL queries.
    I am getting an SQLException "org.apache.jasper.JasperException: java.lang.RuntimeException: java.sql.SQLException: [sunm][Oracle JDBC Driver][Oracle]ORA-00923: FROM keyword not found where expected". I looks like it cut my sql.
    The SQL that I am trying to execute is
    Select part_name
    from table1, table2
    where table1.part_nbr = table2.part_nbr
    and table2.row_add_dt = (select max(table3.row_add_dt)
    from table3
    where table3.ser_part_id =table2.ser_part_id)
    This is a valid query that it is using 2 different selects to get a part number.
    If posible, point me to the best solution were I will be able to make complex SQL queries like the one above and bigger.
    Is there any way that I can read an SQL query file instead of inserting the SQL query string into the setCommand()?

    I have read that document looking for some anwsers on how to make this kind of query. If I try the query that I have above in the query editor ,the query editor will cut off from the last select that is between ().
    I beleave, there is a work around using the inner joint or outter join command. I will try them to see If I get the corrent result. If not, then I have to keep on asking for possible solutions.
    Anyway, someone in the Creator Team should take a note in adding something like a special criteria in the Add Query Criteria Box for cases like the one I have. The special criteria will be like using another select/from/where to get some result that will be compare.
    Girish, Are you in the Sun Creator Team?

  • Using REGEXP_LIKE to query with exclusion

    Dear all,
    how to query a column that doesn't contain value with a particular letter in the middle of it using REGEXP_LIKE? Suppose I have the following:
    SQL> select * from test;
    TEMP
    john
    joni
    jane
    johny
    jonny
    SQL> select temp from test where regexp_like(temp,'[^h]');
    TEMP
    john
    joni
    jane
    johny
    jonny
    SQL> select temp from test where regexp_like(temp,'[a-z]+[^h][a-z]+');
    TEMP
    john
    joni
    jane
    johny
    jonnyThe above code tries to query temp that doesn't contain letter 'h' in the middle (so it querries joni, jane, and jonny) but it cannot be done with
    regexp_like(temp,'[^h]');
    regexp_like(temp,'[a-z]+[^h][a-z]+');since these 2 patterns satisfy all the available rows. What is the solution?
    Best regards,
    Val

    Frank Kulash wrote:
    Hi,
    Valerie Debonair wrote:
    Hi Frank,
    could you give another example, this time involves not equal character ^ instead of using NOT?Why? What's wrong with NOT?
    There are other (more complicated and/or less efficient) ways to get the same results, but whatever objection you have to NOT might apply to those ways, too. Rather than have people suggest solutions one at a time, and wait for you to say "I can't use that", I suggest you explain why you can't use it, so that the next solution won;t have the same problem.
    ^ doesn't mean "not"; it means "something other than" or "anything except". This problem doesn't involve whther or not the string contains something other than 'h'; it only matters whether or not the string conatins 'h'.Hi Frank,
    the purpose of this question is for me to understand the usage of ^ character with REGEXP_LIKE. While your solution solves the particular case that I asked, it didn't fully serve the purpose of the question even though it works well in the real world. In order words, I was focusing on the semantic of regular expression.
    Thanks for the help though, your explanation on ^ character sheds me some light.......

  • Dynamic query with Data Access Layer

    I have a program that has a multiselect box (JSP form) to select certifications and then search to see which employee may have them.
    I have no issues when searching by only one, but if I select multiple certifications from the multiselect box, it doesn't work. I've tried and tried and I can't seem to figure this out.
    Below is the code for returning employees that match what certifications were chosen. Again, it works fine if only 1 was selected. I wish for it to return only the employees that match all selections.
    the arguments passed to the DataAccess Layer are an array of certification ID's and the size variable is how many certifications were chosen. The for loop is supposed to dynamically append to the end of the query an extra "AND" sql operator to match up. The 3 tables selected in the query are Employee (a list of employees and ID's), Certificates (a list of possible certificates and their ID's) and Employee_Certificate (a table that matches which employees have which certificates).
    What am I doing wrong?
    public List certSearch(int cert[], int size) throws Exception{
             // connection instance
             ArrayList list = new ArrayList();
             Connection connection=null;
             PreparedStatement pstatement = null;
             try
                    list.clear();
                    StringBuffer queryString = new StringBuffer("SELECT * from EMPLOYEE, EMPLOYEE_CERTIFICATE, CERTIFICATE" +
                                         " WHERE employee_certificate.employee_id = employee.employee_id " +
                                         "AND certificate.certificate_id = employee_certificate.certificate_id ");
                    for (int incr = 0; incr < size; incr++){
                        queryString.append("AND certificate.certificate_id = " + cert[incr] + " ");
                    String query;
                    query = queryString.toString();
                    // Send query to database and store results.
                    Class.forName(Driver);
                    //Establish network connection to the db
                    connection = (Connection) DriverManager.getConnection(url, username, password);
                    pstatement = (PreparedStatement) connection.prepareStatement(query);
                    ResultSet rs = pstatement.executeQuery();
                    while (rs.next())
                        Employee emp = new Employee();
                        int empID=Integer.parseInt(rs.getString("employee_id"));
                        String first=rs.getString("first_name");
                        String last=rs.getString("last_name");
                        emp.setID(empID);
                        emp.setFirstName(first);
                        emp.setLastName(last);
                        list.add(emp);
               catch(Exception readerr)
                    System.err.println("Error reading  "+ readerr);
               finally
                try
                    // close the connection so it can be returned to the
                    // connection pool then return the SubjectCounselor instance
                    connection.close();
                catch (SQLException ex)
                       System.err.println("Error reading employee data: " + ex);
                return list;
        }Edited by: Snadinator on Aug 1, 2009 1:35 PM

    You don't get it.
    This should work :
    public List certSearch(int cert[], int size) throws Exception{
             // connection instance
             ArrayList list = new ArrayList();
             Connection connection=null;
             PreparedStatement pstatement = null;
             try
                    list.clear();
                    String query = buildQuery(cert);
                    // Send query to database and store results.
                    Class.forName(Driver);
                    //Establish network connection to the db
                    connection = (Connection) DriverManager.getConnection(url, username, password);
                    pstatement = (PreparedStatement) connection.prepareStatement(query);
                    ResultSet rs = pstatement.executeQuery();
                    while (rs.next())
                        Employee emp = new Employee();
                        int empID=Integer.parseInt(rs.getString("employee_id"));
                        String first=rs.getString("first_name");
                        String last=rs.getString("last_name");
                        emp.setID(empID);
                        emp.setFirstName(first);
                        emp.setLastName(last);
                        list.add(emp);
               catch(Exception readerr)
                    System.err.println("Error reading  "+ readerr);
               finally
                try
                    // close the connection so it can be returned to the
                    // connection pool then return the SubjectCounselor instance
                    connection.close();
                catch (SQLException ex)
                       System.err.println("Error reading employee data: " + ex);
                return list;
        // I used the MySQL syntax; if it doesn't work : just enclose the values by single quotes
        private String buildQuery(int[] cert) {
            StringBuffer queryString = new StringBuffer("SELECT * from EMPLOYEE, EMPLOYEE_CERTIFICATE, CERTIFICATE" +
                    " WHERE employee_certificate.employee_id = employee.employee_id " +
                    "AND certificate.certificate_id = employee_certificate.certificate_id " +
                    "AND certificate.certificate_id IN ( ");
            queryString.append(cert[0]);
            for (int i = 1; i < cert.length; i++) {
                queryString.append(" ,");
                queryString.append(cert);
    queryString.append(" )");
    return queryString.toString();

  • Login codes using java database (validates with Microsoft Access File)

    hi all pro-programmer, can you show me the code to login with the username and password using java database. When the user enters the username and password in the login page then it will go to the requested page. may i know how to do it?

    no one will give you complete code.
    i'll lay out the pieces for you, though:
    (1) start with a User object. give it username and password attributes.
    (2) write a UserDAO interface with CRUD operations for a User object.
    (3) write a UserDAOImpl for your Microsoft Access database
    (4) write an AuthenticationService interface
    (5) write an implementation of the AuthenicationService that works with the UserDAO to authorize a User.
    Use a servlet to accept request from your login page and pass it off to the service. Voila.
    PS - Here's skeleton to start with. UI, servlet, and controller are your responsibility:
    package model;
    public class User implements Serializable
        private String username;
        private String password;
        public User(String u, String p)
            this.username = u;
            this.password = p;
        public String getUsername() { return username; }
        public String getPassword() { return password; }
    public interface UserDAO
        public User findByUsername(String username);
        public void saveOrUpdate(User user);
        public void delete(User user);
    public class UserDAOImpl implements UserDAO
        private Connection connection;
        public UserDAOImpl(Connection connection)
            this.connection = connection;
        public User findByUsername(String username)
            String password = "";
            // logic for querying the database for a User
            return new User(username, password);
        public void saveOrUpdate(User user)
            // save or update a User
        public void delete(User user)
            // delete a User
    public interface AuthenticationService
        public boolean isAuthorized(String username);
    public class AuthenticationServiceImpl implements AuthenticationService
        private UserDAO userDAO;
        public AuthenticationServiceImpl()
            // Create a database connection here and the UserDAO, too.
        public boolean isAuthorized(String username)
            boolean isAuthorized = false;
            // Add logic to do the database query and decide if the username is authorized
            return isAuthorized;       
    }

  • Can not execute a simple update query with ms access

    Hi
    I am trying to execute a simple update query , this is the code I am running : I get no exeptions but the db is not being updated .
    When I copy my query into access it works !
    The table / columns are spelled correctly and I am able to execute select queries.
    can anyone figure out what is going on
    Thanks shahar
    public static void main(String[] args) {
    MainManager mainManager = MainManager.getInstance();
    Log log = Log.getInstance();
    try {
    log.writeDebugMessage("befor executing query");
    //stmt.executeUpdate("update trainee set Trainee_Name = 'shahar&Rafi' where Trainee_Id = 1 ");
    //stmt = null ;
    PreparedStatement stmt1 = con.prepareStatement("UPDATE Trainee SET Trainee_Name =? WHERE Trainee_Id =?");
    String name = new String("Shahar&Rafi");
    int Id = 1 ;
    stmt1.setString(1,name);
    stmt1.setInt(2,Id);
    System.out.println(stmt1.toString());
    stmt1.execute();
    log.writeDebugMessage("After executing query");
    catch (SQLException e ){
    System.err.println("SQLException: " + e.getMessage());
    }

    Hi All,
    got the problem solved at last.
    first, in the SQL string all the values must be within " ' "
    for example:
    INSERT INTO Trainee(Trainee_Id , Trainee_password , Trainee_Address, Trainee_Name , Trainee_Phone , Trainee_Gender , Trainee_SessionTime , Trainee_Purpose , Trainee_HealthStatus , Trainee_StartDate , Trainee_Birthday) VALUES (6,'333','hhhh','rafi',048231821,true,63,4,true, ('Feb 22, 2002'), ('Feb 22, 2002'))
    second and more important,
    a 'dummy' sql select query must be performed after an update query
    example for code:
    try{
    DB.MainManager.getInstance().ExecuteUpdateQuery(A);
    DB.MainManager.getInstance().getStatement().executeQuery("SELECT * FROM Trainee");
    where A is the update query.

  • Drill Down BeX Query with hierarchy in WEBI

    Hi,
    I am using a Bex Query with Hierarchy in my WEBI report. Is it possible to drill down ? I am not able to use Scope of Analysis because it is disabled. I am very new to WEBI. Please help me out.
    Thanks in Advance.
    Lakshmi Mohan

    http://www.google.co.in/url?sa=t&rct=j&q=drill%20down%20bex%20query%20with%20hierarchy%20in%20webi%20%20%20&source=web&cd=2&ved=0CDQQFjAB&url=https%3A%2F%2Fcw.sdn.sap.com%2Fcw%2Fservlet%2FJiveServlet%2FpreviewBody%2F137316-102-1-277519%2FWeb%2520Intelligence%2520on%2520SAP%2520implementation%2520best%2520practices.pdf&ei=xofcTpSgF5DJrAeaxpiIBw&usg=AFQjCNHuwDIpvxciPKJyEdoz3GiVjRKgqA
    http://www.scribd.com/doc/62293080/40/Query-Drill-for-hierarchies

  • BEx query with variant from ABAP

    Hello,
    I'm looking for possibility to start BEx query with variant (variant is created with tx RSRT) from ABAP. There are some funktion modules, which start queries (launch excel), for example RSAH_LAUNCH_EXCEL or RSSEM_QUERY_LAUNCH, but they are ending with short dump, when there are variables in the query. Is there any standard FM, which starts the query with variant or accepts parameters?
    regards,
    Krzysztof

    Hi,
    the short dump was my fault, I've passed query name instead of genuniid to the RSAH_LAUNCH_EXCEL.
    What I'm trying to do is to I'll start BEx query with parameters (I don't want to get selection-screen from the query, I need to fill it from ABAP).
    Here is my example, which is not working.
    DATA:
      lv_query(30) TYPE c,
      lv_genuniid  TYPE rsrrepdir-genuniid,
      ls_var       TYPE rrx_var,
      lt_var       TYPE TABLE OF rrx_var.
    lv_query = 'YB_MAKLER_DETAIL'.
    CALL FUNCTION 'CONVERSION_EXIT_GENID_INPUT'
      EXPORTING
        input  = lv_query
      IMPORTING
        output = lv_genuniid.
    IF lv_genuniid = ''.
      WRITE: / 'There is no Query', lv_query.
    ELSE.
      ls_var-vnam = 'YS_MKLE'.
      ls_var-sign = 'I'.
      ls_var-opt  = 'EQ'.
      ls_var-low  = '0000005100'.
      APPEND ls_var TO lt_var.
      ls_var-vnam = 'YS_VTGJ'.
      ls_var-sign = 'I'.
      ls_var-opt  = 'EQ'.
      ls_var-low  = '1999'.
      APPEND ls_var TO lt_var.
      CALL FUNCTION 'RSAH_LAUNCH_EXCEL'
        EXPORTING
          i_genuniid                       = lv_genuniid
          I_OBJVERS                        = 'A'
          i_hide_sapgui                    = 'X'
        TABLES
          I_T_VAR                          = lt_var.
    ENDIF.
    If parameter 'i_hide_sapgui' is empty, I'm getting empty selection-screen,
    If parameter 'i_hide_sapgui' equals 'X' I'm getting selection-screen filled with values, which were used last time manualy, not with values from the internal table 'lt_var'.
    Do you have any idea how to pass parameters to the query with this function module?
    Regards,
    Krzysztof

  • Crystal report based on BW query with two structures

    Hi,
    I use a BW query with 2 structures. In the rows there is a structure of restricted characteristic 0material. I used this characteristics several times in different rows to restrict these rows to specific products.
    Cars
    motorcycles
    Others
    In the columns I have a structure of key figures. Every key figure is restricted to a specific time intervall.
    So in BW the executed query looks like this:
                           Key figure 1         Key figure 2        Key figure 3
      Cars                   10                     30                         100
      motorcycles        20                   100                          30
      Others                30                    40                           39
    If I use the same query in Crystal then I have access to the 3 keyfigures and to one structure element.
    How can I ensure that the query is displayed in CR like in BW? I tried to work with crosstabs but I was not able to get the same display like in BW.
    Thanks for any help.
    BR, Andreas

    Try posting your question to the BW / SAP forum.

  • Using DataSource with MS Access

    is it possible to use the JDBC DataSource with MS Access? Should I download some .class to register with JNDI?

    I've done it with Tomcat, but I've never tried to do it outside of a container. You sound like you want to do it without a servlet or J2EE app server engine acting as the lookup and pool. - MOD

  • Where to find 'Exempt' indicator for reporting using ad-hoc query?

    I want to run report for a count of exempt and non-exempt employees using ad-hoc query with logical database PNPCE. We maintain the exempt/non-exempt flag on the job.
    Thanks
    Manish

    To meet this exact same requirement at my company.  I added an additional table (T5U13) into the logical database. Within transaction SQ02, go to the field group Organizational Assignment, right-click on the field group.  Click Node Extras.  Click Create icon over on the right-hand side of the screen.  Type in the table name T5U13.  Use this select statement:
    SELECT SINGLE * FROM T5U13              
      WHERE STELL                = P0001-STELL
        AND ENDDA                = P0001-ENDDA
    Then add the fields into your field groups.  I also created a local field so I get the word "Exempt" or "Non-Exempt" in my queries instead of "1" or "2" because i can never remember which is which. 
    Hope this helps!

Maybe you are looking for