Solved

PLS-00307: too many declarations of 'TO_CHAR' match this call - WHY???? Whats the fix?

Posted on 2007-04-03
3
9,202 Views
Last Modified: 2013-12-07
Can anyone tell me why the following works:
SELECT  m.value||'\'||'ORA'||ltrim(to_char(p.spid,'00000'))||'.trc'
FROM v$session s, v$process p, v$instance i, v$parameter m  
WHERE m.name = 'user_dump_dest' AND p.addr= s.paddr AND userenv('SESSIONID') = s.audsid
AND s.server='DEDICATED';  

but the following gives me an annoying PLS-00307: too many declarations of 'TO_CHAR' match this call
error:
CREATE OR REPLACE PROCEDURE rssyncit1 IS
location varchar2(255);
BEGIN
   dbms_utility.exec_ddl_statement('alter database backup controlfile to trace');
   SELECT iv.traceloc
    INTO location
    FROM (
      SELECT m.value||'\'||'ORA'||ltrim(to_char(p.spid,'09999'))||'.trc' traceloc
      FROM v$session s, v$process p, v$instance i, v$parameter m
      WHERE m.name = 'user_dump_dest' AND p.addr= s.paddr AND userenv('SESSIONID') = s.audsid
      AND s.server='DEDICATED'
    ) iv;
      insert into mycontrol_files values(location);
   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END rssyncit1;
/


0
Comment
Question by:Robert Silver
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18846122
what about this:

CREATE OR REPLACE PROCEDURE rssyncit1 IS
location varchar2(255);
BEGIN
   dbms_utility.exec_ddl_statement('alter database backup controlfile to trace');
      insert into mycontrol_files
       SELECT m.value||'\ORA'||ltrim(to_char(p.spid,'00000'))||'.trc' traceloc
      FROM v$session s, v$process p, v$instance i, v$parameter m
      WHERE m.name = 'user_dump_dest' AND p.addr= s.paddr AND userenv('SESSIONID') = s.audsid
      AND s.server='DEDICATED'
;
   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END rssyncit1;
/
0
 
LVL 2

Accepted Solution

by:
Robert Silver earned 0 total points
ID: 18846258
Actually I figured out the problem. See I was runing to_char()  on a varchar and not a number.
Odd though that it only fails in a function. My solution was to
change it like so:  Note that I added a, to_number() function to convert the varchar to a number first.
CREATE OR REPLACE PROCEDURE rssyncit1 IS
location varchar2(255);
BEGIN
   dbms_utility.exec_ddl_statement('alter database backup controlfile to trace');
   SELECT iv.traceloc
    INTO location
    FROM (
      SELECT m.value||'\'||'ORA'||ltrim(to_char(to_number(p.spid),'09999'))||'.trc' traceloc
      FROM v$session s, v$process p, v$instance i, v$parameter m
      WHERE m.name = 'user_dump_dest' AND p.addr= s.paddr AND userenv('SESSIONID') = s.audsid
      AND s.server='DEDICATED'
    ) iv;
      insert into mycontrol_files values(location);
   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END rssyncit1;
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question