Ivan Yuzafatau
Ivan Yuzafatau

Reputation: 630

How do we create a function that we can use in an index expression? Is this possible at all?

Let's look at a simple function that takes a value of type CHAR(10) and returns the same value.

CREATE FUNCTION MyFunc 
   ( 
   InputValue CHAR(10)
   )
   RETURNS CHAR(10)
BEGIN
RETURN InputValue;
END;

I can use this function in SELECT queries. For example:

SELECT MyFunc(field1) FROM table1;

But I get an error when trying to use this function in an index expression.

EXECUTE PROCEDURE sp_CreateIndex90( 
   'table1',
   'table1.adi',
   'IDX_FIELD1',
   'MyFunc(field1)',
   '',
   2,
   512,
   '' );

poQuery: Error 7200: AQE Error: State = HY000; NativeError = 3007; [SAP][Advantage SQL Engine][ASA] Error 3007: Unsupported function found in index key expression.

Does Advantage Database Server allow creating custom functions that can be used in indexes at all?

Upvotes: 1

Views: 23

Answers (0)

Related Questions