T.R | Title | User | Personal Name | Date | Lines |
---|
1130.1 | External functions are supported (on UNIX, not until V7). | BROKE::ABUGOV | | Mon Mar 10 1997 09:18 | 16 |
|
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.2 | test case | 3583::ANNIE | | Thu Mar 20 1997 09:20 | 96 |
| 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.3 | A few other things to try... | BROKE::ABUGOV | | Tue Mar 25 1997 08:22 | 20 |
|
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.4 | Function definition | 3583::ANNIE | | Sun Mar 30 1997 12:30 | 33 |
|
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.5 | end of the reply | 3583::ANNIE | | Sun Mar 30 1997 12:33 | 10 |
|
I don't know what happens to my previous reply .
The missing information is that when I run the program
it works
Thanks
Annie
|