Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update a table using execute immediate

Status
Not open for further replies.

kondakindi

IS-IT--Management
Apr 18, 2005
31
US
Hi,
I have a table with column names as Q_1,Q_2 0 columns till 7etc
I would like to update the table using execute immediate with values from a pl/SQl table
around for 40 lines itsays nothing then says invalid identifier for the set values
.i can't take a the fields statically that is why i am using execute update ...
i tired inserting it for 10 rows it deosn't show any error but doesn't get updated.i commit it after running the pl/sql block

the syntax for the execute immderiate is as follows:
v_element_tab is a pl/sql table which has the mentioned rows and v_row and i and val is also assigned value are declared
when i do a normal static update it works.Could u look at the code and tell me wht is wrong with it

while x <= 20
loop
for i in 1..v_element_tab(v_row).e_count
loop
dbms_output.put_line('row_count'||v_element_tab(v_row).e_count||'element is'||v_element_tab(v_row).element);
dbms_output.put_line('i count'||i);
v_col:='Q_'||x;
EXECUTE IMMEDIATE
'UPDATE REPORT1'||
' SET ' || v_col || ' ='||
v_element_tab(v_row).element ||' where seq_num ='||val;
x:=x+1;
dbms_output.put_line(v_col);
end loop;
v_row:=v_row+1;
end loop;


thanks,
 

Your code is not understandable, you need to supply the full code and the table definition to receive any usefull help. [3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
table structure is of report1 is
app_name varchar2(10),
name varchar2(10),
insert_date date,
session_id varchar2(50),
seq_num number,
Q_1 varchar2(500),
Q_2 varchar2(500),
so on till Q_40

am using a execute immdeiate command though it doesn't show error for first 20 rows it doesn't sucessfully updates the table.
thanks
 
I can't say that I understand your code;
but I suggest you check the structure of the two loops. There is an outer loop for x, and an inner loop for i. Then you increment x in the inner loop. I doubt that this is what you want.
hth
 
Where is val defined/assigned? I suppose that its value is null and comparing against null always returns false thus no rows can be updated according to this criterion. Then, I don't see how your i is involed (besides printing debug information)

P.S. not to offence you but your code is horrible.

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top