Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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 Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

773 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