Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have 2 db connections, in each connection I have to repeat same code (i.e. I have read same data fields/tables)
How do i implement code re-use functionality? is below logic correct? OR anyone have better idea?
DB Connection 1.
$(Include=test code.txt);
DB Connection 2.
$(Include=test code.txt);
My test code.txt file will contain all my load statements.
Is that correct?
Thanks.
Hi,
I f u have 2 db connections from one database they it is fine.
but if u have 2 db connections from 2 different databases then you can do like this
DB Connection 1.
$(Include=test code.txt);
disconnect;
DB Connection 2.
$(Include=test code.txt);
at a time QV wn't connect to 2 DB's so u need to do Disconnect a 1 db then connect to another db.
Hi,
I f u have 2 db connections from one database they it is fine.
but if u have 2 db connections from 2 different databases then you can do like this
DB Connection 1.
$(Include=test code.txt);
disconnect;
DB Connection 2.
$(Include=test code.txt);
at a time QV wn't connect to 2 DB's so u need to do Disconnect a 1 db then connect to another db.
Hi,
This is the best method, if there is a change in Query you can just change query in text file one time no need to change twice.
Regards,
Jagan.
I should write a sub ... end sub and use it with a call so you write the code once and call it as if it was a function ...
Let me know
Open you script editor...
FILE -- Export to Script File
Save to any place as per your choice
Open the Script Editor where you want to re-use
Insert
Include Statement
Select that file...
hi make sure even schema is same.
Then this is best approach.
Regards
ASHFAQ
Hi All Thanks for reply.
I will follow.
DB Connection 1.
$(Include=test code.txt);
disconnect;
DB Connection 2.
$(Include=test code.txt);
@ Alessandro, I didn't get your point. Do you have any sample doc which will help to understand more?
Thanks.
Sub MySubName
load * from ...
End Sub
Odbc connect to DB1;
CALL MySubName;
Odbc Connect to DB2;
CALL MySubName;