In [1]:
%%bash
sqlplus -s test/test@dbserver:1521/orcl.mydomain.com <<EOF
set serveroutput on
begin
dbms_output.put_line('Hello world!');
end;
/
select sysdate from dual;
EOF
In [2]:
%%bash
sqlplus -s scott/tiger@dbserver:1521/orcl.mydomain.com <<EOF
set linesize 100
set pagesize 100
col ename for a15
col job for a15
SELECT * from EMP;
EOF
In [4]:
%%bash
sqlplus -s test/test@dbserver:1521/orcl.mydomain.com <<EOF
set verify off
set lines 4000
set pages 999
set heading off
-- From https://github.com/LucaCanali/Miscellaneous/tree/master/SQL_color_Mandelbrot
-- Configuration parameters for the Mandelbrot set calculation
-- Edit to change the region displayed and/or resolution by changing the definitions here below
-- Edit your terminal screen resolution and/or modify XPOINTS and YPOINTS so that the image fits the screen
define XMIN=-2.0
define YMIN=-1.4
define XMAX=0.5
define YMAX=1.4
define XPOINTS=120
define YPOINTS=60
define XSTEP="(&XMAX - &XMIN)/(&XPOINTS - 1)"
define YSTEP="(&YMAX - &YMIN)/(&YPOINTS - 1)"
-- Visualization parameters
define COLORMAP="012223333344445555666677770"
define MAXITER="LENGTH('&COLORMAP')"
define BLUE_PALETTE="0,0,1,15,2,51,3,45,4,39,5,33,6,27,7,21"
define PALETTE_NUMCOLS=8
define ESCAPE_VAL=4
define ANSICODE_PREFIX="chr(27)||'[48;5;'"
define ANSICODE_BACKTONORMAL="chr(27)||'[0m'"
WITH
XGEN AS ( -- X dimension values generator
SELECT CAST(&XMIN + &XSTEP * (rownum-1) AS binary_double) AS X, rownum AS IX FROM DUAL CONNECT BY LEVEL <= &XPOINTS),
YGEN AS ( -- Y dimension values generator
SELECT CAST(&YMIN + &YSTEP * (rownum-1) AS binary_double) AS Y, rownum AS IY FROM DUAL CONNECT BY LEVEL <= &YPOINTS),
Z(IX, IY, CX, CY, X, Y, I) AS ( -- Z point iterator. Makes use of recursive common table expression
SELECT IX, IY, X, Y, X, Y, 0 FROM XGEN, YGEN
UNION ALL
SELECT IX, IY, CX, CY, X*X - Y*Y + CX, 2*X*Y + CY, I+1 FROM Z WHERE X*X + Y*Y < &ESCAPE_VAL AND I < &MAXITER),
MANDELBROT_MAP AS ( -- Computes an approximated map of the Mandelbrot set
SELECT IX, IY, MAX(I) AS VAL FROM Z -- VAL=MAX(I) represents how quickly the values reached the escape point
GROUP BY IY, IX),
PALETTE AS ( -- Color palette generator using ANSI escape codes
SELECT rownum-1 ID, &ANSICODE_PREFIX|| DECODE(rownum-1, &BLUE_PALETTE) || 'm ' || &ANSICODE_BACKTONORMAL COLOR
FROM DUAL CONNECT BY LEVEL <= &PALETTE_NUMCOLS)
SELECT LISTAGG(PALETTE.COLOR) WITHIN GROUP (ORDER BY IX) GRAPH -- The function LISTAGG concatenates values into rows
FROM MANDELBROT_MAP, PALETTE
WHERE TO_NUMBER(SUBSTR('&COLORMAP',MANDELBROT_MAP.VAL,1))=PALETTE.ID -- Map visualization using PALETTE and COLORMAP
GROUP BY IY
ORDER BY IY DESC;
EOF
In [ ]: