Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: externa procedures

Re: externa procedures

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 08 Dec 1999 08:34:11 -0500
Message-ID: <vfns4sopbci6ukk0pv3jmmnjatquj33h61@4ax.com>


A copy of this was sent to "E G" <EGlobys_at_yahoo.com> (if that email address didn't require changing) On Wed, 8 Dec 1999 12:03:19 +0200, you wrote:

>Hi,
>
>I have a problem:
>how to declare character string OUT parameter in PL/SQL ?
>

    procedure get_timezone( p_timezone out varchar2 )     is external
    name "get_timezone"
    library simple_tcp_client_lib
    language C
    with context
    parameters ( CONTEXT,

                 p_timezone     STRING,
                 p_timezone     INDICATOR short,
                 p_timezone     MAXLEN int,
                 p_timezone     LENGTH int );




long
get_hostname( OCIExtProcContext * ctx,

              char * p_data, short * p_data_i,
              int * p_data_maxl, int * p_data_l )
{
char buffer[300];
struct hostent * hent;

    debugf( "get_hostname() " );

    gethostname( buffer, sizeof(buffer) );     hent = gethostbyname( buffer );

    if ( strlen( hent->h_name ) + 1 > *p_data_maxl )

        raise_application_error( ctx, 20001,
            "hostname buffer needed to be %d bytes, was only %d",
             strlen(buffer)+1, *p_data_maxl );

    strcpy( p_data, hent->h_name );
    debugf( "get_hostname() returns %s", p_data );

    *p_data_l = strlen(p_data);
    *p_data_i = 0;

    return 0;
}

>Declaration like this:
>CREATE OR REPLACE
>FUNCTION ret_first_file ( dir IN VARCHAR2
> , mask IN VARCHAR2
> , file_name OUT VARCHAR2)
>RETURN PLS_INTEGER AS
> LANGUAGE C
> LIBRARY extLib
> NAME "ret_first_file"
> WITH CONTEXT
> PARAMETERS (
> CONTEXT,
> Dir,
> Mask,
> file_name,
> file_name INDICATOR,
> file_name LENGTH,
> RETURN );
>
>declaration of ret_first_file in C is:
>long get_first(
> OCIExtProcContext *pOraContext,
> char *Dir,
> char *Mask,
> char *file_name,
> short *file_name_i,
> int *file_name_l
> );
>
>
>Thanx

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Dec 08 1999 - 07:34:11 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US