Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
//1st subroutine
Sub createanddrop (vTableName)
Store $(vTableName) into [$(vTableName).qvd];
Drop Table [$(vTableName)];
End Sub
// 2nd subroutine
sub pop
FOR i=1 to NoOfTables();
LET vTable=TableName($(i) -1);
CALL createanddrop($(vTable));
NEXT i
END SUB
//Main call to subroutine
Call pop;
This is my code....I want to use call within a subroutine, so that I can pass parameter to another subroutine.
Thanks
Hi Jonathan,
You can look at my code...I am using CALL createanddrop('$(vTable)');......Still not working..
Could You plz check out the flow of execution in this code....Bcoz dis is the first time I am using nested subroutine...I am not sure, whether It is correct.
First call is made to pop subroutine...then again inside pop another subroutine createanddrop is being called....So plz verify from ur side....It is correct or not...
Thank you Luis for ur reply...Everything working fine, but my 2nd table is not getting drop..
Emp1:
LOAD * INLINE [
EmpName, Salary
Ram, 4587
Shyam, 1500
John, 5000
James, 2500
Jim, 1000
];
Emp2:
LOAD * INLINE [
EmpId, Office
1, UAE
2, Ind
3, Uk
5, Us
4, Pune
];
Emp3:
LOAD * INLINE [
EId, EOffice
1, UAE
2, Ind
3, Uk
5, Us
4, Pune
];
Fabrice is correct. Always work from the bottom when dropping tables in a loop:
sub pop
LET vTableCount = NoOfTables();
FOR i=0 to vTableCount - 1;
LET vTable=TableName(0);
CALL createanddrop('$(vTable)');
NEXT i
END SUB
HTH
Jonathan
Please read this..............
I really appreciate efforts of everyone......After dealing with the code I made some changes and now I am using same function in single subroutine....This is my code...........////Single subroutine//////////
sub pop
LET vTableCount = NoOfTables();
FOR i=0 to vTableCount - 1;
LET vTable=TableName(0);
Store $(vTable) into [$(vTable).qvd];
Drop Table [$(vTable)];
NEXT i
END SUB
call pop
Now I am having two different code with same functionality.....So my question is Which one is Optimized and which one will you prefer???
//1st subroutine
Sub createanddrop (vTableName)
Store $(vTableName) into [$(vTableName).qvd];
Drop Table [$(vTableName)];
End Sub
// 2nd subroutine
sub pop
LET vTableCount = NoOfTables();
FOR i=0 to vTableCount - 1;
LET vTable=TableName(0);
CALL createanddrop('$(vTable)');
NEXT i
END SUB
call pop
Hi
I doubt you will see any performance difference as the time consuming operations are the same, but always test to confirm the assumption. If you can't see a difference in testing, then I suggest that you use the simpler script.
HTH
Jonathan
hi Jonathan,
I just reloaded same table using both functions one by one......I found something unexpected result
In 1st case, i.e, nested call , It is taking 31 sec
In 2nd case, i.e, Single subroutine, It is taking 37 sec..
It is completely opposite of my expectation...I was thinking nested call will take more time but I was wrong...Dont know how