I got in c# // namespace SqlAnywhereDotNetDll public class Util { public static string toHexStr(Int64 id) { return id.ToString("X2"); } public static string intToHexStr(int id) { return id.ToString("X2"); } public static int fromHexStr(string h) { return int.Parse(h, System.Globalization.NumberStyles.HexNumber); } } and I have tried to interface to toHexStr with the clr function declared as
But it's clearly wrong as I get from isql :
with
Note I have tried bigInt, Int64 instead of numeric in the stored function arg type as a side note, we don't need uidToHexStr nor intToHexStr since SA has a built-in function intToHex that works on bigint and int. I used the clr dll just to try out how to integrate clr function before I proceed to something serious |
The list of types provided to the external function call in the external name definition are the CLR types: http://dcx.sybase.com/index.html#sa160/en/dbprogramming/pg-extenv-clr.html So in this case, you will want: CREATE FUNCTION "dba"."uidToHexStr"(in id_field bigint) returns varchar(16) not deterministic external name 'SqlAnywhereDotNetDll.dll::SqlAnywhereDotNetDll.Util.toHexStr( long )' language CLR; 1
thx, it works after adding string after the ) sorry for not commenting earlier
(06 Nov '14, 03:57)
gg99
OT: despite only .net 2 is supported for Sql anywhere v 11, .net 3 can do the job as well so far
(06 Nov '14, 03:59)
gg99
|
The documentation lists long as the corresponding CLR type for bigint, have you tried that?
I did try and I got null output from SELECT "dba"."uidToHexStr"(16546878931561) also null for a lot smaller number
for those looking string clr function return:
.net code