Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added hex function #4004

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

added hex function #4004

wants to merge 2 commits into from

Conversation

quantrpeter
Copy link

hex() function done

select hex(43981)

returns

0xabcd

SELECT HEX(123);

returns

7b
select hex(43981)

returns

0xabcd
@katzyn
Copy link
Contributor

katzyn commented Feb 18, 2024

Thank you for your contribution!

Why do you need this function in H2 itself?

You can create a user-defined function instead:

CREATE ALIAS HEX FOR 'java.lang.Long.toHexString';

Built-in functions should be more advanced and configurable to be really useful for many users.

H2 actually already has a function for this purpose:

TO_CHAR(23423, 'FMXXXXXXXX')

Unfortunately, it only supports INTEGER values, but you can add support of BIGINT values to this function instead of introduction of another one.

@quantrpeter
Copy link
Author

oh thanks, i have been asking in https://groups.google.com/g/h2-database/c/4tqipZkUzaE , seems we have to build a hotter forum.

If I write a java function and pack it into a jar, how can I expose it to H2 ? thanks

@katzyn
Copy link
Contributor

katzyn commented Feb 21, 2024

If you use H2 embedded into your application, class with this function must be in classpath of your application.

If you have standalone H2 Server process, your function must be in its classpath. Client applications don't need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants