empty dataset from search form in Scriptcase

Hi all,
hope you’r doing well… i need some advice about something i’m trying to do with scriptcase. I have a search form that calls a single row form. Search criteria is set to only “equal to” and if the input is not complete it doesnt call any row from the db. Ex: search by phone no. user should enter the complete no. not just 2-3 digits. Now what i want, when the input is not complete, is to show a error message… not go to the form!

I tried something with the redirect macro:
** $check_table = ‘xts_cards’; // Table name
$check_where = “xts_cards.CARD_NO = ‘{CARD_NO}’”; // Where clause

       // Check for record
  $check_sql = 'SELECT *'
    . ' FROM ' . $check_table
    . ' WHERE ' . $check_where;
      sc_select(dataset, $check_sql);

    if (false == {dataset})
  {
     sc_redir('search_cards', "", "_self"); // Error while accessing database
    }else
      {
         // Record found
       }; **

… but no luck… :frowning:

Does anyone have an idea what should i do?!?

Thanks a lot!!!

Re: empty dataset from search form in Scriptcase

/**

  • Check for an existing record
    */

// SQL statement parameters
$check_table = ‘my_table’; // Table name
$check_where = “field = ‘condition’”; // Where clause

// Check for record
$check_sql = ‘SELECT *’
. ’ FROM ’ . $check_table
. ’ WHERE ’ . $check_where;
sc_select(dataset, $check_sql);

if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
// No record found
}
else
{
// Record found
}

This is the complete check. You have to put your sc_redir in the ELSEIF

Re: empty dataset from search form in Scriptcase

Hey it works :slight_smile: thanks! …but there is a little problem… at the beginning in the search form, it shows "Error
Undefined variable: card_no " :frowning:
How can i take it away??

Re: empty dataset from search form in Scriptcase

You have to go to Application - Global Variable and set it to OUT