Home » Developer & Programmer » Forms » DATA INSERT PROBLEM
DATA INSERT PROBLEM [message #274873] Wed, 17 October 2007 08:53 Go to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

i developed form for user permissions.
for the first time assigning permission.Save works well(e.g for user AJX).
Am manually inserting data like..
first_record
loop
insert into AAA...
VALUES....
exit when :system.last_record="TRUE'
next_record;
end loop;
COMMIT;

now problem is that when second time i change any permission
for AJX like add some new Permission delete any previous one ..it again save all records ..rather then just saving changed data on form..
I think i am clear enough...
How to handle this (LIKE default saving functionality on default form menu or simple commit_form)..
Doing this manually ...
Forms6i used ..

[Updated on: Wed, 17 October 2007 09:06]

Report message to a moderator

Re: DATA INSERT PROBLEM [message #274932 is a reply to message #274873] Wed, 17 October 2007 14:19 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Check whether the "permission" (what permission?) has changed or not. If it has, insert new record (or update existing one). If not, do nothing. For example
SELECT permission INTO l_permission FROM aaa
  WHERE some_id_column = :block.some_id_column;

IF l_permission = :block.permission
THEN
   NEXT_RECORD;
ELSE
   INSERT INTO aaa (column_list) VALUES (...);
   -- or, would you rather use 
   -- UPDATE aaa SET permission = :block.permission
   --   WHERE some_id_column = :block.some_id_column;
END IF;


Re: DATA INSERT PROBLEM [message #274977 is a reply to message #274932] Thu, 18 October 2007 00:09 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

But problem is for the first most time ..
there will be no permission found for specific user in table.
so this query will return nothing first time ..
i think ..
but let me try it ..
Re: DATA INSERT PROBLEM [message #274979 is a reply to message #274932] Thu, 18 October 2007 00:43 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

For a new brand user having no permission..and trying to assign permission to him first time ..
on save
this query returning nothing ..
so ORA-01403..raising..
So is this better to write insert code for first time user in
When no_data_found 

I Don`t think So..

[Updated on: Thu, 18 October 2007 00:46]

Report message to a moderator

Re: DATA INSERT PROBLEM [message #274993 is a reply to message #274979] Thu, 18 October 2007 01:14 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
OK, so handle the exception!
BEGIN
  BEGIN
    SELECT permission INTO l_permission FROM aaa
      WHERE some_id_column = :block.some_id_column;

  EXCEPTION
    WHEN NO_DATA_FOUND THEN
      INSERT INTO aaa (column_list) VALUES (...);
  END;

  IF l_permission = :block.permission
  THEN
     NEXT_RECORD;
  ELSE
     UPDATE aaa SET permission = :block.permission
       WHERE some_id_column = :block.some_id_column;
  END IF;
END;
Re: DATA INSERT PROBLEM [message #275051 is a reply to message #274993] Thu, 18 October 2007 03:09 Go to previous message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

It`s working thanks..
Previous Topic: Adding a new line in a word document using ole2
Next Topic: set_menu_itme_property
Goto Forum:
  


Current Time: Sat Dec 03 14:01:42 CST 2016

Total time taken to generate the page: 0.09764 seconds