473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Compiling stored UDFs

Hi!

I have a UDFs defined in a C source file. I also have a Microsoft Visual
Studio 2005.
Can someone please tell me how to compile this C source with Microsoft's
compiler into a DLL? I'd prefer the command line options :)

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 6 '06 #1
17 2115
Gregor KovaÄŤ wrote:
Hi!

I have a UDFs defined in a C source file. I also have a Microsoft Visual
Studio 2005.
Can someone please tell me how to compile this C source with Microsoft's
compiler into a DLL? I'd prefer the command line options :)

Best regards,
Kovi

Gregor,

cd to sqllib\samples\c
There is a DOS script called bldrtn
Usage is described in the header comments.
When you have it done once it's pretty trivial.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 6 '06 #2
Serge Rielau wrote:
Gregor Kovač wrote:
Hi!

I have a UDFs defined in a C source file. I also have a Microsoft Visual
Studio 2005.
Can someone please tell me how to compile this C source with Microsoft's
compiler into a DLL? I'd prefer the command line options :)

Best regards,
Kovi

Gregor,

cd to sqllib\samples\c
There is a DOS script called bldrtn
Usage is described in the header comments.
When you have it done once it's pretty trivial.

Cheers
Serge

I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory, bind
it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name "SQL060406131448304")
is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724

Regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 7 '06 #3
Gregor KovaÄŤ wrote:
I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory,
The bldrtn script already copies the necessary files to sqllib/function/
directory (at least on Unix and Linux systems).
bind it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name "SQL060406131448304")
is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724


What does your CREATE FUNCTION statement look like?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 7 '06 #4
Knut Stolze wrote:
Gregor Kovač wrote:
I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory,


The bldrtn script already copies the necessary files to sqllib/function/
directory (at least on Unix and Linux systems).
bind it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name "SQL060406131448304")
is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724


What does your CREATE FUNCTION statement look like?

The put_line.dll is in sqllib/function directory.
And the create function is like this:
CREATE FUNCTION PUT_LINE(SMALLINT, VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line';

CREATE FUNCTION PUT_LINE(INTEGER, VARCHAR(4000))
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT,VARCHAR(4000));

CREATE FUNCTION PUT_LINE(SMALLINT)
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line1';

CREATE FUNCTION PUT_LINE(INTEGER)
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT);

CREATE FUNCTION PUT_LINE(VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line2';

CREATE FUNCTION PUT_LINE(VARCHAR(4000),VARCHAR(1),VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
SCRATCHPAD
FINAL CALL
EXTERNAL NAME 'put_line!put_line3';

If I recreate the functions with FENCED option then the 32-bit version of
the DLL works, but this is not exactly what I want, since I can bring the
DB2 engine to crash with this version.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #5
Gregor Kovač wrote:
Knut Stolze wrote:
Gregor Kovač wrote:
I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory,

The bldrtn script already copies the necessary files to sqllib/function/
directory (at least on Unix and Linux systems).
bind it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name "SQL060406131448304")
is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724

What does your CREATE FUNCTION statement look like?

The put_line.dll is in sqllib/function directory.
And the create function is like this:
CREATE FUNCTION PUT_LINE(SMALLINT, VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line';

CREATE FUNCTION PUT_LINE(INTEGER, VARCHAR(4000))
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT,VARCHAR(4000));

CREATE FUNCTION PUT_LINE(SMALLINT)
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line1';

CREATE FUNCTION PUT_LINE(INTEGER)
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT);

CREATE FUNCTION PUT_LINE(VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line2';

CREATE FUNCTION PUT_LINE(VARCHAR(4000),VARCHAR(1),VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
SCRATCHPAD
FINAL CALL
EXTERNAL NAME 'put_line!put_line3';

If I recreate the functions with FENCED option then the 32-bit version of
the DLL works, but this is not exactly what I want, since I can bring the
DB2 engine to crash with this version.

Just a hunch: Copy the DLL to sqllib\function\unfenced.
What does: echo %DB2PATH% say?
It should point to your sqllib.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 10 '06 #6
Serge Rielau wrote:
Gregor Kovač wrote:
Knut Stolze wrote:
Gregor Kovač wrote:

I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory,
The bldrtn script already copies the necessary files to sqllib/function/
directory (at least on Unix and Linux systems).

bind it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name
"SQL060406131448304") is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724
What does your CREATE FUNCTION statement look like?

The put_line.dll is in sqllib/function directory.
And the create function is like this:
CREATE FUNCTION PUT_LINE(SMALLINT, VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line';

CREATE FUNCTION PUT_LINE(INTEGER, VARCHAR(4000))
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT,VARCHAR(4000));

CREATE FUNCTION PUT_LINE(SMALLINT)
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line1';

CREATE FUNCTION PUT_LINE(INTEGER)
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT);

