[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference orarep::nomahs::dbintegrator_public_public

Title:DB Integrator Public Conference
Notice:Database Integration - today! Kit/Doc info see note 36
Moderator:BROKE::ABUGOV
Created:Mon Sep 21 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1171
Total number of notes:5187

1130.0. "DBI and external routine" by 3583::ANNIE () Sun Mar 09 1997 12:55

    
    
 Hi ,
    
     I tried to define in a DBI database an external function .
     When I ran it , I received the following error:
         RDB-E-EXTFUN_FAIL,external routine failed to compile 
    		or execute successfully
    The same function works on non DBI database.

     Does DBI support external function and how can I define it ?
    
    Thanks .
    
     Annie.
T.RTitleUserPersonal
Name
DateLines
1130.1External functions are supported (on UNIX, not until V7).BROKE::ABUGOVMon Mar 10 1997 09:1816
    
    Hi Annie,
    
    Section 13.2.7 in the product family users guide has a bit of info
    about using external functions in the product.  Could you show us the
    syntax you are using to define it?  Make sure privs for accessing it
    are OK, too.
    
    You should be attached to the Distributed Option database when it is
    defined, and not directly to an Rdb database.
    
    The product family users guide is located at:
    
    dbi$public:DBI_V7_FAMILY_USER_GD.{ps,txt}
    
    dan
1130.2test case3583::ANNIEThu Mar 20 1997 09:2096
    Dan ,
    
    I created a test case 
    
    This is the sqlmod module :
    ----------------------------
module db_read_a
language c

declare alias for filename '/TYPE=DBI/DBNAME=TESTDBI'

procedure start_txn
  sqlcode;
set transaction read only;

procedure db_read_a                                             
  sqlcode
  a_rec record
	a1 INTEGER
	a2 INTEGER
   end record ;

  select * into a_rec from ann     --------- This is the linked table 
	where a1 = 1;

procedure commit_txn
  sqlcode ;
commit;
    
    This is the c program ( read_a is the name of the function )
     --------------------
#include <descrip.h>
#include <stsdef.h>
#include <string.h>
#include <stdio.h>
#include ctype

struct s_rec  {
        int a1;
	int a2;
	};

void db_read_a();
void start_txn();
void commit_txn();

read_a(int num)
{
        struct s_rec a_rec;
	int sql_code ;
	start_txn(&sql_code);
	db_read_a(&sql_code , &a_rec);
	commit_txn(&sql_code);  

	   return a_rec.a2;	
}

main()
{
    read_a(1);

}
    
   This is the option file 
    -----------------------
UNIVERSAL = READ_A
PSECT_ATTR=RDB$MESSAGE_VECTOR,NOSHR
PSECT_ATTR=RDB$DBHANDLE,NOSHR
PSECT_ATTR=RDB$TRANSACTION_HANDLE,NOSHR
    
    
     This is the link
    ------------------
$ set ver
$ link/share=testread.exe test_c                  ( C program )
    			,test_READ -              ( SQLMOD )
		        ,test_opt.opt/opt         (Option file )
    			,sys$share:sql$user70/lib
$ ins rep dka200:[annie.rdb70]testread/write/open/share
    
    This is the definition of the external function
    --------------------------------------------------
CREATE FUNCTION READ_A
(IN INTEGER) RETURN INTEGER ;
EXTERNAL NAME READ_A LOCATION 'dka200:[annie.rdb70]TESTREAD.EXE'
LANGUAGE C GENERAL PARAMETER STYLE
;
    
    Like I explained in .0 , the same definitions
    work on an RDB database ( not DBI)
    
    Did I miss something ?
    
    Thanks for your help .
    
    Annie.
1130.3A few other things to try...BROKE::ABUGOVTue Mar 25 1997 08:2220
    
    Hi Annie,
    
    Things look OK from here.  I'm assuming when you created the function
    you were attached to the DBI database.
    
    When I looked at some of the function callouts we've written here most
    of them have "by reference" or "by value" in the parenthesis after where 
    you have (in integer.  Also, we tend to put the not variant keywords
    after general parameter style.
    
    Could you attach to the DBI database and do a show function and post
    the output?  Perhaps we will notice something that will help.
    
    Also, if you just run the program (where main does a call to read_a
    with the value (1) does it work?
    
    Thanks,
    
    Dan
1130.4Function definition3583::ANNIESun Mar 30 1997 12:3033
    
Hi ,
    
     This is the function's definition in the DBI database :
    
SH FUNCTION READ_A
Function name is: READ_A
 Type is VARIANT
 Function ID is: 5
 External Location is: dka200:[annie.rdb70]TESTREAD_dbi.EXE
 Entry Point is: READ_A
 Bind on Client Site
 Bind Scope Connect
 Language is: C
 GENERAL parameter passing style used
 Number of parameters is: 1
 
				Data Type
				---------
 
                                INTEGER		 
	Domain: DBI$_INT_000_010
	Function result datatype
	Return value is passed by VALUE
 
                                INTEGER		 
	Domain: DBI$_INT_000_010
	Parameter position is 1
	Parameter is IN (read)
	Parameter is passed by REFERENCE
 
 
    When I run the 
1130.5end of the reply3583::ANNIESun Mar 30 1997 12:3310
     
    
     I don't know what happens to my previous reply .
    
     The missing information is that when I run the program
       it works
    
    Thanks 
    
      Annie