Skip to content

Instantly share code, notes, and snippets.

View develost's full-sized avatar

Massimiliano Bernabé develost

View GitHub Profile
@develost
develost / oracle_member_of_example.sql
Created May 17, 2018 13:52
Oracle example of MEMBER OF function
create type typ_number_table IS TABLE OF NUMBER;
declare
ptyp_list typ_number_table;
begin
ptyp_list := typ_number_table();
ptyp_list.extend;
ptyp_list(ptyp_list.last) := 88;
ptyp_list.extend;
ptyp_list(ptyp_list.last) := 90;
@develost
develost / get_remote_select.sql
Last active February 11, 2016 09:00
Postgres function compose a select statement from a dblink (remote) table
DROP FUNCTION IF EXISTS manager.get_remote_select(text, text, text, text[], text);
CREATE OR REPLACE FUNCTION manager.get_remote_select(dblink_name text,remote_schema_name text,remote_table_name text, remote_attribute_names text[], where_clause text)
RETURNS text AS
$BODY$
DECLARE
information_schema_query text;
information_schema_record record;
remote_attribute_name text;
remote_attribute_types text[] := '{}';
@develost
develost / Keyframes playground - engine demo.markdown
Created August 27, 2015 11:42
Keyframes playground - engine demo
@develost
develost / Keyframes playgound demo 01.markdown
Last active August 26, 2015 15:56
Keyframes playgound demo 01
@develost
develost / bulk_chown_tables_postgresql_pgscript.sql
Last active August 29, 2015 14:22
Bulk change owner tables in multiple schema postgres
---------------------------------------------------------------------------------
--- Bulk alter table owner for all tables in multiple schema
--- to be run into pgAdmin "Execute pgScript"
---------------------------------------------------------------------------------
--- hint: replace MY_USER with your actual user
SET @elements = select schemaname, tablename from pg_tables where schemaname in ('public','test','whatever');
SET @i = 0;
WHILE @i < LINES(@elements)
BEGIN
@develost
develost / pgbytea2file.py
Last active March 6, 2023 17:33
From postgres bytea to file (a PDF for example)
# Execute select in pgAdmin
# write result to file
"""
select encode(my_bin_field,'base64')
from my_schema.my_table
where id=123;
"""
# Remove column name from generated file
import base64