Dear Monks,

Perl newbie here.

I am looking to write some queries/stored procedures to return table, insert them into temp table and export that to flat file. While running, the perl program continues to throw "table or view does not exist" in runtime. I also am unable to see the temp table in my database.

Please can you help me understand what is wrong here...



# load all the libraries use DBI; use Config::IniFiles; use warnings; use strict; my $dbconfig = Config::IniFiles->new(-file => "C:/Users/Me/Documents/d +ev/perl/project1/dbcredentials.ini"); my $dbname = $dbconfig->val('myoracle','dbname'); my $driver = $dbconfig->val('myoracle','driver'); my $host = $dbconfig->val('myoracle','host'); my $sid = $dbconfig->val('myoracle','sid'); my $username = $dbconfig->val('myoracle','username'); my $password = $dbconfig->val('myoracle','password'); my $port = $dbconfig->val('myoracle','port'); my $dsn = "dbi:$driver:host=$host;sid=$sid;port=$port"; my $dbh = DBI->connect($dsn,$username,$password) or die $DBI::errstr; $dbh->do("CREATE GLOBAL TEMPORARY TABLE HR.Tempest( ID INT, NAME VARCHAR2(25), TITLE VARCHAR2(50), DEPT VARCHAR2(100) ) ON COMMMIT PRESERVE ROWS"); $dbh->commit(); my $sth = $dbh->prepare(" select e.employee_id, e.first_name, j.job_title,d. department_name + from HR.employees e, HR.jobs j, HR.departments d where e.job_id = j.job_id and e.department_id = d.department_id "); $sth->execute or die "cant execute SQL statement"; my @row; while (@row = $sth->fetchrow_array()){ my $id = @row[0]; my $name = @row[1]; my $title = @row[2]; my $dept = @row[3]; my $insert1 = $dbh->do(" INSERT INTO HR.Tempest ( ID, NAME, TITLE, DEPT ) VALUES ( $id, '$name', '$title', '$dept' ) "); ###$insert1->execute() or die "{ERROR} - ". $insert1->errstr; ###print"@row\n\n"; } my $resultset = $dbh->prepare("Select * from Tempest"); while(@row = $resultset->fetchrow_array()){ print"@row\n\n"; } $dbh->disconnect() or warn "error disconnecting"; exit;

In reply to oracle temp table does not exist by SpaceCowboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.