multiple layout in for a singlr file
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.

12»»

multiple layout in for a singlr file Expand / Collapse
Author
Message
Posted 10/15/2006 5:49:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/29/2006 2:44:00 AM
Posts: 4, Visits: 1
hi this is raul

is it possible in mload to use different layout for same infile,
i mean i am receving data in which one occurence of column is of datatype integer and the other occurence of data is of datatype varchar -- i hope i made it clear

kindly can u reply fast, it will solve one of the major problem hindering me to go ahead in my university project


Rocky

Post #5529
Posted 10/18/2006 3:16:37 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/5/2009 4:40:02 PM
Posts: 717, Visits: 466
Hi Raul,
yes, should be possible.
Could you post some more details, file layout, example records etc.

Dieter
Post #5550
Posted 10/19/2006 2:12:15 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/29/2006 2:44:00 AM
Posts: 4, Visits: 1
dnoeth the following is the records which i am receving

these are just an example records which i am trying to test

12|2.3|b
10|c|t

if u observe in the above record i am getting 2,3 which is of decimal datatype and in second record 'c' which is of character datatype

one solution whic i could come up was i used .accept command of mload like this

.accept flag from ignore 1 to 3 --which will enable me to catch the data prsent in third column i.e either 'b' or 't' --iam doing this because based on 'b'or 't' only my records are going to get varied then iam using following layouts

layout test1
.field c1 * integer
.field c2 * deciaml(4,1)
.filed c3 * varchar(2)

layout test2
field c1 * integer
.field c2 * varchar(4)
.filed c3 * varchar(2)

later iam using if else conditional statements of mload,
it's working fine no errors but while loading data of 1st record type some garbage value is going into my target table

while loading data of second record type it was loading properly

my target table datatypes are

c1:ineteger
c2:varchar(20)
c3:varchar(2)

regards
raul


Rocky

Post #5565
Posted 10/19/2006 8:14:01 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/5/2009 4:40:02 PM
Posts: 717, Visits: 466
Hi Raul,
ACCEPT and IF/ELSE are the wrong places, you have to redefine the input layout and use different APPLYs, e.g.

.layout test;
.field c1 * integer;
.field c2d * decimal(4,1);
.field c2v 3 varchar(4); -- redefine the input position
.field c3 * varchar(2);

.dml label l1;
sql for c3='b'

.dml label l1;
sql for c3='t'

.IMPORT ...
FORMAT ???
LAYOUT test
APPLY l1 WHERE c3 = 'b'
APPLY l2 WHERE c3 = 't';


Regading the input records, what's the FORMAT: BINARY\TEXT\VARTEXT?
Is it readable information or binary data?

Dieter
Post #5567
Posted 10/20/2006 2:43:11 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/29/2006 2:44:00 AM
Posts: 4, Visits: 1
thanks dieter

the solution was good, as you have asked regarding the format of data,according to my perception it will in text i guess but it is just an asumption because my prof didnot told me the exact situtaion yet

as a matter of curisosity can u confirm why the .accept and if/else commands was not fealisble for this kind of problems.


Rocky

Post #5579
Posted 10/20/2006 4:43:02 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/5/2009 4:40:02 PM
Posts: 717, Visits: 466
Hi Raul,
if the input format is readable text or vartext, then you don't specify DECIMAL within the FIELD, it's CHAR or VARCHAR. The cast will be done automatically or by using CAST(col as DEC(..)) within the Insert.

ACCEPT reads a *single* row from input, but you want to load a file with lots of rows in different formats.
Check the manuals for "redefining the layout".

You talked about your prof, so out of curiosity:
Which university offers Teradata classes?

Dieter
Post #5580
Posted 10/20/2006 9:08:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/29/2006 2:44:00 AM
Posts: 4, Visits: 1
thanks dieter for prompt reply .

as u have asked i stduy jere in INDIA in IIT Bombay



Rocky

Post #5581
Posted 5/27/2009 11:18:01 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 10/29/2009 2:48:53 AM
Posts: 94, Visits: 321
Hi Forum Masters,

I was facing the same problem as described in this post...

I am not getting how this repositioning really works...

Suppose my input records are

12|2.3|b

10|c|t



layout is

.layout test;

.field c1 * integer;

.field c2d * decimal(4,1);

.field c2v 3 varchar(4); -- redefine the input position

.field c3 * varchar(2);



client will read 12 store it in field c1...next is 2.3 stored in c2d after that it will reposition and again come to 3rd position that is 2of decimal 2.3 or directly go to c....basically not able to get what will happen to 'b'



Please throw some insight how exactly it is going on.......

Your help will make all of us better understand this redefining the input concept Gurus
Post #15540
Posted 5/28/2009 12:32:47 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 10/29/2009 2:48:53 AM
Posts: 94, Visits: 321
Would be appreciable if you throw some light please..............
Post #15555
Posted 5/29/2009 2:50:16 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 8/24/2009 7:41:51 AM
Posts: 12, Visits: 55
Prakhar,

Layout reflects the source file format.
So in the case above it will check data field by field, when it encounters decimal it will go with c2d skips c2v and goes on as you have correctly mentioned.

For the 2nd scenario of c3='t', it will encounter varchar which is not of data type decimal as in layout, so the pointer is lost as it does not matches with the field type, but as we specified position 3, so it will start reading from that field onwards and take the field as varchar.

Hope it helps...

Ankit


Regards

Ankit
Post #15581
« Prev Topic | Next Topic »

12»»

Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 5:16pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.047. 6 queries. Compression Disabled.