Connecting Tech Pros Worldwide Forums | Help | Site Map

data manipulation operation not legal on this view - in a cursor

Newbie
 
Join Date: Oct 2009
Posts: 2
#1: Oct 7 '09
Hi,

I am trying to update a table using cursors...
I have a few if clauses... I just put the first if clause and I am trying to update the table, but it gives me an error saying "data manipulation operation not legal on this view".. so what does this mean???

Here is the code that I wrote

DECLARE
itemnum AtomData.itemnumber%type;
itype AtomData.itemtype%type;
ilength varchar2(20);
ilen varchar2(20);
CURSOR n1 is select length(itemnumber) as ilength, itemnumber, itemtype from ATOMDATA for update;
BEGIN
OPEN n1;
IF n1%ISOPEN THEN
LOOP
FETCH n1 into ilen,itemnum,itype;
EXIT WHEN n1%NOTFOUND;
if itype = '1' AND ilen = '6' THEN
UPDATE ATOMDATA set itemnum = (itemnum|| + '0000000L10') where current of n1 ;
END IF;
END LOOP;
END IF;
END;
/

Please let me know the solution...
best answer - posted by debasisdas
ORA-01732: data manipulation operation not legal on this view
Cause: An attempt was made to use an UPDATE, INSERT, or DELETE statement on a view that contains expressions or functions or was derived from more than one table. If a join operation was used to create the view or the view contains virtual columns derived from functions or expressions, then the view may only be queried.
Action: UPDATE, INSERT, or DELETE rows in the base tables instead and restrict the operations on the view to queries.

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#2: Oct 8 '09

re: data manipulation operation not legal on this view - in a cursor


ORA-01732: data manipulation operation not legal on this view
Cause: An attempt was made to use an UPDATE, INSERT, or DELETE statement on a view that contains expressions or functions or was derived from more than one table. If a join operation was used to create the view or the view contains virtual columns derived from functions or expressions, then the view may only be queried.
Action: UPDATE, INSERT, or DELETE rows in the base tables instead and restrict the operations on the view to queries.
OraMaster's Avatar
Member
 
Join Date: Aug 2009
Location: Pune, India
Posts: 76
#3: Oct 8 '09

re: data manipulation operation not legal on this view - in a cursor


Hi

Please try to make ATOMDATA as an updateable view.
Newbie
 
Join Date: Oct 2009
Posts: 2
#4: Oct 8 '09

re: data manipulation operation not legal on this view - in a cursor


How can I make the view updateable????
OraMaster's Avatar
Member
 
Join Date: Aug 2009
Location: Pune, India
Posts: 76
#5: Oct 9 '09

re: data manipulation operation not legal on this view - in a cursor


Quote:

Originally Posted by Spike1980 View Post

How can I make the view updateable????

Hi

A modifiable join view is a view that contains more than one table in the top-level FROM clause of the SELECT statement, and that does not contain any of the following:

DISTINCT operator
Aggregate functions: AVG, COUNT, GLB, MAX, MIN, STDDEV, SUM, or VARIANCE
Set operations: UNION, UNION ALL, INTERSECT, MINUS
GROUP BY or HAVING clauses
START WITH or CONNECT BY clauses
ROWNUM pseudocolumn
Any UPDATE, INSERT, or DELETE statement on a join view can modify only one underlying base table.

For detail description visit
http://www.oracle-dba-online.com/sql...nage_views.htm
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#6: Oct 15 '09

re: data manipulation operation not legal on this view - in a cursor


Instead of updating the View, try updating the underlying table
Reply