Skip to content

Instantly share code, notes, and snippets.

@joesavak
joesavak / gist:649590
Created October 27, 2010 18:02
Hello World from dual
select 'Hello World' from dual
@joesavak
joesavak / gist:649621
Created October 27, 2010 18:18
Dual example
select 'Hello World' from dual;
@joesavak
joesavak / gist:649722
Created October 27, 2010 19:05
Column names & order
select column_name, column_id
from user_tab_cols
where table_name = '&tableName'
order by 2
@joesavak
joesavak / gist:649730
Created October 27, 2010 19:09
get delimited row
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?
@joesavak
joesavak / easyAuditTrails.sql
Created November 5, 2010 16:48
Easy audit trails
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:664350
Created November 5, 2010 15:58
Easy Audit Trails
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 November 8, 2010 18:50
install oci8 driver
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 November 8, 2010 22:22
Ruby quick getter setter
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 November 9, 2010 13:51
Validation Numercality
validates :cost, :numericality=> {:greather_than => 0}
@joesavak
joesavak / config.yml
Created November 11, 2010 22:37
config.yml
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---