How to create RGB value in PL / SQL?

I have a large table in my database where I need to update the internally called field "ColorByte" . This field is calculated using RGB values ​​and is first used in Excel-VBA scripts, but also in WinForms C # applications. It represents a single integer value that represents a specific color.

This works in VBA (no working code to clarify):

 r = 5 g = 50 b = 200 colorByte = RGB(r,g,b) 

Read more about the RGB function here .

Now I have a complex calculation scheme for obtaining the best RGB values ​​from our company data, developed in VBA by a member of our research team. I have to define this calculation in the database to easily update my large table and fix the "ColorByte" field. Exact calculations are irrelevant because this material works, but:

Is there an equivalent VBA RGB(r, g, b) function that I can use in PL / SQL to execute my function?

Or does anyone know what this function does internally so that I can override it in PL / SQL?

+5
source share
2 answers

No, there is no Oracle RGB( ) built-in function, but the formula

+4
source

I think RGB(r,g,b) just does

 RGB(r,g,b) = 256 * 256 * r + 256 * g + b 

It may be the other way around (i.e. r + 256*g + 256*256*b ), but I'm sure you can find it with a simple try-and-error. PL / SQL should not have problems with rebuilding.

+2
source

Source: https://habr.com/ru/post/1260821/


All Articles