Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Devuelve
hola mundo
Fin del programa
b) Devuelve error de compilacin
Ejercicio 2 ) Marcar la respuesta correcta
Ejemplo #2
SET SERVEROUTPUT ON
DECLARE
V_NUM1 NUMBER(4,2):=10.2;
V_NUM2 NUMBER(4,2):=20.1;
BEGIN
DBMS_OUTPUT.PUT_LINE('LA SUMA ES: '||TO_CHAR(V_NUM1+V_NUM2));
END;
/
Devuelve
a)
b)
c)
Ejercicio4 ) CHAR
Crear un pl-sql que defina dos variables v_nombre_empleado_1 y v_nombre_empleado_2 con el nombre
Juan . La primera de tipo char de 6 y la segunda de tipo varchar de 6. Imprimir ambos valores
concatenando un * al principio .
1) Ocupan lo mismo ? Imprimir usando length(variable)
2) Asignar a v_nombre_empleado_1 el nombre Juan manuel Garcia
3) Asignar a v_nombre_empleado_1 el valor JG
4) Asignar a v_nombre_empleado_2 el valor JG
Ejercicio5 ) DATE
Objetivo: poder asignar ver que tipos de datos se pueden sumar entre, si. Dates , numbers.
Abrir el sql-developer y armar un pl-sql que cargue una fecha sysdate en una variable, arme la fecha de
fin de mes en otra variable, reste las fechas y calcule cuantos das faltan para fin de mes.
Imprimir la cantidad de das que faltan para fin de mes.
Referencias
1) http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/datatypes.htm#i45907
To find just the time portion of a DATE variable, subtract the date
portion:date_variable - TRUNC(date_variable).
Nota:
formatear la fecha
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT = "dd-MON-yyyy" ';
Referencia funcin : TO_CHAR(date1 [,fmt]);
Fmt:
Parameter
Explanation
YEAR
YYYY
4-digit year
YYY
YY
Y
IYY
IY
I
IYYY
RRRR
MM
MON
MONTH
RM
WW
The week of the year (1-53) where week 1 starts on the first day of
the year and continues to the seventh day of the year.
The week of the month (1-5) where week 1 starts on the first day of
the month and ends on the seventh.
IW
DAY
DD
DDD
DY
HH
HH12
HH24
MI
Minute (0-59).
SS
Second (0-59).
SSSSS
FF
AD indicator
BC or B.C.
BC indicator
TZD
TZH
TZM
TZR
Ejplo:
Este ejemplo pasa a date , formatea y luego pasa a char con otro formato
select TO_CHAR (TO_DATE('0297','MM/YY'), 'YY/MM') from dual
The string to search. string can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or
NCLOB.
substring
The substring to search for in string. substring can be CHAR, VARCHAR2, NCHAR,
NVARCHAR2, CLOB, or NCLOB.
start_position
Optional. The position in string where the search will start. If omitted, it defaults to 1. The first
position in the string is 1. If the start_position is negative, the INSTR function counts
back start_position number of characters from the end of stringand then searches towards the
beginning of string.
nth_appearance
Optional. The nth appearance of substring. If omitted, it defaults to 1.
SUBSTR
SUBSTR( string, start_position [, length ] )
Parameters or Arguments
string
The source string.
start_position
The starting position for extraction. The first position in the string is always 1.
length
Optional. It is the number of characters to extract. If this parameter is omitted, the SUBSTR
function will return the entire string.
Note:
If start_position is 0, then the SUBSTR function treats start_position as 1 (ie: the first position in
the string).
If start_position is a positive number, then the SUBSTR function starts from the beginning of the
string.
If start_position is a negative number, then the SUBSTR function starts from the end of the string
ANDconjunction
ORinclusion
Ref: http://www.oracle.com/technetwork/issue-archive/2012/12-jan/o12plsql-1408561.html
DECLARE
a SIMPLE_INTEGER := 1;
b PLS_INTEGER := NULL;
BEGIN
a := b;
END;
/
Ejercicio 11) Esto es correcto ?
DECLARE
acct_id INTEGER(4) NOT NULL ;
begin
DBMS_OUTPUT.PUT_LINE( acct_id ) ;
end;
/