'I m inserting my data uthrough page item using request process it gives an error fetch more then one row please give me a solution

var a = $v('P1995_LUMBER');
if ((a = '1')) {
  apex.submit({
    request: "CREATE",
    set: {
      LUMBER: "P1995_LUMBER",
      LST_NME: "P1995_LST_NME",
      FST_NME: "P1995_FST_NME",
    },
  });
} else if (a != '1') {
  apex.submit({
    request: "Update",
    set: {
      LUMBER: "P1995_LUMBER",
      LST_NME: "P1995_LST_NME",
      FST_NME: "P1995_FST_NME",
    },
  });
} else {
  alert("bang bang");
}


Solution 1:[1]

That code does not have any sql in it so it is impossible to diagnose why you are encountering a TOO_MANY_ROWS exception. Run the page in debug mode and check the debug data - it should show you what statement is throwing the exception. If you need more help, post a proper reproducible case, not a single snipped of code without any context.

Solution 2:[2]

Couple of things:

  1. JavaScript's equality check is either == or === (more details here). (a = '1') assign '1' to the variable.
  2. It seems like you're not using the apex.submit process correctly. Typically, you would set the item's value e.g.:
apex.page.submit({
    request: "SAVE",
    set: {
        "P1_DEPTNO": 10,
        "P1_EMPNO": 5433
    }
} );

Although, by looking at your JavaScript code, I would say you don't even need to use JavaScript.

Whenever you submit a page, all items on it are automatically sent to the server-side. You can then reference them using bind variables. You could then simply have two process, one for the Create and one for the Update, each having the corresponding insert/update statement using the different items on your page.

Usually what you will see is a page with two buttons for Create/Edit. They will have a server-side condition so that only the correct one is displayed.

Try creating a Form type page (form with report) using the wizard, and you'll see how everything is done.

Without seeing the page and the code you're using it's hard to tell what your issue really is, more details would be required.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Koen Lostrie
Solution 2 askMax - Maxime Tremblay