Announcement

Collapse
No announcement yet.

Undefined offset: 0

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Undefined offset: 0

    I use the same script on OnBeforeUpdate and OnBeforeInsert events.
    In both cases I have Error "Invalid Item!", but on onBeforeInsert I have also additional Error "Undefined offset: 0".

    Below is the script I used.

    sc_lookup(dataset, "select arbecd from CWMUDTA.initem where arcomp={M0COMP} and arbecd='{M0ITEM}'");

    if (!{dataset[0][0]})
    {
    sc_error_message("Invalid Item!");
    }

  • #2
    Re: Undefined offset: 0

    Several things to look at:

    -echo your SQL statement to the form and see if it is valid.
    -copy the echo'd statement to your DB manager and execute .. do you get a result?

    Here is the code I used in projects:

    $sql = 'SELECT ....';
    sc_lookup(tbl_items,$sql);

    if ({tbl_items} == false || empty({tbl_items}) ) {
    return false;
    } else {
    return {tbl_items[0][0]} > 0 ? true : false;
    }

    Regards,
    Scott.

    Comment


    • #3
      Re: Undefined offset: 0

      It`s probably a problem with {dataset[0][0]}. It`s returns no value so you got a message undefined offset
      try:

      if (empty({dataset}))
      {
      sc_error_message("Invalid Item!");
      }

      Comment

      Working...
      X