Skip to content

Instantly share code, notes, and snippets.

View hackvan's full-sized avatar
🇨🇴

Diego Camacho hackvan

🇨🇴
View GitHub Profile
@hackvan
hackvan / arreglos_clave_valor.sql
Last active January 8, 2016 15:38
PL/SQL Oracle: Utilizar arreglos del tipo clave -> valor
Declare
pevc_codlibori sfci001t.codlibro%Type := 'PUC001';
pevc_codctaori sfci001t.codctaco%Type := '244001';
pevc_nivan1ori sfci019t.nivanal1%Type := 'TNEG';
pevc_codan1ori sfci019t.codniva1%Type := '1234';
pevc_nivan2ori sfci019t.nivanal2%Type := 'NIT';
pevc_codan2ori sfci019t.codniva2%Type := '5678';
pevc_nivan3ori sfci019t.nivanal3%Type := 'VIGE';
pevc_codan3ori sfci019t.codniva3%Type := '2016';
pevc_nivan4ori sfci019t.nivanal4%Type;
@hackvan
hackvan / example-continue.sql
Created May 16, 2016 16:49
PL/SQL Oracle: Uso de la instrucción "continue" en un ciclo For.
Declare
Cursor cuprincipal Is
Select '1' as Data From dual
Union
Select '2' as Data From dual
Union
Select '3' as Data From dual
Union
Select '4' as Data From dual
Union
@hackvan
hackvan / getCodeSeq.sql
Created May 18, 2016 13:28
PL/SQL Oracle: Ejemplo del uso del "For Update Of" y "Current Of"
Create Or Replace Function getCodSeq(xcodseque In Varchar2,xtam In Number Default Null) Return Varchar2 Is
xvalseque sfad012t.valseque%Type;
xcodprefi sfad012t.codprefi%Type;
xseque Varchar2(50);
Cursor c1 Is
Select nvl(valseque, 0) + nvl(incseque, 1), codprefi
Into xvalseque, xcodprefi
From sfad012t
Where codseque = xcodseque
For Update Of valseque;
@hackvan
hackvan / exception_init.sql
Created May 18, 2016 13:56
PL/SQL Oracle: Ejemplo con el uso del "Pragma Exception_Init"
Create Or Replace Procedure do_something(pevc_codbanco In Varchar2) Is
row_locked Exception;
Pragma Exception_Init(row_locked, -54); -- ORA-00054: recurso ocupado y obtenido con NOWAIT especificado o timeout vencido
Begin
For cc In (Select codbanco From sfcp005t Where codbanco = pevc_codbanco For Update Nowait) Loop
Exit;
End Loop;
Exception
When row_locked Then
raise_application_error(-20001, 'this row is locked...', False);
@hackvan
hackvan / DDL_test_table.sql
Created May 18, 2016 14:35
PL/SQL Oracle: Ejemplo del uso de la sentencia FOLLOWS en los triggers
CREATE TABLE test (
testcol VARCHAR2(15));
INSERT INTO test VALUES ('dummy');
COMMIT;
@hackvan
hackvan / zsh.md
Last active September 15, 2016 02:37 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@hackvan
hackvan / define_exception_for_currval.sql
Created February 23, 2017 16:53
How to create a custom exception for the use of CURRVAL on sequences.
Declare
nextvalnotfound Exception;
Pragma Exception_Init(nextvalnotfound, -08002);
lc_secuencia Number;
Begin
SELECT sfps010s.currval INTO lc_secuencia FROM dual;
Exception
When nextvalnotfound Then
dbms_output.put_line('NextVal is not found it!');
When Others Then
@hackvan
hackvan / postgres-cheatsheet.md
Last active July 6, 2017 23:39 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

To have launchd start postgresql now and restart at login:

brew services start postgresql

Or, if you don't want/need a background service you can just run:

pg_ctl -D /usr/local/var/postgres start
@hackvan
hackvan / .bash_profile
Created July 19, 2018 01:54
Dot Files - MBP
export PATH="/usr/local/bin:$PATH"
@hackvan
hackvan / 2_dummy.php
Last active September 12, 2018 16:52
<?php
$x = 0;
$x = $x + 1;
$x = $x + 2;
$x = $x + 3;
print($x);
?>