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... |