Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi to everyone...
I have this problem about loops:
there is a long string that i have to divide in different parts but i'd like to use a cycle instead of rewriting many times the same code, changing the values in the SUBTRING FUNCTION!
this is my code:
SET Y= 9
FOR A=1 TO 10
TABLE_1:
SELECT SUBSTR(XXX, Y, 15) AS COLUMN_A
FROM TAB
LET Y=Y+15
NEXT
I'm glad of receive suggestions!!!
i'm really new
thanks to everyone!!
I could reach the aim
but with MID and LOAD it doesnt work!!
this is the perfect result i got:
SET Y=9;
FOR A=1 TO 10
SELECT
SUBTR(TAB.F1, $(Y), 15)
FROM TAB
/*WHERE XXX*/;
LET Y=$(Y)+15;
NEXT
You missed some semicolons and use the wrong function(?)
SET Y= 9;
FOR A=1 TO 10
TABLE_1:
LOAD
mid(F1, $(Y), 15) AS COLUMN_A
RESIDENT
TAB;
LET Y= $(Y) + 15;
NEXT
Is the dividing the strings only depends upon the size? because you specified 15?
any delimiters between the parts?
Hi.
I'm not sure what you are trying to accomplish, but you must place the variables inside $() to be evaluated.
SET Y=9;
FOR A=1 TO 10
LOAD
MID(X_FIELD, $(Y), 15) AS COLUMN_$(A)
FROM X.QVD (qvd);
LET Y=$(Y)+15;
NEXT
Hope it helps.
because every 15 characters there are a field i want:
ex:
123456789pizza_______maccheroni_____mafia__________berlusconi_____ etc...
i would like
column_1 column_2 column _3 column_4 column_5
pizza maccheroni mafia berlusconi ...........
Take a look at this qvw file using Join.
TAB:
LOAD * INLINE [
F1
12345678pizza__________maccheroni_____mafia__________berlusca_______ etc..
];
SET Y= 9;
FOR A=1 TO 5
join LOAD
F1,
MID(F1, $(Y), 15) AS COLUMN_$(A)
RESIDENT TAB;
LET Y= $(Y) + 15;
NEXT
drop field F1;
Message was edited by: Vegar Arntsen, Lie Added the actual script I used in qvw.
1)i feel stupid
2)your file is really good. but in my case the string that u call "F1" is in the database (in the table TAB):
THIS SHOULD BE: MID(TAB.F1, $(Y), 15))
so i'm not able to traslate ur code in relation to my aims.
thanks!!
I could reach the aim
but with MID and LOAD it doesnt work!!
this is the perfect result i got:
SET Y=9;
FOR A=1 TO 10
SELECT
SUBTR(TAB.F1, $(Y), 15)
FROM TAB
/*WHERE XXX*/;
LET Y=$(Y)+15;
NEXT