Home » SQL & PL/SQL » SQL & PL/SQL » unable to create a c function to use in plsql  () 1 Vote
unable to create a c function to use in plsql [message #204333] Mon, 20 November 2006 03:34 Go to next message
kiran9i
Messages: 4
Registered: November 2006
Location: 1
Junior Member

hi friends,

i m trying to create c library in oracle.
and as per oracle documentation its working fine.
but have to write another function to encrypt password in c
but its very difficult to write the funciton in c as per requisition of oracle something like this

/*
** Copyright (c) 1997 by Oracle Corporation
**
** NAME
** EXTERN.C
**
** DESCRIPTION
** Sample Windows NT External Procedure: find_max
**
*/

#include <windows.h>

#define NullValue -1

/*
This function simply returns the returns the larger of x and y.
*/

long __declspec(dllexport) find_max(long x,
short x_indicator,
long y,
short y_indicator,
short *ret_indicator)
{
/* It can be tricky to debug DLL's that are being called by a process
that is spawned only when needed, as in this case.
Therefore try using the DebugBreak(); command.
This will start your debugger. Uncomment the following line and
you can step right into your code.
*/
/* DebugBreak(); */

/* first check to see if you have any nulls */
/* Just return a null if either x or y is null */

if ( x_indicator==NullValue || y_indicator==NullValue) {
*ret_indicator = NullValue;
return(0);
} else {
*ret_indicator = 0; /* Signify that return value is not null */
if (x >= y) return x;
else return y;
}
}


i m not getting which data types it supports if i m defining char datatype the c function is not creating the dll with make.bat

pls help !!!!!!!!!!!!!!!
Re: unable to create a c function to use in plsql [message #204776 is a reply to message #204333] Wed, 22 November 2006 01:40 Go to previous message
kiran9i
Messages: 4
Registered: November 2006
Location: 1
Junior Member

Hi friends,
No body has answered me for this questoin
fine
but i found the answer


we can use string instead of char in oracle c function call :

CREATE OR REPLACE FUNCTION endecrypt(
x Varchar2,
y BINARY_INTEGER)
RETURN Varchar2 AS
EXTERNAL LIBRARY pass
NAME "crypt" -- Name of function call. Quotes preserve case.
LANGUAGE C
PARAMETERS (x String, y short);

and now i m able to use c in oracle.
so if u will be having any problem you are welcome.

thanx
bye
Previous Topic: Automatic Triggers
Next Topic: SQL query help
Goto Forum:
  


Current Time: Wed Dec 07 08:47:54 CST 2016

Total time taken to generate the page: 0.09493 seconds