I tried the "documented" ways to get STDIN working, but it failed. So, I tried named pipes, and got the working on Windows. You could do something very similar on *nixy platforms with mknod/mkfifo
Control file:
LOAD DATA
INFILE '\\.\pipe\sql_pipe\'
REPLACE
INTO TABLE my_table
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(col1,col2,col3,col4)
Perl:
use strict;
use Win32::Pipe;
$|=1; # autoflush for messages
my $pipe_name = "sql_pipe";
my $pipe = new Win32::Pipe($pipe_name)|| die "Can't Create Named Pipe:
+ $!\n";
open(my $ldr,"|sqlldr.exe a/b\@c control=control.ctl log")
|| die "Unable to execute sqlldr: $!";
$pipe->Connect();
#... do something interesting to get data, and probably loop
$pipe->Write(join(",",$1,$2,$3,$4)."\n");
#...
$pipe->Disconnect();
$pipe->Close();
close $ldr;
Note: the pipe in the open was just a leftover from my first attempt... You could remove that and do something more sensible for launching sqlldr...
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.