package opt;

;#--- pod Start -----------------------------------------------------------#
=pod

=head1 NAME

opt.pm - 共通サブルーチン群（EUCコードで接続）

=cut
;#--- pod Start -----------------------------------------------------------#

use rpics;
@ISA = qw(rpics);
use strict;
use DBI;
use Jcode;
require 'optconfig.pl';

#------------------------------------------------------------------
sub new {
#------------------------------------------------------------------

=head2 ＤＢオープン [new]

optconfig.plの内容でＤＢをオープンして
データベースハンドルを返す

=cut
	my $class = shift;
	my $self ;
	my @user_pass = split( /\// , optconfig::initset() );
	my $user = $user_pass[0];
	my $pass = $user_pass[1];

	# shell変数セット
	local $ENV{ORACLE_HOME} = '/usr/lib/oracle/10.1.0.4/client';
	local $ENV{NLS_LANG} = 'JAPANESE_JAPAN.JA16EUC';
	local $ENV{NLS_LANGUAGE} = 'JAPANESE';

	eval{
		$self->{'dbh'} = DBI->connect('dbi:Oracle:SMTSV',$user,$pass)
			or die $DBI::errstr;
	};
	bless $self,$class;

	return  $self ;
}
#---------------------------------------------------------------#
sub look_up{
#---------------------------------------------------------------#

=head2 look_up

参照テーブルを参照する。

=cut

	my $s =shift;
	my ($sql,$para) = @_;
	my @para;
	for (@$para){
		if(ref($_) eq 'CODE'){
			push @para,&$_;
		}else{ push @para,$_;
		}
	}
	my $sth = $s->{dbh}->prepare(qq{$sql});
	$sth->execute(@para);
	my $ref = $sth->fetchrow_arrayref();
	return $ref;
}
sub Xeuc2sj{
	my $s = shift;
	my $text = shift;
	return $text;
}
sub Xsj2euc{
	my $s = shift;
	my $text = shift;
	return $text;
}
1;
__END__

=head1 AUTHOR INFORMATION

 ;######################################################################
 ;#
 ;# opt.pm: OPTSV ACCESS Sub Routine (EUC).
 ;#
 ;# Copyright (c) 2008 HORI Masashi <hori@japannet.co.jp>
 ;# JapanNet. All Rights Reserved.
 ;#
 ;#
 ;######################################################################

=cut

