Skip to content

Update why-i-get-lua-error-decimal-expected-got-number.md #157

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ SELECT TEST.NUMBER_DECIMAL_UDF (a) FROM TEST.T;

I get the following error message:

> [!CAUTION]
> [Code: 0, SQL State: 22001] Lua Error "decimal expected, got number" caught in script "TEST"."NUMBER_DECIMAL_UDF" at line 4 (Session: 1836005522647613440)
```text
[Code: 0, SQL State: 22001] Lua Error "decimal expected, got number" caught in
script "TEST"."NUMBER_DECIMAL_UDF" at line 4 (Session: 1836005522647613440)
```

## The Error

Expand All @@ -57,11 +59,12 @@ end
* ctx.a / 10: Performs floating-point division in Lua.
* DECIMAL(): Converts the floating-point result into an integer by rounding down

> [!TIP]
> Always use decimal() for calculations if you’re working with DECIMALs!
### 💡Hint💡

* Always use decimal() for calculations if you’re working with DECIMALs!

## References

* [Exasol Lua Scripting: Decimal number handling](https://docs.exasol.com/db/latest/database_concepts/scripting/general_script_language.htm#TypesandValues)
* Documentation of [Exasol Lua Scripting: Decimal number handling](https://docs.exasol.com/db/latest/database_concepts/scripting/general_script_language.htm#TypesandValues)

*We appreciate your input! Share your knowledge by contributing to the Knowledge Base directly in [GitHub](https://github.com/exasol/public-knowledgebase).*