RAWTOHEX Function in PL/SQL Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The objective is to use the function RAWTOHEX in PL/SQL code. Purpose : This inbuilt function is beneficial for the conversion of a raw value into a character value in its hexadecimal format. Syntax : RAWTOHEX(x) where x - raw value to be converted to hexadecimal value and hexadecimal equivalent in the form of a string value is returned. Here may be a simple procedure to demonstrate the usage of the function - Example-1: Storing the hexadecimal converted value in a variable 'random'. CREATE PROCEDURE TEST_RAW2HEX IS random varchar2(20); BEGIN SELECT RAWTOHEX('JAVA') INTO random FROM dual; dbms_output.put_line('random = ' || random); EXCEPTION WHEN OTHERS THEN dbms_output.put_line(Exception occurred.) END TEST_RAW2HEX; When the procedure is created, and it is run using the SQL script - BEGIN TEST_RAW2HEX; END; We get the output as - random = 5859 This function accepts argument of any data type other than LONG, LONG RAW, CLOB, BLOB, or BFILE. Here we see another example of a procedure for the function demonstration. Example-2: Storing the hexadecimal converted values in variables 'random_1' & 'random_2'. CREATE PROCEDURE TEST1_RAW2HEX IS random_1 varchar2(12); random_2 varchar2(12); BEGIN SELECT RAWTOHEX('JAVA') INTO random_1 FROM dual; SELECT RAWTOHEX('CPP') INTO random_2 FROM dual; dbms_output.put_line('random_1 = ' || random_1); dbms_output.put_line('random_2 = ' || random_2); END TEST1_RAW2HEX; When the procedure is created, and it is run using the SQL script - BEGIN TEST1_RAW2HEX; END; We get the output as - random_1 = 4A415641 random_2 = 435050 Comment More infoAdvertise with us Next Article PLSQL | INSTRB Function D devyanshgoyal699dg Follow Improve Article Tags : PL/SQL SQL-PL/SQL Similar Reads Math Functions in PL/SQL In PL/SQL, mathematical functions play a important role in performing calculations and manipulating numeric data. These functions allow us to execute a wide range of mathematical operations from basic arithmetic to complex computations within our PL/SQL code.In this article, we will learn about Math 4 min read PLSQL | LN Function The LN function is an inbuilt function in PLSQL which is used to return the natural logarithm of a given input number. The natural logarithm of a number is the logarithm of that number to the base e, where e is the mathematical constant approximately equal to 2.718. This is written using the notatio 2 min read PLSQL | INSTRC Function The PLSQL INSTRC function is used for returning the location of a substring in a string, Unicode complete characters. The PLSQL INSTRC function searches a string for a substring specified by the user using characters and returns the position in the string that is the first character of a specified o 2 min read PLSQL | INSTRB Function The PLSQL INSTRB function is used for returning the location of a substring in a string, using bytes instead of characters. The PLSQL INSTRB function searches a string for a substring specified by the user using characters and returns the position in the string that is the first character of a speci 2 min read PL/SQL Functions PL/SQL functions are reusable blocks of code that can be used to perform specific tasks. They are similar to procedures but must always return a value. A function in PL/SQL contains:Function Header: The function header includes the function name and an optional parameter list. It is the first part o 4 min read PLSQL | NCHR Function The PLSQL NCHR function is used for returning the character based on the number code in the national character set or in other words it returns the binary equivalent to the number in the national character set. The value returned by the NCHR function is always of the datatype NVARCHAR2. The NCHR fun 1 min read Like