The TO_DATE function converts a string to a DATE variable. Syntax: TO_DATE(source_string, Format, NLS_LANGUAGE); --The last parameter NLS_LANGUAGE (which I understand to be for setting the encoding) has never been useful to me. Examples: SQL> sel…
The TO_NUMBER function converts a string value to a numeric (NUMBER) value. Syntax: TO_NUMBER(source_string, Format, NLS_LANGUAGE); --The last parameter NLS_LANGUAGE (as I understand, for setting the encoding) has never been useful to me. Examples:…
The TO_CHAR function converts a date or number to a string. Syntax: TO_CHAR(original_value, Format, NLS_LANGUAGE); --The original value can be either a date (DATE) or a number (NUMBER). --The last parameter NLS_LANGUAGE (such as AMERICAN_AMERICA or RUSSIAN_RUSSIA) is used to specify the language for the date and time format. For example, if you want to display the date in Russian, you would use NLS_LANGUAGE = RUSSIAN_RUSSIA.
Main ways to process string values in Oracle. In this publication, I will list the main string processing functions that I encountered in my work, and will be useful to all who work with Oracle. CONCAT - Joins two strings SQL> sele…
A small guide to catching errors in Oracle PLSQL. Description of how to use Oracle (PLSQL) functions SQLERRM and SQLCODE to catch errors EXCEPTION, with syntax and example description.
A function for calculating the check digit of the EAN13 barcode based on the first 12 digits. Input: a string (12-digit number). Output: the check digit. function GetControlNumber(p_code varchar2) return number is v…
Let's start with the RANK() function. With explanations for what it is and in what cases it may be useful. The RANK() function is a very useful function that allows us to number a set by some grouping value within the entire selected set. It is easiest to show this with an example. To do this, let's create a small table:
Learn how much each Tablespace occupies: (Size is shown in megabytes) select a.tablespace_name, totalspace, nvl(freespace,0) freespace, (totalspace-nvl(freespace,0)) used, ((totalspace-nvl(freespace,0))/totalspace)*100 "%USED" from (select a.tablespace_name, sum(a.bytes) totalspace, sum(b.bytes) freespace from dba_data_files a, dba_free_space b where a.tablespace_name = b.tablespace_name group by a.tablespace_name)
Displays sessions that block tables: select distinct ddl.session_id, s.SERIAL#, ddl.owner, ddl.name, ddl.mode_held, ddl.mode_requested, s.username, s.status from dba_dml_locks ddl, v$session s where ddl.session_id = s.SID
I have encountered the problem of Russian letters in SQLPlus many times, so I decided to document it so I wouldn't have to search the internet again. If we see gibberish instead of letters, we do: 1. Check what we have in NLS_LANG in the registry. It should be: ...