ref cursor column names

declare l_ref sys_refcursor; l_cur integer; l_exe integer; l_sql varchar2(100) := ‘select * from <>’; l_tab dbms_sql.desc_tab; l_cnt integer; l_val varchar2(4000); l_num number; l_dat date; begin l_cur := dbms_sql.open_cursor; open l_ref for l_sql; dbms_sql.parse(l_cur, l_sql, dbms_sql.native); dbms_sql.describe_columns(l_cur,l_cnt,l_tab); for i in 1..l_cnt loop dbms_output.put_line(i||’ ‘||l_tab(i).col_name||’ ‘||l_val); — dbms_output.put_line(‘|- type : ‘||l_tab(i).col_type); — dbms_output.put_line(‘|- max_len : ‘||l_tab(i).col_max_len); — […]

move directories

I wanted to differentiate my movies into ones playable on dlna aware devices and others. ie my avi’s and mkv’s and mp4’s are ok. but files with reside into folders named video_ts need to be excluded. So how to mv all dir’s (in from current dir) where an avi exists into the dlna folder: find […]

plug my alcatel 3g modem in an usb3 port….

Cut ‘n Paste from some forum: In the last ‘upstream’ version of usb_modeswitch, there is an additional global option SetStorageDelay in the config file “/etc/usb_modeswitch.conf”. You can set this to “3” or anything else, and usb_modeswitch will check if this is the minimum value and set it accordingly via the respective sysfs attribute.

oracle xml quicky

declare c_x sys_refcursor; l_xml_ xmltype; begin open c_x for select t.a,t.b,t.c from zzz_test t; select t.xml_ into l_xml_ from xmltable(‘/’ passing xmltype(c_x) columns xml_ xmltype path ‘.’) t; dbms_output.put_line(l_xml_.getclobval()); end; <?xml version=”1.0″?> <ROWSET> <ROW> <A>1</A> <B>Some text</B> <C>6</C> </ROW> <ROW> <A>7</A> <B>Some other text</B> <C>5</C> </ROW> <ROW> <A>8</A> <C>4</C> </ROW> </ROWSET>

And now for something completely different….

POSTGRESQL Why didn’t I think off that before. $johannes@ubuntu:~$ sudo apt-get install postgresql $johannes@ubuntu:~$ sudo apt-get install postgresql-doc login: sudo -u postgres psql postgres change password: \password postgres create database johannes; create user johannes; ctrl D ~$ psql johannes=> create table test (a varchar(10)); insert into test (a) values(‘b’); commit; \password CTRL D …..  

Some Oracle session information

select s.process,s.status ,s.username,s.schemaname ,s.sid,s.serial# ,to_char(s.logon_time,’dd-mm-yyyy hh24:mi’) logon_time ,substr(sq.sql_text,1,25) sql_txt from v$session s left outer join v$sql sq on s.sql_id = sq.sql_id order by 5; And kill some session: ALTER SYSTEM KILL SESSION ‘sid,serial#’;

chrooted sftp

chrooted sftp: $ sudo adduser –shell /bin/false pietjepuk password: $ /home $ sudo chown root:pietjepuk /home/pietjepuk/ $ sudo chmod 755 /home/pietjepuk/ $ sudo vi /etc/ssh/sshd_config comment de regel waar sftp server wordt bepaald: #Subsystem sftp /usr/lib/openssh/sftp-server En voeg het volgende onderaan toe: Subsystem sftp internal-sftp Match User pietjepuk ChrootDirectory %h ForceCommand internal-sftp X11Forwarding no AllowTCPForwarding […]

json kladblok $.getJSON( “ajax/test.json”, function( data ) { var items = []; $.each( data, function( key, val ) { items.push( “ ” + val + “ ” ); }); $( “ “, { “class”: “my-new-list”, html: items.join( “” ) }).appendTo( “body” ); }); jQuery(‘ ‘, { id: ‘foo’, href: ‘’, title: ‘Become a Googler’, rel: […]

bulk update with exception handling

CREATE TABLE tmp_table (aaa VARCHAR2(100) NOT NULL); DECLARE TYPE t_varchar IS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER; a_varchar t_varchar; e_bulk_errors EXCEPTION; t_error_index PLS_INTEGER; PRAGMA EXCEPTION_INIT(e_bulk_errors,-24381); BEGIN a_varchar(1) := ‘aaa’; a_varchar(2) := NULL; a_varchar(4) := NULL; a_varchar(5) := ‘eee’; a_varchar(7) := ‘fff’; a_varchar(8) := ‘ggg’; a_varchar(9) := NULL; FORALL i IN INDICES OF a_varchar SAVE EXCEPTIONS […]