CREATE FUNCTION PUT_LINE(VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line2';

CREATE FUNCTION PUT_LINE(VARCHAR(4000),VARCHAR(1),VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
SCRATCHPAD
FINAL CALL
EXTERNAL NAME 'put_line!put_line3';

If I recreate the functions with FENCED option then the 32-bit version of
the DLL works, but this is not exactly what I want, since I can bring the
DB2 engine to crash with this version.

Just a hunch: Copy the DLL to sqllib\function\unfenced.
What does: echo %DB2PATH% say?
It should point to your sqllib.

Cheers
Serge


%DB2PATH% = C:\Program Files\IBM\SQLLIB
Copying the DLL into the sqllib\function\unfenced directory returned the
same error. As I said I think that the DLL is not properly compiled.

Best regards,
Kovi

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #7
Gregor KovaÄŤ wrote:
Knut Stolze wrote:
Gregor KovaÄŤ wrote:
I've got the put_line sources and I want to compile it for a 64-bit DB2
v8.2.
I did compile it with bldrtn, but when I copy it to FUNCTION directory,


The bldrtn script already copies the necessary files to sqllib/function/
directory (at least on Unix and Linux systems).
bind it to DB2, use it in a procedure I get:
SQL0444N Routine "EMGSYS.PUT_LINE" (specific name "SQL060406131448304")
is
implemented with code in library or path "\put_line", function
"put_line2"
which cannot be accessed. Reason code: "4". SQLSTATE=42724


What does your CREATE FUNCTION statement look like?

The put_line.dll is in sqllib/function directory.
And the create function is like this:
CREATE FUNCTION PUT_LINE(SMALLINT, VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line';

CREATE FUNCTION PUT_LINE(INTEGER, VARCHAR(4000))
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT,VARCHAR(4000));

CREATE FUNCTION PUT_LINE(SMALLINT)
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line1';

CREATE FUNCTION PUT_LINE(INTEGER)
RETURNS VARCHAR(1)
SOURCE PUT_LINE(SMALLINT);

CREATE FUNCTION PUT_LINE(VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
EXTERNAL NAME 'put_line!put_line2';

CREATE FUNCTION PUT_LINE(VARCHAR(4000),VARCHAR(1),VARCHAR(4000))
RETURNS VARCHAR(1)
NOT FENCED
RETURNS NULL ON NULL INPUT
NO SQL
DBINFO
EXTERNAL ACTION
LANGUAGE C
PARAMETER STYLE DB2SQL
SCRATCHPAD
FINAL CALL
EXTERNAL NAME 'put_line!put_line3';

If I recreate the functions with FENCED option then the 32-bit version of
the DLL works, but this is not exactly what I want, since I can bring the
DB2 engine to crash with this version.


This I don't understand. If the functions are not properly debugged yet,
you should definitively run them as FENCED. This is a safer thing to do
than NOT FENCED (trusted) functions.

I would now check the following:
(1) My guess would be now that some compiler switch that causes 64-bit code
to be produced doesn't quite work or is not set. On AIX, you would set
"-q64" for the xlC compiler.
How did you build the 32-bit library?
(2) that the db2 instance owner has the necessary privileges to read and
load the DLL.
(3) set the diaglevel to 4, try to call the function on the command line.
Then have a look at the output of "db2diag" to see which messages were
written by DB2. Thus should allow you to narrow down whether the lib
was not found (along with the directories being searched) or if it could
not be loaded.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 10 '06 #8
Please see the comments inline.

Knut Stolze wrote:

This I don't understand. If the functions are not properly debugged yet,
you should definitively run them as FENCED. This is a safer thing to do
than NOT FENCED (trusted) functions.

I would now check the following:
(1) My guess would be now that some compiler switch that causes 64-bit
code
to be produced doesn't quite work or is not set. On AIX, you would
set "-q64" for the xlC compiler.
How did you build the 32-bit library?
In using Microsoft Visual Studio 2005. It has three different compilers.
32-bit native compiler, 32-bit compiler that can also produre 64-bit code,
and a 64-bit native compiler. I'm using compiler that runs on 32-bit system
and prodeuces 64-bit code. I'm sure of this.
The 32-bit library already came compiled.
(2) that the db2 instance owner has the necessary privileges to read and
load the DLL.
I'm on Windows logged in as Admninistrator. I've always worked like this and
had no problems before.
(3) set the diaglevel to 4, try to call the function on the command line.
Then have a look at the output of "db2diag" to see which messages were
written by DB2. Thus should allow you to narrow down whether the lib
was not found (along with the directories being searched) or if it
could not be loaded.


After setting diaglevel to 4 I get:

2006-04-10-13.52.52.703000+120 I961F1031 LEVEL: Error
PID : 2128 TID : 3388 PROC : db2bp.exe
INSTANCE: DB2 NODE : 000
APPID : *LOCAL.DB2.060410115224
FUNCTION: DB2 UDB, oper system services, sqlofica, probe:10
DATA #1 : Hexdump, 136 bytes
0x000000000012FB70 : 5351 4C43 4120 2020 8800 0000 44FE FFFF
SQLCA ....D...
0x000000000012FB80 : 3800 454D 4753 5953 2E50 5554 5F4C 494E
8.EMGSYS.PUT_LIN
0x000000000012FB90 : 45FF 5351 4C30 3630 3431 3031 3335 3132
E.SQL06041013512
0x000000000012FBA0 : 3438 3034 FF5C 7075 745F 6C69 6E65 FF70 4804
\put_line.p
0x000000000012FBB0 : 7574 5F6C 696E 6532 FF34 2020 2020 2020 ut_line2.4
0x000000000012FBC0 : 2020 2020 2020 2020 5351 4C45 524C 4942
SQLERLIB
0x000000000012FBD0 : FFFF FFFF 0000 0000 0000 0000 0000
0000 ................
0x000000000012FBE0 : 0000 0000 0000 0000 2020 2020 2020 2020 ........
0x000000000012FBF0 : 2020 2034 3237 3234 42724

I cannot make a lot out of this. The functions are now NOT FENCED as I want
them to be.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #9
Gregor KovaÄŤ wrote:
Please see the comments inline.

Knut Stolze wrote:

I would now check the following:
(1) My guess would be now that some compiler switch that causes 64-bit
code
to be produced doesn't quite work or is not set. On AIX, you would
set "-q64" for the xlC compiler.
How did you build the 32-bit library?


In using Microsoft Visual Studio 2005. It has three different compilers.
32-bit native compiler, 32-bit compiler that can also produre 64-bit code,
and a 64-bit native compiler. I'm using compiler that runs on 32-bit
system and prodeuces 64-bit code. I'm sure of this.
The 32-bit library already came compiled.


Ah, so it could still be a compile problem after all. I thought you
compiled it yourself.
(2) that the db2 instance owner has the necessary privileges to read and
load the DLL.


I'm on Windows logged in as Admninistrator. I've always worked like this
and had no problems before.


It doesn't hurt to check the privileges nevertheless.
(3) set the diaglevel to 4, try to call the function on the command line.
Then have a look at the output of "db2diag" to see which messages
were
written by DB2. Thus should allow you to narrow down whether the lib
was not found (along with the directories being searched) or if it
could not be loaded.


After setting diaglevel to 4 I get:

2006-04-10-13.52.52.703000+120 I961F1031 LEVEL: Error
PID : 2128 TID : 3388 PROC : db2bp.exe
INSTANCE: DB2 NODE : 000
APPID : *LOCAL.DB2.060410115224
FUNCTION: DB2 UDB, oper system services, sqlofica, probe:10
DATA #1 : Hexdump, 136 bytes
0x000000000012FB70 : 5351 4C43 4120 2020 8800 0000 44FE FFFF
SQLCA ....D...
0x000000000012FB80 : 3800 454D 4753 5953 2E50 5554 5F4C 494E
8.EMGSYS.PUT_LIN
0x000000000012FB90 : 45FF 5351 4C30 3630 3431 3031 3335 3132
E.SQL06041013512
0x000000000012FBA0 : 3438 3034 FF5C 7075 745F 6C69 6E65 FF70 4804
\put_line.p
0x000000000012FBB0 : 7574 5F6C 696E 6532 FF34 2020 2020 2020 ut_line2.4
0x000000000012FBC0 : 2020 2020 2020 2020 5351 4C45 524C 4942
SQLERLIB
0x000000000012FBD0 : FFFF FFFF 0000 0000 0000 0000 0000
0000 ................
0x000000000012FBE0 : 0000 0000 0000 0000 2020 2020 2020 2020 ........
0x000000000012FBF0 : 2020 2034 3237 3234 42724

I cannot make a lot out of this. The functions are now NOT FENCED as I
want them to be.


Not very helpful, indeed. Take a trace and have a look at it:

$ db2trc on
$ db2 "values <fct>"
$ db2trc dump trc
$ db2trc fmt trc fmt

Have a look at the "fmt" file, search for function "sqloLoadModule". I just
tried it with a non-existing file and there I see "SQLO_FNEX" (file not
exists).

--
Knut Stolze
DB2 Information Integration Development
BM Germany
Apr 10 '06 #10
Udo
You can use the command line program "dumpbin" (part of visiual studio)
to examine the functions in a shared library (windows ddl).

use:

dumpbin /exports <your .dll here>

Regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html

Apr 10 '06 #11
Udo wrote:
You can use the command line program "dumpbin" (part of visiual studio)
to examine the functions in a shared library (windows ddl).

use:

dumpbin /exports <your .dll here>

Regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html


This gives me:
Dump of file PUT_LINE.dll

File Type: DLL

Section contains the following exports for put_line.dll

00000000 characteristics
44352FAC time date stamp Thu Apr 06 17:11:40 2006
0.00 version
1 ordinal base
2 number of functions
2 number of names

ordinal hint RVA name

1 0 0000100A put_line1 = @ILT+
(?put_line1@@YAXPEAFPEAD00QEAD222@Z)

2 1 0000100F put_line2 = @ILT+1
(?put_line2@@YAXPEAD0PEAF1QEAD222@Z
)

Summary

1000 .data
1000 .idata
1000 .pdata
2000 .rdata
1000 .reloc
1000 .rsrc
4000 .text
I hope this means functions put_line1 and put_line2 are exported?

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #12
Udo
And that's the reason...

Yes the functions are exported. But the exported names are "mangled"

See:

http://en.wikipedia.org/wiki/Name_mangling

You have to use the "export C" declaration while using a "c++"
compiler.

Regards,
Udo
--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html


Apr 10 '06 #13
Here is the standand way of doing it:

#ifdef __cplusplus
extern "C" {
#endif

SQL_API_RC SQL_API_FN myproc(....)
{
....
}
#ifdef __cplusplus
}
#endif

The extern C would protect your function name from being mangled by
C++. Also, SQL_API_FN is very important on windows.

Apr 10 '06 #14
Also, on windows, make sure your sqllib\function is on your system
PATH. An improperly exported symbol should get -444 reason code 6
rather than reason code 4. Reason code 4 usually means DB2 can not find
your library at all.

Apr 10 '06 #15
Liu Liu wrote:
Here is the standand way of doing it:

#ifdef __cplusplus
extern "C" {
#endif

SQL_API_RC SQL_API_FN myproc(....)
{
...
}
#ifdef __cplusplus
}
#endif

The extern C would protect your function name from being mangled by
C++. Also, SQL_API_FN is very important on windows.


I have done this. I have also specified the put_line.def file that says what
functions are exported. I verified that the sqllib/function is in PATH. I
have SQL_API_FN specified on exported functions, I copied the DLL to
sqllib/functions, but I still get the same error.

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #16
Udo
>From your previous post:
Dump of file PUT_LINE.dll From your ddl EXTERNAL NAME 'put_line!put_line2';
I think for the windows platform (if you name it ".dll") your
sql-source has to be:
EXTERNAL NAME 'put_line.dll!put_line2';


regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html

Apr 10 '06 #17
Udo wrote:
From your previous post:

Dump of file PUT_LINE.dll

From your ddl

EXTERNAL NAME 'put_line!put_line2';


I think for the windows platform (if you name it ".dll") your
sql-source has to be:
EXTERNAL NAME 'put_line.dll!put_line2';


regards,
Udo

--
Speedgain for DB2 - The DB2 Monitor
http://www.itgain.de/en/index.html

It doesn't matter.
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Apr 10 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: hrishikesh musale | last post by:
hey does anybody know what are these in UDF's in SQL2k? when to use UDF's and when to use Stored procedures are they dependent? where i will get information on this topic please let me know...
4
by: richardshen | last post by:
DB2 V8 FP4 on W2K. After a long long time waiting.. SQL1131N DARI (Stored Procedure) process has been terminated abnormally. SQLSTATE=38503 And in DB2Diag.log
3
by: David Carver | last post by:
We are running into a problem with a Communication Link failure when calling an External Stored procedure written in ILE Cobol from an SQL UDF. When calling the stored procedure by itself and not...
1
by: Alex | last post by:
Hi all, Just been dabbling with java stored procedures and I'm having problems replacing System: db2 8.1.4 on RH 7.1 linux system 1). Look at java jdbc samples as supplied with db2 and run...
7
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
7
by: P. Adhia | last post by:
Hi, I don't have much experience writting UDFs, so I don't know if this is possible (and simple). I am basically looking to write a wrapper table UDF that encapsulates reorgchk_tb_stats and...
8
by: rick | last post by:
Hi I m trying to move only stored procedures from one database to another and also onto a database on another server, I tried db2 -x "select text from syscat.procedures where procschema =...
15
by: Burt | last post by:
I'm a stored proc guy, but a lot of people at my company use inline sql in their apps, sometimes putting the sql in a text file, sometimes hardcoding it. They don't see much benefit from procs, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.