Help with Like Prepared statement

Hi,
Below is a part of the code in my test application which I am using for searching the phone book.
I want to do a pattern search with like, but for some reason, my code is not fetching me the results.
It just gives Zero results.
But if i use "=" it works fine.
I have highlighted the important part
Can you please guide me to correct this code ?
public class DBprgm {
ResultSet result;
public ResultSet getSearch(String a) {
          try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:source", "sa" , "");
Statement st = con.createStatement();
PreparedStatement ps = con.prepareStatement("select from friends where fname like ? ");*
*String x = "%"+a+"%";*
*ps.setString(1, x);*
result = ps.executeQuery();
     catch (SQLException s){
          s.printStackTrace();
     catch (ClassNotFoundException c){
          c.printStackTrace();
     return result;
}

Your code leaks Connections! You create a Connection and never close it, that's a pretty bad idea.
What database are you using? From a quick glance the code seems correct (apart from the problem I mentioned above, of course).
Edit: also, I see that you're using the JDBC-ODBC bridge. That JDBC driver has only very limited functionality and also has a few tiny bugs. Generally I'd strongly suggest that you avoid it and use your databases native JDBC drivers instead. Maybe that's also the problem here, but I can't say for sure.

Similar Messages

  • Need help with the session state value items.

    I need help with the session state value items.
    Trigger is created (on After delete, insert action) on table A.
    When insert in table B at least one row, then trigger update value to 'Y'
    in table A.
    When delete all rows from a table B,, then trigger update value to 'N'
    in table A.
    In detail report changes are visible, but the trigger replacement value is not set in session value.
    How can I implement this?

    You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
    For example
    SELECT YN_COLUMN
    FROM My_TABLE
    INTO My_Page_Item
    WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
    If the value is showing in a report, make sure the report refreshes on reload of the page.
    Edited by: Bob37 on Dec 6, 2011 10:36 AM

  • Help with this update statement..

    Hi everyone,
    I am trying to update a column in a table .I need to update that column
    with a function that takes patient_nbr and type_x column values as a parameter.
    That table has almost "300,000" records. It is taking long time to complete
    almost 60 min to 90 min.
    Is it usual to take that much time to update that many records?
    I dont know why it is taking this much time.Please help with this update statement.
    select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
    (it is just taking 20 - 30 sec)
    I am sure that it is not the problem with my function.
    I tried the following update and merge statements .Please correct me if i am wrong
    in the syntax and give me some suggestions how can i make the update statement fast.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    there is a index on patient_nbr column
    and the statistics are gathered on this table.

    Hi Justin,
    As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 3793814442"
    "| Id  | Operation          | Name             | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | UPDATE STATEMENT   |                  |   274K|  4552K|  1488   (1)| 00:00:18 |"
    "|   1 |  UPDATE            |        TEST_LOAD |       |       |            |          |"
    "|   2 |   TABLE ACCESS FULL|        TEST_LOAD |   274K|  4552K|  1488   (1)| 00:00:18 |"
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 1188928691"
    "| Id  | Operation            | Name             | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
    "|   0 | MERGE STATEMENT      |                  |   274K|  3213K|       |  6660   (1)| 00:01:20 |"
    "|   1 |  MERGE               |        TEST_LOAD |       |       |       |            |          |"
    "|   2 |   VIEW               |                  |       |       |       |            |          |"
    "|*  3 |    HASH JOIN         |                  |   274K|    43M|  7232K|  6660   (1)| 00:01:20 |"
    "|   4 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|  4017K|       |  1482   (1)| 00:00:18 |"
    "|   5 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|    40M|       |  1496   (2)| 00:00:18 |"
    "Predicate Information (identified by operation id):"
    "   3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
    what's the best approach for doing the updates for huge tables?
    Thanks

  • Help changing to prepared statements for mysqli

    I am trying to change previously working php pages from mysql to mysqli using prepared statements.
    I am having problems with an error message.
    Basically the page I have just changed produces a set of database results depending on list menu and check box criteria from user input. I run 2 queries, one to find the total number of records, and the other to retrieve the required subset for pagination. All works fine. However if there are no actual results found from the requested input my php script then uses an includes file which basically runs the same 2 queries but with the user criteria narrowed down so that similar options are presented to the user. This is where my problem lies, for some unknown to me reason the second set of queries is producing no results and an error:
    'Attempt to read a row while there is no result set associated with the statement'
    If I run the second set of queries without running the first set then the second set works fine so I know that it is not the statements themselves but something in my new code. How can the first set of queries be affecting the results of the second set?
    Here is the code below which produces the first 2 queries that work, and below it the same code for the second 2 queries (which is from an 'Includes' file and is the same code exactly except the EXPECTED parameters $expected have been narrowed down in the expected array and list of params for binding).
    //list of possible field input by user
    $expected = array('location'   => 'text',
                      'type' => 'text',
                      'beds' => 'text',
                      'price' => 'text',
    'nbuild'     => 'int',
    'resale'     => 'int',
    'coastal'    => 'int',
    'seaview'    => 'int',
    'rural'      => 'int',
    'golf'       => 'int',
    'ppool'      => 'int',
    'comp'       => 'int',                            
    'garden'     => 'int',
    'terrace'    => 'int',
    'aircon'     => 'int',
    'heating'    => 'int',
    'garage'     => 'int',
    'telephone'  => 'int',
    'furnished'  => 'int',
    'internet'   => 'int',
    'dpaid'      => 'int',
    'propid'     => 'text');
    define('SHOWMAX', 10);
    // prepare SQL to get total records
    $getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $getTotal .= ' AND ';
          } else {
            $getTotal .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $getTotal .= "`$var` LIKE ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $getTotal .= "`$var` $operator ? ";
              break;
            default:
            $getTotal .= "`$var` = ? ";
    $getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($getTotal)) {
    $params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['nbuild'], $_GET['resale'], $_GET['coastal'], $_GET['seaview'], $_GET['rural'], $_GET['golf'], $_GET['ppool'], $_GET['comp'], $_GET['garden'], $_GET['terrace'],
    $_GET['aircon'], $_GET['heating'], $_GET['garage'], $_GET['telephone'], $_GET['furnished'], $_GET['internet'], $_GET['dpaid'], $_GET['propid']);
    $params = array_filter($params);
    $params = array_values($params);
    if (!empty($params)) {
                $types = '';
                foreach($params as $param) {
                    // set param type
                    if (is_string($param)) {
                        $types .= 's';  // strings
                    } else if (is_int($param)) {
                        $types .= 'i';  // integer
                    } else if (is_float($param)) {
                        $types .= 'd';  // double
                    } else {
                        $types .= 'b';  // default: blob and unknown types
                $bind_names[] = $types;
                for ($i=0; $i<count($params);$i++) {
                    $bind_name = 'bind' . $i;      
                    $$bind_name = $params[$i];     
    $bind_names[] = &$$bind_name;  
    call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($total);
    $stmt->fetch();
    // sort paging
    $totalRecords = $total;
    $stmt->free_result();
    $stmt->close();
    // check that there is at least 1 result and if there is do the second part of the search
    // if there is no result then I skip this second bit of code
    if($totalRecords > '0') {
    // check current page
    if (isset($_GET['curPage'])) {
    $curPage = $_GET['curPage'];
    } else {
    $curPage = 0;
    // calculate the start row of the subset
    $startRow = $curPage * SHOWMAX;        
    $sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $sql .= ' AND ';
          } else {
            $sql .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $sql .= "`$var` LIKE  ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $sql .= "`$var` $operator ? ";
              break;
            default:
            $sql .= "`$var` = ? ";
    $sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($sql)) {
    $nextparams = $params;
    if (!empty($nextparams)) {
                $nexttypes = '';
    foreach($nextparams as $nextparam) {
                    // set param type
                    if (is_string($nextparam)) {
    $nexttypes .= 's';  // strings
                    } else if (is_int($nextparam)) {
    $nexttypes .= 'i';  // integer
                    } else if (is_float($nextparam)) {
    $nexttypes .= 'd';  // double
                    } else {
    $nexttypes .= 'b';  // default: blob and unknown types
                $newbind_names[] = $nexttypes;
                for ($i=0; $i<count($nextparams);$i++) {
    $newbind_name = 'bind' . $i;      
    $$newbind_name = $nextparams[$i];
    $newbind_names[] = &$$newbind_name;
    call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
    $numRows = $stmt->num_rows;
    If a result was found in the part that checks the numbers of records then the second query is run and displayed using : while ($stmt->fetch()) { ...... to display the results and then I use $stmt->free_result();
    $stmt->close();
    All fine no problems.
    If the first query did not find a result then the second query is skipped and instead the script then uses a php includes file with exactly the same script as above except the expected params are narrowed as below: THIS IS WHEN I GET NO RESULTS – when I do expect to get a result) AND AN ERROR OF :
    Attempt to read a row while there is no result set associated with the statement.
    Yet if I run the includes file and skip the whole of the above code the code in the includes file find the result no problem. Anyway code below:
    $expected = array('location'   => 'text',
                      'type' => 'text',
                      'beds' => 'text',
                      'price' => 'text',
    'dpaid'      => 'int',
    'propid'     => 'text');
    define('SHOWMAX', 10);
    // prepare SQL to get total records
    $getTotal = 'SELECT COUNT(*) FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ';
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $getTotal .= ' AND ';
          } else {
            $getTotal .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $getTotal .= "`$var` LIKE ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $getTotal .= "`$var` $operator ? ";
              break;
            default:
            $getTotal .= "`$var` = ? ";
    $getTotal .= ' ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC';
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($getTotal)) {
    $params = array($_GET['location'], $_GET['type'], $_GET['beds'], $_GET['price'], $_GET['dpaid'], $_GET['propid']);
    $params = array_filter($params);
    $params = array_values($params);
    if (!empty($params)) {
                $types = '';
                foreach($params as $param) {
                    // set param type
                    if (is_string($param)) {
                        $types .= 's';  // strings
                    } else if (is_int($param)) {
                        $types .= 'i';  // integer
                    } else if (is_float($param)) {
                        $types .= 'd';  // double
                    } else {
                        $types .= 'b';  // default: blob and unknown types
                $bind_names[] = $types;
                for ($i=0; $i<count($params);$i++) {
                    $bind_name = 'bind' . $i;      
                    $$bind_name = $params[$i];     
    $bind_names[] = &$$bind_name;  
    call_user_func_array(array(&$stmt,'bind_param'),$bind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($total);
    $stmt->fetch();
    // sort paging
    $totalRecords2 = $total;
    echo $stmt->error;
    $stmt->free_result();
    $stmt->close();
    // there is a result get the subset
    if($totalRecords2 > '0') {
    // check current page
    if (isset($_GET['curPage'])) {
    $curPage = $_GET['curPage'];
    } else {
    $curPage = 0;
    // calculate the start row of the subset
    $startRow = $curPage * SHOWMAX;        
    $sql = "SELECT DISTINCT detailsid, trueprice, reduced, offers, `desc`, `propid`, `bathrooms`, `location`, `type`, `price`, `beds`, photossale.photo1, newloctable.newloc,   typetable.style, bedtable.`number` FROM detailstable JOIN newloctable ON detailstable.location=newloctable.newlocid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid JOIN photossale ON detailstable.detailsid=photossale.propsaleid ";
    // Set a flag to indicate whether the query has a WHERE clause
    $where = false;
    // Loop through the associatiave array of expected search values
    foreach ($expected as $var => $type) {
      if (isset($_GET[$var])) {
        $value = trim(urldecode($_GET[$var]));
        if (!empty($value)) {
          // Check if the value begins with > or <
          // If so, use it as the operator, and extract the value
          if ($value[0] == '>' || $value[0] == '<') {
            $operator = $value[0];
            $value = ltrim(substr($value, 1));
          } elseif (strtolower($type) != 'like') {
            $operator = '=';
          // Check if the WHERE clause has been added yet
          if ($where) {
            $sql .= ' AND ';
          } else {
            $sql .= ' WHERE ';
            $where = true;
          // Build the SQL query using the right operator and data type
           $type = strtolower($type);
          switch($type) {
            case 'like':
              $sql .= "`$var` LIKE  ? ";
              break;
            case 'int':
            case 'double':
            case 'date':
              $sql .= "`$var` $operator ? ";
              break;
            default:
            $sql .= "`$var` = ? ";
    $sql .= " ORDER BY ABS(detailstable.trueprice), bedtable.number, detailstable.propid ASC LIMIT $startRow," . SHOWMAX;
    $stmt = $conn->stmt_init();
    if ($stmt->prepare($sql)) {
    $nextparams = $params;
    if (!empty($nextparams)) {
                $nexttypes = '';
    foreach($nextparams as $nextparam) {
                    // set param type
                    if (is_string($nextparam)) {
    $nexttypes .= 's';  // strings
                    } else if (is_int($nextparam)) {
    $nexttypes .= 'i';  // integer
                    } else if (is_float($nextparam)) {
    $nexttypes .= 'd';  // double
                    } else {
    $nexttypes .= 'b';  // default: blob and unknown types
                $newbind_names[] = $nexttypes;
                for ($i=0; $i<count($nextparams);$i++) {
    $newbind_name = 'bind' . $i;      
    $$newbind_name = $nextparams[$i];
    $newbind_names[] = &$$newbind_name;
    call_user_func_array(array(&$stmt,'bind_param'),$newbind_names);
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($detailsid, $trueprice, $reduced, $offers, $desc, $propid, $bathrooms, $location, $type, $price, $beds, $photo1, $newloc, $style, $bednumber);
    $numRows = $stmt->num_rows;
    Again here I would then display the results before closing and freeing the stmt or display a message to say there were no results found from the criteria. But instead I get the error message and echoing the value of $totalRecords2 is empty.
    I have been pulling my hair out for days and days over this and as it is one of the first pages I am converting from mysql to mysqli I wonder if I am missing something very obvious to someone with more experience with the code.  I will be very grateful for any help, thank you in advance.

    You have intel graphics, that means the graphics cannot be upgraded.
    Welcome to the Toshiba user forums.
    For those of you who do not know what a user forum is, it is a community of users who volunteer time to help other users. Anyone can participate. It's 100% voluntary.
    Being super active is never a requirement

  • Problem with Oracle Prepared Statement

    Hi all,
    Please help me..
    I Have 2 pages, in first page i had table with rows with update image for each row, when i click update it leads to 2nd page which shows the particular row information
    my problem is, i am executing prepared statement with 2 parameters in 2nd page controller which is working fine first time, when i go to first page and comes to 2nd page again my
    result set showing Null, some times query executing and getting results, some times null, i am confused with this behaviour. please help me ..
    Thanks all

    Hi ,
    How your table is being popluated ? You have executed VO in PR or PFR ?
    Please give snippet of your CO code , both after navigating from first page to second and again after coming back to first page .
    Also is same AM is retain or not ?

  • Can any body Help me to prepare statement

    I want to provide dynamic table name for preparestatement that i just pass table name every time and it pass me total number in that table.
    I create this prepare statement
    PreparedStatement prepStmt=conn_.prepareStatement("select count(*) Total from ?");
    prepStmt.setString(1,"new");
    but it is giving error
    [JDBC SQL Server Driver] Line 1: Incorrect syntax near 'new'.
    Any body can help me??
    I will appreciate.

    In PreparedStatement, the setString method adds quotes at the start and at the end of your String.
    So your request :
    select count(*) Total from ?
    is interpreted :
    select count(*) Total from 'new'
    One possible solution is to pass your tablename parameter directly in the precompiled request :
    String myTableName = "new";
    PreparedStatement prepStmt=conn_.prepareStatement("select count(*) Total from "+myTableName);
    In your database, you will store as many precompiled Statement as you will call this method with different parameters.
    Hope it helps !

  • Batch updates with callable/prepared statement?

    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797 states
    that "Using Batch updates with the callableStatement or preparedStatement is
    not supported". What does that actually mean? We have used both callable and prepared
    statements with the batch update in our current project (with the Oracle 817 db).
    It seems to run ok anyway.

    So the documentation should state that batch updates do not work ok in old versions
    of JDriver for Oracle, BUT work correctly with newer version. Additionally, batch
    updates work ok when used with Oracle supplied jdbc-drivers?
    "Stephen Felts" <[email protected]> wrote:
    Support for addBatch and executeBatch in the WLS Jdriver for Oracle was
    added in 7.0SP2.
    It was not available in 6.X or 7.0 or 7.0SP1.
    "Janne" <[email protected]> wrote in message news:3edb0cdc$[email protected]..
    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797
    states
    that "Using Batch updates with the callableStatement or preparedStatementis
    not supported". What does that actually mean? We have used both callableand prepared
    statements with the batch update in our current project (with the Oracle817 db).
    It seems to run ok anyway.

  • Looking for some help with building insert statements...

    Hi, I am using some sql to build some insert statements for me to update a set of tables in our qa environments. The scripts that I have created were working great until someone added a column to some of the tables in the qa env which in turn makes my scripts break because I was simply building the statment to do someting like this...
    insert into dest_table (select * from source_table@dblink);
    But now when the coumns in the tables do not match it breaks...
    This is the dynamic create script I use, can anyone help or suggest a better way to be able to build update statements update to qa tables when the columns are mismatched?
    spool insert.sql
    select
    'insert into ' || table_name || ' (select * from ' || table_name || '@prod );' || chr(10) || ' commit;'
    from user_tables
    where table_name in
    (select * from refresh_tablesl)
    any help is greatly appreciated,
    Thanks.

    See my reply to your duplicate post
    looking for help building dynamic insert statements...

  • Help with a CASE statement

    Please help me with a CASE Statement:
    - When ID = 15, 16, 17, 18 then "Bad"
    - when ID = 19, then "Average"
    - when ID = 21, then "Good"
    - else "Null"
    Thank you!!

    Well the 1st thing to do would be to correct my poor spelling... change    Delault : to Default :
    Don't know why you would get an error stating "The result of selection formula must be a boolean". It's working fine on my machine.
    If your ID field is numbers stored text you have a couple different options...
    1) Convert the ID to a number...
    Select  ToNumber({home.noone_ID})
    2) Wrap the ID values in double quotes...
       Case "15", "16", "17", "18" :
          "BAD"
    Even if this were your problem... the error should be something other than the boolean thing...
    Jason

  • Help with like in sql

    Hi all,
        I am having an issue with like statement with full text search
    My data : BEAN PEELER
     SQL STATEMENT:  Select * from table where col1 like '%[^a-z]peeler[^a-z]%' 
    doesn't give all the results which has peeler in it (for example the above example)
    instead if i use this statement
     Select * from table where col1 like '%peeler%' it returns all the rows.
    But, i need to check the exact word search and not subset of it.
    My problem is how is my query able to detect few rows which has peeler in it but not all?  please help

    so did you try this?
    declare @tab table(
    val varchar(50));
    insert into @tab values
    ('BEAN PEELER'),
    ('PEELERRRRR'),
    ('SOMPEERLER');
    Select * from @tab where val like 'peeler' or VAL like '% Peeler %' or val like '% Peeler'
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Help with a return statement please!

    hey, just hoping somone can help me with this return statement
    i have to add a method called "specialReport" this method takes a year as it's parameter. if the parameter is not a year between 1930 and 1969 inclusive it displays an error message, "not a valid year"
    if the parameter is a valid year, then it compares the parameter with the year field. if they are the same, and is the movie has been rented at least five times, the method will display the message "a good year for movies" if the years are different or the movie has NOT been rented at least five times, the method displays the message "try a different year"
    btw, the Year field is : yearReleased
    all help is very much appreciated!

    public void specialReport(int year){
       //add functionality to process here
       return;
    }

  • How to use in clause with variable elements with a prepared statement?

    Is there any way to use a prepared statement for a query which incorporates an in clause with unknown number of elements in the list?
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Iraj ():
    Is there any way to use a prepared statement for a query which incorporates an in clause with unknown number of elements in the list?<HR></BLOCKQUOTE>
    Sorry, can't be done. The PreparedStatement is precomplied, so you can't have variable number of params or unknown number of elements in a list.

  • Help with multiple case statements

    Hello,
    I am new to BO.  I am on XI 3.0.  SQL 2005.  In Designer, I am trying to create a measure in a financial universe that would end up being multiple case statements within one select.  This is what I tried to do, but it doesn't work with the two case statements.  Can I use an ELSE leading into the second CASE WHEN somehow?  How can I accomplish this?  Sorry for my ignorance!
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 12 THEN dbo.ClientBudgetMonth.Stage1Sales END
    CASE WHEN  dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 11 THEN dbo.ClientBudgetMonth.Stage1Sales END
    Any Suggestions?
    Thanks,
    Holly

    Holly,
    I don't know enough about your data or requirement to provide a solution, however, the construct that you post will not work because it causes you to build an object with multiple case statements when only one case statement per object is permitted.  From what I see in your code I would be inclined to combine the two statements into one as such:
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month in (11,12) THEN dbo.ClientBudgetMonth.Stage1Sales else null END
    Thanks,
    John

  • Help with a select statement from a SQL Server within a DTS !!

    Hello Gurus!
    I help with the script bellow, when I run it within DTS (in SQL Sever 2000), I got the error Invalid number/or not a valid month.
    Please bellow with the WHERE CLASUE '08/01/2001' AND '03/09/2002'
    And in the other hand I change this forma to '01-AUG-01' AND
    '03-MAR-2002', the DTS start and run witha successful messages, but it does not returns row, which is wrong.
    Somebady please help!
    Thanks Gurus!
    GET Total ANIs with Trafic By Area Code
    select
         substr(b.ct_num, 0,3) as Area_Codes,
         COUNT(DISTINCT B.CT_NUM) AS ANIS
    from
         wasabi.v_trans A,
         wasabi.V_Sur_Universal B,
         wasabi.V_Sub C,
         wasabi.V_Trans_Typ D
    where
         D.Trans_typ = A.Trans_Typ AND
         A.Sur_ID = B.Sur_ID AND
         C.Sub_ID = A.Sub_ID AND
         a.trans_stat != 'X' AND     
         a.Trans_DTTM >= '08/01/2001'AND
         a.Trans_DTTM < '03/09/2002 AND
         B.AMA3 = 'PHONE1'
         AND C.SUB_ID not in (100117)
    GROUP BY
         substr(b.ct_num, 0,3)
    ORDER BY
         Area_Codes

    I think that you need a "to_date" function eg
    change '08/01/2001' to to_date('08/01/2001','dd/mm/yyyy')

  • Kindly help me out with this prepared statement

    Hi All,
    I am having some problem with this code.The databaseUsername and databasePassword seem to be printing only null, what could be the problem.
    AFIAK, it is not going into the while loop itself.
    Help would be greatly appreciated.
    TIA
    AS
    try {
                  String sql = "SELECT username, password FROM admintable WHERE username = ? AND password = ?";
                PreparedStatement stmt = null;
                ResultSet rs = null;
                stmt=con.prepareStatement(sql);
                stmt.setString(1, username);
                stmt.setString(2, password);
                rs = stmt.executeQuery();
                String databaseUsername = null;
                String databasePassword = null;
                while (rs.next()){
                    databaseUsername=rs.getString("username");
                    databasePassword=rs.getString("password");
                     System.out.println("Values are Username " + databaseUsername);
                     System.out.println("Values are Password "+ databasePassword);
                 rs.close();
                 stmt.close();

    Hi Again,
    I would like to tell that there is only one entry in the database table.
    String sql = "SELECT username, password FROM professorforminfo.admintable WHERE username = ? AND password = ?";
                PreparedStatement stmt = null;
                ResultSet rs = null;
                stmt=con.prepareStatement(sql);
                stmt.setString(1, username);
                stmt.setString(2, password);
                rs = stmt.executeQuery();
                String databaseUsername = null;
                String databasePassword = null;
                while (rs.next()){
                    databaseUsername=rs.getString("username");
                    databasePassword=rs.getString("password");
                     System.out.println("Username value " + databaseUsername);
                     System.out.println("Password value "+ databasePassword);
                  }catch(SQLException sqlEx){
                       System.err.println("Unable to connect to DB");
                       sqlEx.printStackTrace();
                 rs.close();
                 stmt.close();Why do you think that the databaseUsername and databasePassword has null values in them.
    Kindly help me out.
    Thanking you
    AS

Maybe you are looking for

  • [SOLVED] ATI HD5650M + radeon +opengl=crash

    Hi to everyone, as the title says i'm having some strange problems with my ATI HD 5650M using the radeon open source drivers. The problem arises randomly when i try to use the opengl hardware acceleration and also when using vdapau. The screen sundde

  • Proxy Settings Are Lost

    I have several Mac clients that run OS X (10.6-10.8) and all are configured to access the internet via the same proxy server. Within System Preferences, each user has their proxy server login details saved - no problem there. Periodically (and not do

  • EREC - ASSIGN_BASE_TOO_SHORT error

    Hi All, At a client, they want to enlargen the data model of e-rec. This means adding fields to the standard SAP tables. For example HRP5125. I created append structures to do this (best practice as far as I know). On activation, there are no problem

  • Annoying little white line on letterbox matte.

    When I scrub throught footage or if I hit play little white lines apear on the edges of the letterbox png. How can I stop this? * It doesn't appear on the final result * It stops me from seeing exactly how it will look http://gyazo.com/2d532cefc76dcd

  • Operating and Non-operating temperatures for iPhone 5s

    For all iPhones it is mentioned as below - Nonoperating temperature: −4° to 113° F (−20° to 45° C) Operating ambient temperature: 32° to 95° F (0° to 35° C) Above info is mis-leading. So which is  the temperature for optimal usage if all temperatures