473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Executing memberfunction in udf

JB
After searching a lot on the ibmsite and googling a lot, i still dont
know how to execute a memberfunction in an udf.

Example:
-----------A.h --------------
class A
{
public:
void run();
}

------------udf.c------------
#include "sqludf.h"
#include "A.h"

SQL_API_RC SQL_API_FN run ( SQLUDF_VARCHAR* out,
SQLUDF_NULLIND* outnul,
SQLUDF_TRAIL_ARGS )
{
A a;
a.run();
strcpy(out,"done");
}

----------------------------
After bldrtn and

create function run () returns varchar(80)
external name 'udf!run'
language C
parameter style SQL
;

I get the error running[select run() from R]:

SQL0444N Routine "BEN.RUN" (specific name "SQL040526125305300") is
implemented with code in library or path ".../sqllib/function/A",
function
"run" which cannot be accessed. Reason code: "6". SQLSTATE=42724.

Paul Cowell
Nov 12 '05 #1
3 1494
JB wrote:
After searching a lot on the ibmsite and googling a lot, i still dont
know how to execute a memberfunction in an udf.

Example:
-----------A.h --------------
class A
{
public:
void run();
}

------------udf.c------------
#include "sqludf.h"
#include "A.h"

You need this here as well:

extern "C" SQL_API_RC SQL_API_FN run ( SQLUDF_VARCHAR* out,
The return type for UDFs needs to be "void".
SQLUDF_NULLIND* outnul,
SQLUDF_TRAIL_ARGS )
{
A a;
a.run();
strcpy(out,"done");
}

----------------------------
After bldrtn and

create function run () returns varchar(80)
external name 'udf!run'
language C
parameter style SQL
;

I get the error running[select run() from R]:

SQL0444N Routine "BEN.RUN" (specific name "SQL040526125305300") is
implemented with code in library or path ".../sqllib/function/A",
function
"run" which cannot be accessed. Reason code: "6". SQLSTATE=42724.


I think that your problem is that the function named "run" was not exported
as C symbol, so your compiler used C++ name mangling. But DB2 requires the
C name mangling and, thus, it did look for the symbol "run" and couldn't
find it. The above mentioned 'extern "C"' should fix your problem.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
> I think that your problem is that the function named "run" was not exported
as C symbol, so your compiler used C++ name mangling. But DB2 requires the
C name mangling and, thus, it did look for the symbol "run" and couldn't
find it. The above mentioned 'extern "C"' should fix your problem.


I did all this, but still the same error...
The class A that I include in the udf.c came from [>db2 prep a.sqC]...
Nov 12 '05 #3
Paul Cowell wrote:
I think that your problem is that the function named "run" was not
exported
as C symbol, so your compiler used C++ name mangling. But DB2 requires
the C name mangling and, thus, it did look for the symbol "run" and
couldn't
find it. The above mentioned 'extern "C"' should fix your problem.


I did all this, but still the same error...
The class A that I include in the udf.c came from [>db2 prep a.sqC]...


I already answered your question that you sent by email. I suspect there is
just a minor issue that you need to find and fix. The detailed steps I
provided should help you with that.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #4

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

Similar topics

10
by: Heiko Pliefke | last post by:
Hi NG! I wrote a stored procedure which at first deletes 100.000 rows and then inserts 100.000 new rows. There is a huge difference between executing this SP in the query-analyzer (runtime...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
2
by: Frank Vanris | last post by:
Hi, I have the following code: #include "stdafx.h" #using <mscorlib.dll> using namespace std; __gc class A {
7
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.