on 2013 Jul 17 1:08 AM
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
ALTER FUNCTION "dba"."uidToHexStr"(in @ID bigInt) returns varchar(16) not deterministic external name 'SqlAnywhereDotNetDll.dll::SqlAnywhereDotNetDll.Util.toHexStr( numeric)' language CLR
But it's clearly wrong as I get from isql :
Procedure 'uidToHexStr' terminated with unhandled exception 'Invalid type in parameter list: numeric' SQLCODE=-91, ODBC 3 State="HY000"
with
begin declare @bi bigint; set @bi=9223372036854775807; select dba.uidToHexStr(@bi); end
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
Request clarification before answering.
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thx, it works after adding string after the )
sorry for not commenting earlier
User | Count |
---|---|
60 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.