Solved

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

Posted on 2007-04-03
3
9,036 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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now