Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-04-03
3
Medium Priority
?
9,799 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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