Home > Archive > Other Oracle database topics > April 2006 > ORA-06521: PL/SQL: Error mapping function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ORA-06521: PL/SQL: Error mapping function
mukesh bhakta

2006-04-08, 3:23 am

Hi all,

I am writing a C/C++ code using MSDEV 2003 and get the

SQL> exec shell('dir');
BEGIN shell('dir'); END;

*
ERROR at line 1:
ORA-06521: PL/SQL: Error mapping function
ORA-06522: Unable to load symbol from DLL
ORA-06512: at "SYS.SHELL", line 1
ORA-06512: at line 1

when trying to run it from SQL Plus.

Here the dump of my source code -

extern "C" __declspec(dllexport
) void shell(const char *cmd)
{
printf("test\n");
}

I have used dependency walker and dumpbin to make sure my call is not
mangled up.

Here are the SQL statements -

CREATE LIBRARY shell_lib is
'C:\mbhakta\playgrou
nd\oraProc\oraProc\D
ebug\oraProc.dll';
/

create or replace procedure shell(cmd IN char)
as external
library shell_lib
name "shell"
language C
parameters (cmd string);
/

I have also modifed the Listenrer.Ora to follows -




SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10
.2.0\db_1)
(PROGRAM = extproc)
(ENVS=" EXTPROC_DLLS=C:\oraP
roc\Debug\oraProc.dll")
)
(SID_DESC =
(GLOBAL_DBNAME = x)
(SID_NAME = x)
)
)

Sybrand Bakker

2006-04-08, 3:23 am

On 7 Apr 2006 19:04:15 -0700, "mukesh bhakta"
< mukesh_bhakta@hotmai
l.com> wrote:

>Hi all,
>
>I am writing a C/C++ code using MSDEV 2003 and get the
>
>SQL> exec shell('dir');
>BEGIN shell('dir'); END;
>
>*
>ERROR at line 1:
>ORA-06521: PL/SQL: Error mapping function
>ORA-06522: Unable to load symbol from DLL
>ORA-06512: at "SYS.SHELL", line 1
>ORA-06512: at line 1
>
>when trying to run it from SQL Plus.
>
>Here the dump of my source code -
>
>extern "C" __declspec(dllexport
) void shell(const char *cmd)
>{
> printf("test\n");
>}
>
>I have used dependency walker and dumpbin to make sure my call is not
>mangled up.
>
>Here are the SQL statements -
>
>CREATE LIBRARY shell_lib is
> 'C:\mbhakta\playgrou
nd\oraProc\oraProc\D
ebug\oraProc.dll';
>/
>
>create or replace procedure shell(cmd IN char)
>as external
>library shell_lib
>name "shell"
>language C
>parameters (cmd string);
>/
>
>I have also modifed the Listenrer.Ora to follows -
>
>
>
>
>SID_LIST_LISTENER =
> (SID_LIST =
> (SID_DESC =
> (SID_NAME = PLSExtProc)
> (ORACLE_HOME = C:\oracle\product\10
.2.0\db_1)
> (PROGRAM = extproc)
> (ENVS=" EXTPROC_DLLS=C:\oraP
roc\Debug\oraProc.dll")
> )
> (SID_DESC =
> (GLOBAL_DBNAME = x)
> (SID_NAME = x)
> )
> )



>CREATE LIBRARY shell_lib is
> 'C:\mbhakta\playgrou
nd\oraProc\oraProc\D
ebug\oraProc.dll';

doesn't match

> (ENVS=" EXTPROC_DLLS=C:\oraP
roc\Debug\oraProc.dll")
>



--
Sybrand Bakker, Senior Oracle DBA
mukesh bhakta

2006-04-08, 3:23 am

Hi Sybrand,

Do you have an answer? Your answer was not displayed.

Cheers

MB

Frank van Bortel

2006-04-08, 7:23 am

mukesh bhakta wrote:
> Hi Sybrand,
>
> Do you have an answer? Your answer was not displayed.
>
> Cheers
>
> MB
>

Yes, he stated:

CREATE LIBRARY shell_lib is
'C:\mbhakta\playgrou
nd\oraProc\oraProc\D
ebug\oraProc.dll';
doesn't match
(ENVS=" EXTPROC_DLLS=C:\oraP
roc\Debug\oraProc.dll")

Strange I can see it...
--
Regards,
Frank van Bortel

Top-posting is one way to shut me up...
mukesh bhakta

2006-04-08, 7:23 am

Thanks Frank,

Strange!! I couldn't read the messagel. No the path was right. It was
my mistake to not have copy pasted the path in both places.

I think I have found the problem. Here is my change -

create or replace procedure shell(cmd IN varchar2)
as external
library shell_lib
name "shell"
language C
parameters (cmd string);

This has fixed the error but I still can't see the resultset coming out
of the following code -


extern "C" __declspec(dllexport
) void shell(const char *cmd)
{
int num = system(cmd);
}

Vladimir M. Zakharychev

2006-04-08, 7:23 am

>create or replace procedure shell(cmd IN varchar2)
>as external
>...
>I still can't see the resultset coming out of the following code -
>
>
>extern "C" __declspec(dllexport
) void shell(const char *cmd)
>{
> int num = system(cmd);
>}
>


And what kind of result set you are expecting from this code?
It's a PROCEDURE, not a FUNCTION, and it doesn't have any
OUT arguments, so it doesn't return anything. Or do you mean
that cmd is not executed?

Hth,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

Sybrand Bakker

2006-04-08, 9:23 am

On 8 Apr 2006 05:17:27 -0700, "Vladimir M. Zakharychev"
<vladimir.zakharychev@gmail.com> wrote:

>
>And what kind of result set you are expecting from this code?
>It's a PROCEDURE, not a FUNCTION, and it doesn't have any
>OUT arguments, so it doesn't return anything. Or do you mean
>that cmd is not executed?
>
>Hth,
> Vladimir M. Zakharychev
> N-Networks, makers of Dynamic PSP(tm)
> http://www.dynamicpsp.com



Obviously the printf function has output for stdout. Now my guess is
stdout for external procedures just equates /dev/null.
At least, the procedure is run at the server...


--
Sybrand Bakker, Senior Oracle DBA
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com