Re: load a table with some null lines
Posted in 2001
If you are just loading the report files to store them why not
just load them into a blob?
we do that to archive important jobs, we compress them first and
then load em up, code snippet follows.
function hp_store_file (p_jobname)
define p_jobname char (250)
define progname char (18),
dbname char (18),
run_cmd char (250),
new_id smallint,
data_blob byte
# Determine the program name from basename `pwd`
let run_cmd = "basename `pwd` > /tmp/", hp_username () clipped,
".size"
run run_cmd
let run_cmd = "/tmp/", hp_username () clipped, ".size"
# c_readfile does its nut with the above, so load it
create temp table hp_tempst1
( line char (250)) with no log;
load from run_cmd insert into hp_tempst1
select * into progname from hp_tempst1
drop table hp_tempst1;
let run_cmd = "/bin/echo Loading... ; ",
" /usr/local/bin/gzip -vc9 ", p_jobname clipped, " > ",
" /tmp/", hp_username () clipped, ".size"
run run_cmd
let run_cmd = "/tmp/", hp_username () clipped, ".size"
# Load her up
locate data_blob in file run_cmd
select max (rpa_id) + 1
into new_id
from reparchive
where rpa_progname = progname
if new_id is null then let new_id = 1 end if # Patch around first
time
insert into reparchive values (progname,
user, current, new_id, p_jobname,
data_blob)
# Clean up (free dumps the file!)
free data_blob
end function
brett
Gary Quiring wrote:
>
> On Wed, 3 Jan 2001 12:26:01 -0500 (EST), Colin McGrath
> <cmm@trac3000.ueci.com> wrote:
>
> >
> >Couldn't you just clean up the data first?
> >
> >grep -v '^$' tab1.unl > tab2.unl
> >
> >or add a pipe "|" at the end?
> We currently did a tr and changed the new line to a pipe. But I would
> really like to know how to load the data without constantly running a unix
> script. This is not a one time deal, we have a need to parse about 3,000
> print files per day.
>
> Thanks
> Gary
>
> >Gary Quiring wrote:
> >>
> >> I'm trying to load a print file into a table. The print file does not have
> >> any control characters, but it does have some lines with just line feeds
> >> and no data. I keep getting ' 846: Number of values in load file is not
> >> equal to number of columns.'
> >>
> >> I just want to declare a 132 char variable and bring in each print line.
> >> Is there a way of loading the data and not using TEXT as the type.
> >>
> >> Thanks
> >> Gary Quiring
> >>
> >>
> >>
--
-----------------------------------------------------------------
Brett's 11th law of UNIX administration...
Users think that Y2K was a non-event... well... They havn't got
our overtime bills yet :)
-----------------------------------------------------------------
Brett Geer - UNIX Admin/Analyst/Programmer - Intratex Holdings.
Tel. +27 31 717 4000 Direct. +27 31 717 4146
Fax. +27 31 717 4001
-----------------------------------------------------------------
The little voices are talking to me again, telling me to reach
for a keyboard and type rm -rf /*
last week they had me rm -rf `echo $MANPATH | sed 's/:/ /g'`
now I fear I have no answers
-----------------------------------------------------------------