oracle-sqldeveloperoracleformsora-00001

oracle forms 10g runtime timeout


i have this code in a when-validate-item trigger

declare
x number;
c varchar2(5);
n varchar2(25);
begin
select COUNT(*) into x from CUSTOMERS where CUSTOMERS.cus_name=:output_header.text_item48;
if x > 0
  then
  NULL;
else
  IF SHOW_ALERT('ALERT56')= ALERT_BUTTON1 THEN
  select to_char(max(customers.cus_id)+1) into c from customers;
  n:=to_char(:output_header.text_item48);
  insert into customers(cus_id,cus_name) values(c,n);
  end if;
END IF;
end;'

this code should check if the customer name entered already exists , if NOT i want to create a new customer the problem is when i press the alert button1,, instead of inserting a new customer(record) into the customers table , the form become not responding for ever can you please help me the problem is in the insert statement; thanks in advance


Solution

  • Seems :output_header.text_item48 is already a char item so no need to convert using to_char, test with the following code:

    declare
    x number;
    c varchar2(5);
    n varchar2(25);
    begin
    select COUNT(*) into x from CUSTOMERS where CUSTOMERS.cus_name=:output_header.text_item48;
    if x > 0
      then
      NULL;
    else
      IF SHOW_ALERT('ALERT56')= ALERT_BUTTON1 THEN
      select to_char(max(customers.cus_id)+1) into c from customers;
      n:= :output_header.text_item48;
      insert into customers(cus_id,cus_name) values(c,n);
      commit;
      end if;
    END IF;
    end;