Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PLS-00382: expression is of wrong type

480544Feb 2 2007 — edited Feb 2 2007
All, below is a procedure from a package by Connor McDonald, and for the life of me I cannot work out why the execute immediate line will not compile, giving the above error.

If I populate a varchar2 variable with the conacatenated string and then execute immediate the string it's fine, but it doesn't like me doing it directly in the execute immediate. I've narrowed it down to this part of the concatenation -> substr(x.param, j) but I've no idea why it fails.

Any ideas? It's not desparately urgent as I have a workaround as I said above, but I'm curious if anyone else has seen a similar problem.

PROCEDURE update_skip_count(p_count IN NUMBER DEFAULT 0, reset BOOLEAN DEFAULT FALSE) AS
-- update access parameters of external table
i NUMBER;
j NUMBER;
adj NUMBER := p_count;

BEGIN
FOR x IN (SELECT REPLACE(access_parameters, chr(10)) param
FROM user_external_tables
WHERE table_name = 'ALERT_FILE_EXT')
LOOP

i := owa_pattern.amatch(x.param, 1, '.*skip', i);
j := owa_pattern.amatch(x.param, 1, '.*skip \d*');

-- to reset the count (to zero)
IF reset
THEN
adj := -1 * to_number(substr(x.param, i, j - i));
END IF;

EXECUTE IMMEDIATE 'alter table alert_file_ext access parameters (' ||
substr(x.param, 1, i) || (to_number(substr(x.param, i, j - i)) + adj) ||
substr(x.param, j) || ')';

END LOOP;
END;


Thanks
Graham

p.s. if it loses formatting during posting, my apologies.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2007
Added on Feb 2 2007
8 comments
1,725 views