esmith2112 wrote:
> void SQL_API_FN hash(SQLUDF_VARCHAR *str,
> SQLUDF_VARCHAR *outHash,
> SQLUDF_SMALLINT *strNullInd,
> SQLUDF_SMALLINT *outHashNullInd,
> SQLUDF_TRAIL_ARGS)
Could you show us the exact CREATE FUNCTION statement that you used?
> {
> int i;
> unsigned char hash_str[40];
>
> if (*strNullInd == -1)
> {
> *outHashNullInd = -1;
> }
> else
> {
> i = strlen(str);
> my_hash((unsigned char *) str, i, hash_str);
Could you show us my_hash as well? Maybe you run into a buffer overflow
there since you don't pass along the size of the "hash_str" buffer.
Also, does "my_hash" return some sort of error information? If so, you
may want to check that.
> sprintf(outHash, "%X", hash_str);
The %X is not be right here. %X expects an "unsigned int", but you provide
a char *. For example, my compiler complains about this:
$ g++ -Wall -Wextra a.cpp
a.cpp: In function ‘int main()’:
a.cpp:7: warning: format ‘%X’ expects type ‘unsigned int’, but
argument 2 has type ‘char*’
> *outHashNullInd = 0;
> }
> }
--
Knut Stolze
Data Warehousing for DB2 z/OS
IBM Germane Research & Development


|