sql - Incomplete/Malformed cursor -


i have pl/sql script perform aggregation tasks. having compilation errors, logic not top priority @ moment can changed once errors resolved. script follows :

set serveroutput on; alter session set nls_date_format = 'dd-mon-yy'; create or replace procedure updatefeatureperformancetable     (noofdays in number, rundate in date, timespan in varchar2)     cursor c_feature_performance          select distinct mkt_id,dow,device_type,feature_name          gfmdev.feature_performance          timespan = 'one_day'          , feature_performance_day >= to_date('17-aug-15','dd-mon-yy');     rowsextracted c_feature_performance%rowtype;     extractdate date;     timespan_test varchar2(20); begin     open c_feature_performance;     extractdate := rundate - noofdays;     timespan_test := timespan;     loop         fetch c_feature_performance rowsextracted;         exit when c_feature_performance%notfound;          dbms_output.put_line(extractdate || ' ' || timespan_test);          insert gfmdev.feature_performance         select               rowsextracted.mkt_id,             rowsextracted.dow,             rowsextracted.device_type,             rowsextracted.feature_name,             sum(ops),             sum(gv_count),             rundate,             timespan_test        gfmdev.feature_performance          feature_performance_day between extractdate , rundate      , timespan = 'one_day'     , mkt_id = rowsextracted.mkt_id     , dow = rowsextracted.dow     , device_type = rowsextracted.device_type     , feature_name = rowsextracted.feature_name     group mkt_id, dow, device_type, feature_name, timespan;        end loop; close c_feature_performance; exception     when too_many_rows         dbms_output.put_line('trying insert many rows in select...into');         rollback;     when no_data_found         dbms_output.put_line('no rows returned in select...into');         rollback;     when storage_error         dbms_output.put_line('too data handle! storage error');         rollback;     when others         dbms_output.put_line('oops! went wrong');         rollback;         raise;        end updatefeatureperformancetable; 

show compilation errors:

show errors procedure updatefeatureperformancetable; 

run procedure:

declare     rundate date; begin j in 0 .. 5 loop     select (to_date('17-aug-15','dd-mon-yy') + j) rundate dual;     updatefeatureperformancetable(6,rundate, 'one_week'); end loop; dbms_output.put_line(' weekly records updated '); j in 0 .. 28 loop     select (to_date('17-aug-15','dd-mon-yy') + j) rundate dual;     updatefeatureperformancetable(29,rundate, 'one_month'); end loop; dbms_output.put_line(' monthly records updated '); commit; end; / 

when execute following error message :

errors procedure updatefeatureperformancetable:  line/col error -------- ----------------------------------------------------------------- 4/9      pls-00341: declaration of cursor 'c_feature_performance'      incomplete or malformed  5/3      pl/sql: sql statement ignored 6/15     pl/sql: ora-00942: table or view not exist 8/16     pl/sql: item ignored 16/3     pl/sql: sql statement ignored 16/36    pls-00320: declaration of type of expression      incomplete or malformed  21/3     pl/sql: sql statement ignored  line/col error -------- ----------------------------------------------------------------- 36/22    pl/sql: ora-00904: "rowsextracted"."feature_name": invalid      identifier  36/22    pls-00320: declaration of type of expression      incomplete or malformed              updatefeatureperformancetable(6,rundate, 'one_week');             * 

any on going wrong highly appreciated?

pl/sql framework running sql statements programmatically. find pl/sql errors caused sql errors in our code.

that case here. have several pl/sql errors indicating cursor declaration invalid. , why invalid? line holds answer:

6/15     pl/sql: ora-00942: table or view not exist 

so problem is, owner of procedure updatefeatureperformancetable (ugly name way) not have rights on gfmdev.feature_performance.

to solve, table owner gfmdev needs grant select , insert directly account owns procedure.

sql>  conn gfmdev/password sql>  grant select, insert on feature_performance whoever; 

note granting privileges through view won't cut it. oracle security model permits build objects - pl/sql programs, views - privileges granted directly our user.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -