SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
create or replace FUNCTION "CALCULAR_DV" (rut in TARSSB0001.NRO_IDENTIDAD%TYPE) RETURN char IS TYPE Vec_Number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; str_rut varchar2(10); long_rut integer; arr_rut Vec_Number; dv_rut integer; total integer; aux float; parteent integer; i integer; j integer; BEGIN str_rut := to_char(rut); long_rut := length(str_rut); if long_rut < 8 then j := 8 - long_rut + 1; else j := 1; end if; if long_rut <= 8 then i := 1; else i := 1 + (long_rut - 8); end if; for k in 1..20 loop arr_rut(k) := 0; end loop; for k in i..long_rut loop if substr(str_rut, k, 1) <> ' ' then arr_rut(j) := to_number(substr(str_rut, k, 1)); j := j + 1; end if; end loop; total := arr_rut(1) * 3 + arr_rut(2) * 2 + arr_rut(3) * 7 + arr_rut(4) * 6 + arr_rut(5) * 5 + arr_rut(6) * 4 + arr_rut(7) * 3 + arr_rut(8) * 2; aux := total / 11; if aux < 1 then aux := 0; end if; parteent := floor(aux); if (total - parteent * 11) = 0 then dv_rut := 0; else dv_rut := 11 - (total - parteent * 11); end if; if dv_rut < 10 then return to_char(dv_rut); else return 'K'; end if; END CALCULAR_DV;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear