use strict;
use warnings;
use DBD::Oracle qw(:ora_types);
use DBI;
use constant SqlOracle => 'C:\oraclexe\app\oracle\product\10.2.0\server\BIN\sqlplus.exe\\';
use constant User => 'system';
use constant Pass => '12345';
use constant DB => 'XE';
print "Test Show Valeu : $0\n";
my $dbh = DBI->connect("dbi:Oracle:".DB,User,Pass) or die $!;
my $CreateTable = "CREATE TABLE EMPREGADO (codigo number(6) primary key, nome varchar2(25) not null, salario number(11,2))";
my $sth = $dbh->prepare($CreateTable);
$sth->execute();
$sth = $dbh->prepare( q{INSERT INTO EMPREGADO (codigo,nome,salario) VALUES(?,?,?)}) or die $dbh->errstr;
open(IN,"pessoas.txt") or die $!;
while(<IN>){
chomp;
my($codigo,$nome,$salario) = split (/\t/,$_);
$sth->execute($codigo,$nome,$salario) or die $dbh->errstr;
}
close(IN);
$dbh->disconnect;
------------------------------------------------------------------------------------------------------------
SQL> desc empregado;
Nome Nulo? Tipo
----------------------------------------- -------- ----------------------------
CODIGO NOT NULL NUMBER(6)
NOME NOT NULL VARCHAR2(25)
SALARIO NUMBER(11,2)
SQL> select * from empregado;
CODIGO NOME SALARIO
---------- ------------------------- ----------
1 joao 10
2 maria 80
3 jose 60
------------------------------------------------------------------------------------------------------------
pessoas.txt
1 joao 10
2 maria 80
3 jose 60
0 comentários:
Post a Comment