Skip to content

Instantly share code, notes, and snippets.

@alexishida
Last active December 7, 2021 12:47
Show Gist options
  • Select an option

  • Save alexishida/3caf4e27002329d664321d0e4eb10105 to your computer and use it in GitHub Desktop.

Select an option

Save alexishida/3caf4e27002329d664321d0e4eb10105 to your computer and use it in GitHub Desktop.
ruby simple oracle dao connector
# frozen_string_literal: true
require 'oci8'
module Connector
class Oracle
def initialize
@con = OCI8.new(ORACLE_CONFIG['user'], ORACLE_CONFIG['password'], ORACLE_CONFIG['host'])
end
def consultar(sql)
cursor = @con.parse(sql)
cursor.exec
return cursor
end
def consulta_retorno(sql)
dados = []
cursor = @con.parse(sql)
cursor.exec
cursor.fetch do |row|
dados << row
end
return dados
end
def executar(sql)
cursor = @con.parse(sql)
cursor.exec
end
def commit()
@con.commit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment