Home » RDBMS Server » Server Utilities » sqlldr loading multiple lines
sqlldr loading multiple lines [message #130651] Mon, 01 August 2005 17:26 Go to next message
hboen
Messages: 5
Registered: March 2005
Junior Member
Hi,

I am a bit stuck to assemble a controlfile for the following record layout:

1,3,2,1,,0,0,,,,1,2,1,2,2,"De echtgenote is matig belastbaar.
Mw. heeft een te lage bloeddruk. Mw. is onder behandeling bij dr. Korts cardioloog in het Flevo-zh.
Mw. mist 1 nier. Mw. geeft aan de laatse jaren geregeld duizelig te zijn ze is sneller moe tgv zowel psychische als somatische faktoren.
Mw. geeft aan dat de psychische belasting qua de zorg voor haar man groot is zijn gedrag is moeilijk om mee om te gaan.
Mw. en haar kinderen geven aan dat mw. nooit een activiteit rustig kan doen snel naar huis moet om weer voor haar man te zorgen. Rust nemen is moeilijk gezien de relatie die zij hebben.
Mw. heeft al jaren last van haar rug. Het liggen is pijnlijk voor haar s nachts slaapt mw. daardoor al jaren slecht. Tevens gaat mw. 's nacht om de 2 uur naar het toilet. Haar man vraagt s nacht ook de nodige zorg ivm incontinentieproblemen.
Mw. doet de boodschappen met de bus. Het tillen van de boodschappen wordt steeds zwaarder.
Fietsen doet mw. niet meer sinds ze is gevallen (tgv gejaagdheid vlg de kinderen).
Mw. is zelfstandig wat betreft de persoonlijke verzorging.",3,2,"De echtgenote van de heer geeft aan ontlast te worden indien de heer s morgens geholpen wordt bij het wassen/kleden en de heer 1 dag extra naar de dagverzorging gaat in Buitenhaege. Dit ontlast haar zowel lichamelijk als geestelijk.
Mevrouw heeft af en toe ook vakantie nodig. Daarom voorgesteld om Verblijf Tijdelijk( met interval/ intermitterend) te indiceren zodat meneer af en toe opgenomen kan worden ter ontlasting van de mantelzorg.","OB-alg wordt geadviseerd ter ontlasting van de informele zorg.
Mevrouw heeft af en toe een uitlaatklep nodig iemand om te praten anders houdt zij de zorg niet vol. Alles is nu gericht op haar man.
Zij is bij de vereniging van Mantelzorgers geweest maar daar krijgt ze andermans problemen erbij zegt ze."
3,,2,,,0,0,,,,,,,,,"",,2,"",""
9,3,3,3,,0,0,,,,,2,,,,"Mw. van Dijk (buurvrouw) helpt mw. dagelijks een aantal keren tijdens de dag.
Zij neemt veel taken over, biedt structuur, ondersteuning en begeleiding en toezicht.
's Morgens: Handdoeken verwijderen uit het bed. Mw. gaat dan in de tussentijd douchen. De buurvrouw maakt ontbijt en koffie.
's middags verzorging van de lunch.
's Avonds kookt mw. en doet de afwas.
Wat later op de avond verzorgt de buurvrouw nog een advocaatje.
1 keer per week draaidt de buurvrouw 2 wassen ivm de handdoeken op bed en laat ze de matras luchten.
Mw. geeft aan niet overbelast te zijn en de activiteiten tot opname van mw. te willen voortzetten. Overname is niet gewenst o.a. omdat de buurvrouw verwacht dat dit onrust bij mw. ten Damme tot gevolg zal hebben. Het belang van vaste afspraken en vaste tijdstippen van activiteiten is groot.",,,"",""
10,3,,,,0,0,,,,,,,,,"",3,,"",""

(4 records)

load data
infile 'c:\gino\data\INFZORG.csv' "str X'0A'"
replace
into table INFZORG
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
ID INTEGER EXTERNAL
,NUM1 INTEGER EXTERNAL
,NUM2 INTEGER EXTERNAL
,NUM3 INTEGER EXTERNAL
,NUM4 INTEGER EXTERNAL
,NUM5 INTEGER EXTERNAL
,NUM6 INTEGER EXTERNAL
,NUM7 INTEGER EXTERNAL
,STR1 CHAR
,STR2 CHAR
,NUM8 INTEGER EXTERNAL
,NUM9 INTEGER EXTERNAL
,NUM10 INTEGER EXTERNAL
,NUM11 INTEGER EXTERNAL
,NUM12 INTEGER EXTERNAL
,STR13 CHAR(4000)
,NUM14 INTEGER EXTERNAL
,NUM15 INTEGER EXTERNAL
,STR16 CHAR(4000)
,STR17 CHAR(4000)
)

It just refused the first record (missing the closing character " )...

Please help,

Thanks

Henk B
Re: sqlldr loading multiple lines [message #130707 is a reply to message #130651] Tue, 02 August 2005 01:50 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9097
Registered: November 2002
Location: California, USA
Senior Member
Use CONTINUEIF as shown below.

load data
infile 'c:\gino\data\INFZORG.csv' "str X'0A'"
replace
CONTINUEIF LAST <> '"'
into table INFZORG
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
ID INTEGER EXTERNAL
,NUM1 INTEGER EXTERNAL
,NUM2 INTEGER EXTERNAL
,NUM3 INTEGER EXTERNAL
,NUM4 INTEGER EXTERNAL
,NUM5 INTEGER EXTERNAL
,NUM6 INTEGER EXTERNAL
,NUM7 INTEGER EXTERNAL
,STR1 CHAR
,STR2 CHAR
,NUM8 INTEGER EXTERNAL
,NUM9 INTEGER EXTERNAL
,NUM10 INTEGER EXTERNAL
,NUM11 INTEGER EXTERNAL
,NUM12 INTEGER EXTERNAL
,STR13 CHAR(4000)
,NUM14 INTEGER EXTERNAL
,NUM15 INTEGER EXTERNAL
,STR16 CHAR(4000)
,STR17 CHAR(4000)
)
icon14.gif  Re: sqlldr loading multiple lines [message #130821 is a reply to message #130707] Tue, 02 August 2005 14:03 Go to previous messageGo to next message
hboen
Messages: 5
Registered: March 2005
Junior Member
Thanks,

the continueif last do the trick.

Henk
Re: sqlldr loading multiple lines [message #131491 is a reply to message #130707] Sun, 07 August 2005 11:09 Go to previous messageGo to next message
hboen
Messages: 5
Registered: March 2005
Junior Member
Hi Barbara,

I tried the same logic for the following data file but does not load...

I Have the following ctl-file
Load data
infile 'c:\gino\aanvraag.csv' "str X'0A'"
replace
CONTINUEIF LAST <> '"'
into table AANVRAAG
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
ID INTEGER EXTERNAL
,NUM1 INTEGER EXTERNAL
,STR1 CHAR
,STR2 CHAR
,STR3 CHAR
,NUM2 INTEGER EXTERNAL
,NUM3 INTEGER EXTERNAL
,NUM4 INTEGER EXTERNAL
,NUM5 INTEGER EXTERNAL
,NUM6 INTEGER EXTERNAL
,STR4 CHAR(4000)
,STR5 CHAR
)

with data like

13,7,"13",6/4/1994,25/2/1994,,,,,10001,"",25/2/1994
16,7,"16",27/6/1994,18/5/1994,,,,,10001,"",18/5/1994
7337,7,"7337",30/10/1999,20/9/1999,,,,,10001,"mevr heeft een scootmobiel gekregen in 1999, mevr durft er niet meer op te rijden en hij staat al een poosje in de schuur bij haar zoon.

Graag de scootmobiel op laten halen bij de zoon. adres; Dhr Musch
Rstraat 16
Almere, nnn- nnnnnnnnn/06-nnnnnnnnn..
Betreft mevr xxxx
De xxxxxx 46
xxx xxx
12323321
clientnr; nnnnn",20/9/1999
7338,7,"7338",27/4/1999,18/3/1999,,,,,10001,"",18/3/1999

will not load the data

if I used
Load data
infile 'c:\gino\aanvraag.csv'
--infile 'c:\gino\aanvraag.csv' "str X'0A'"
replace
---CONTINUEIF LAST <> '"'
into table AANVRAAG
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
ID INTEGER EXTERNAL
,SOORTAANVRAAG INTEGER EXTERNAL
,AANVRAAGNUMMER CHAR
,UITERSTEBESLUITDATUM CHAR
,AANVRAAGDATUM CHAR
,WIJZEAANVRAAG INTEGER EXTERNAL
,SOORTAANVRAGER INTEGER EXTERNAL
,AANVRAGER INTEGER EXTERNAL
,MEDEWERKER INTEGER EXTERNAL
,STATUS INTEGER EXTERNAL
,HULPVRAAG CHAR(4000)
,ARCHIEFDATUM CHAR
)

it will load the first 2 records and last record but not the third (beginning with 7337)

Thanks,

Greetings,

Henk B

[Updated on: Sun, 07 August 2005 15:42]

Report message to a moderator

Re: sqlldr loading multiple lines [message #131493 is a reply to message #131491] Sun, 07 August 2005 16:43 Go to previous message
Barbara Boehmer
Messages: 9097
Registered: November 2002
Location: California, USA
Senior Member
Continueif has some limitations. It can check characters based on their positions in the current line or next line or the last single character of the current line. So, I don't think you can load it as is in one run of SQL*Loader. What you can do is load it into a staging table, where each row is loaded into a one-column record, use an update statement to identify the last rows of each record and add an ending character, spool the results back to a .csv file, then load it using continueif, trimming the ending character during the load. I was trying to figure what you could use to identify the end of a record. It looks like each record ends with a / and a four-digit year, so perhaps you could check for whether the fifth character from the end is /. I tested the following and it worked with the sample data that you provided.

-- contents of first_load.ctl:
Load data
infile 'aanvraag.csv'
replace
into table staging
fields terminated by X'0A'
(whole_row)


-- fix data:
-- create staging table:
CREATE TABLE staging
  (whole_row VARCHAR2(2000))
/
-- load data into staging table:
HOST SQLLDR scott/tiger CONTROL=first_load.ctl LOG=first_load.log
-- add * at the end of each record:
UPDATE staging
SET    whole_row = whole_row || '*'
WHERE  SUBSTR (whole_row, -5, 1) = '/'
/
-- spool the data to staging.csv:
STORE  SET saved_settings REPLACE
SET    ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF
SPOOL  staging.csv
SELECT * FROM staging
/
SPOOL  OFF
START  saved_settings


-- contents of second_load.ctl:
Load data
infile 'staging.csv'
replace
CONTINUEIF LAST <> '*'
into table AANVRAAG
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
ID INTEGER EXTERNAL
,NUM1 INTEGER EXTERNAL
,STR1 CHAR
,STR2 CHAR
,STR3 CHAR
,NUM2 INTEGER EXTERNAL
,NUM3 INTEGER EXTERNAL
,NUM4 INTEGER EXTERNAL
,NUM5 INTEGER EXTERNAL
,NUM6 INTEGER EXTERNAL
,STR4 CHAR(4000)
,STR5 "RTRIM (:str5, '*')"
)


-- load data:
HOST SQLLDR scott/tiger CONTROL=second_load.ctl LOG=second_load.log


Previous Topic: is there a way to script a schema without toad??
Next Topic: Oracle Management Server Installation
Goto Forum:
  


Current Time: Thu Jul 04 05:34:11 CDT 2024