lunes, 10 de octubre de 2016

Figuras Geométricas en PL/SQL 2

Objetivos:

• Mostrar lo flexible que resulta PL/SQL.
• Matar algo de estrés.
____________________________________________________________________________________
SET SERVEROUTPUT ON SET VERIFY OFF DECLARE v_char_line VARCHAR2(1000); v_loop_count NUMBER(3); v_reverse v_loop_count%TYPE; BEGIN v_loop_count := &COUNT_; v_reverse := (v_loop_count/2)+1; FOR I IN 1..v_loop_count LOOP IF I < (v_loop_count/2)+1 THEN v_char_line := RPAD('*',I,'*'); DBMS_OUTPUT.PUT_LINE(v_char_line); ELSE v_reverse := v_reverse-1; v_char_line := RPAD('*',v_reverse,'*'); DBMS_OUTPUT.PUT_LINE(v_char_line); END IF; END LOOP; END;
---OUTPUT:
_____________________________________________________________________________________
SET SERVEROUTPUT ON SET VERIFY OFF DECLARE v_string VARCHAR2(200); v_string2 VARCHAR2(200); v_length NUMBER(10); e_wrong# EXCEPTION; PRAGMA EXCEPTION_INIT(e_wrong#,-06502); BEGIN v_length := '&AMOUNT'; IF v_length > 40 OR v_length < 5 THEN RAISE e_wrong#; END IF; -- v_string := RPAD('*',v_length,'*'); v_string2 := v_string; -- DBMS_OUTPUT.PUT_LINE('_____PL/SQL NO ES UN'||CHR(10)||'LENGUAJE DE PROGRAMACIÓN...'); DBMS_OUTPUT.PUT_LINE(v_string); -- v_string := '*'||REPLACE(SUBSTR(v_string,2,v_length-2),'*',' ')||'*'; -- FOR I IN 1..v_length/2 LOOP DBMS_OUTPUT.PUT_LINE(v_string); END LOOP; -- DBMS_OUTPUT.PUT_LINE(v_string2); DBMS_OUTPUT.PUT_LINE('PL/SQL ES MAGIA'); -- EXCEPTION WHEN e_wrong# THEN DBMS_OUTPUT.PUT_LINE('Solo Valores Numéricos en un rango de 5 al 41!!!'); END;
---OUTPUT: