Skip to content

Instantly share code, notes, and snippets.

@joesavak
joesavak / gist:649590
Created Oct 27, 2010
Hello World from dual
View gist:649590
select 'Hello World' from dual
View gist:649621
select 'Hello World' from dual;
@joesavak
joesavak / gist:649722
Created Oct 27, 2010
Column names & order
View gist:649722
select column_name, column_id
from user_tab_cols
where table_name = '&tableName'
order by 2
@joesavak
joesavak / gist:649730
Created Oct 27, 2010
get delimited row
View gist:649730
create or replace function getDelimRow(i_table_name varchar2, i_delim varchar2, i_rowNumber number) return varchar2 is
Result varchar2(2000); --delimited string that will be returned
execSql varchar2(2000); --sql to execute to get delimited string
l_colName varchar2(2000); --column name from user_tab_cols for the table passed in
concatCols varchar2(2000); --all cols concated together to be part of the execsql var.
cursor l_cur is
select column_name
from user_tab_cols
where table_name = upper(i_table_name)
order by column_name; --i know, cursors are bad. Got a suggestion?
View gist:649803
#!/usr/bin/perl
use strict;
use LWP::Simple;
my $url = 'http://site/files';
my $file = 'fileName';
getstore( "$url/$file", $file );
@joesavak
joesavak / gist:664350
Created Nov 5, 2010
Easy Audit Trails
View gist:664350
create or replace trigger master_table_audit
after insert or update or delete on master_table
for each row
--
begin
if UPDATING then
insert into audit_table (
pk_uid
,edit_user
,edit_datetime
View easyAuditTrails.sql
create or replace trigger master_table_audit
after insert or update or delete on master_table
for each row
--
begin
if UPDATING then
insert into audit_table (
pk_uid
,edit_user
,edit_datetime
@joesavak
joesavak / gist:668076
Created Nov 8, 2010
install oci8 driver
View gist:668076
gem install ruby-oci8
1 gem installed
Installing ri documentation for ruby-oci8-2.0.4-x86-mingw32...
Installing RDoc documentation for ruby-oci8-2.0.4-x86-mingw32...
@joesavak
joesavak / gist:668381
Created Nov 8, 2010
Ruby quick getter setter
View gist:668381
class Product
attr_accessor :external_id #automagically create reader & writer methods
attr_reader :internal_id #automagically create reader method
attr_writer :product_id #automagically create writer method
end
@joesavak
joesavak / Numericality?
Created Nov 9, 2010
Validation Numercality
View Numericality?
validates :cost, :numericality=> {:greather_than => 0}