Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen a piped process (sqlplus) in perl and get information from the query?
    primarykey
    data
    text
    <p>Basically, I'd like to <code>open</code> a pipe to sqlplus using Perl, sending a query and then getting back the information from the query.</p> <p>Current code:</p> <pre><code>open(PIPE, '-|', "sqlplus user/password@server_details"); while (&lt;PIPE&gt;) { print $_; } </code></pre> <p>This allows me to jump into sqlplus and run my query.</p> <p>What I'm having trouble figuring out is how to let Perl send sqlplus the query (since it's always the same query), and once that's done, how can I get the information written back to a variable in my Perl script?</p> <p>PS - I know about <code>DBI</code>... but I'd like to know how to do it using the above method, as inelegant as it is :)</p> <hr /> <p>Made some changes to the code, and I can now send my query to sqlplus but <strong>it disconnects</strong>... and I don't know how to get the results back from it.</p> <pre><code>my $squery = "select column from table where rownum &lt;= 10;" # Open pipe to sqlplus, connect to server... open(PIPE, '|-', "sqlplus user/password@server_details") or die "I cannot fork: $!"; # Print the query to PIPE? print PIPE $squery; </code></pre> <p>Would it be a case of grabbing the <code>STDOUT</code> from sqlplus and then storing it using the Perl (parent) script?</p> <p>I'd like to store it in an array for parsing later, basically.</p> <p>Flow diagram:</p> <p>Perl script (parent) -> open pipe into sqlplus (child) -> print query on pipe -> sqlplus outputs results on screen (STDOUT?) -> read the STDOUT into an array in the Perl script (parent)</p> <hr /> <p><strong>Edit</strong>: It could be that forking the process into sqlplus might not be viable using this method and I <em>will</em> have to use DBI. Just waiting to see if anyone else answers...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload