According to manual help of Powerbuilder, a Pipeline system object is used to manage a data pipeline during execution.
You use a Pipeline object by defining a standard class user object inherited from the built-in Pipeline object in the User Object painter. You can then access the Pipeline events by writing scripts that contain code for the events.
Now I will show you how to execute pipeline by writing the script.
The scenario of this case is you want to pipeline a table from one database to another database. So, first you need at least 2 transaction objects, which mean we must declare first in the top of the script. Since we have a default database connection SQLCA, we only have declare another new transaction object called SQLCAtarget, which represent for the target database connection. Remember, in this case, SQLCA will be the source of database connection
SQLCA.DBMS = 'your source dbms name'
SQLCA.Database = 'your source database name'
SQLCA.LogId = 'your source database login id'
SQLCA.LogPass = 'your source database password'
SQLCA.ServerName = 'your source database server'
CONNECT USING SQLCA;
SQLCAtarget = CREATE transaction
SQLCAtarget.DBMS = 'your target dbms name'
SQLCAtarget.Database = 'your target database login id'
SQLCAtarget.LogPass = 'your target database password'
SQLCAtarget.ServerName = 'your target database server'
SQLCAtarget.LogId = 'your target database login id'
CONNECT USING SQLCAtarget;
Next step, you need to build pipeline object by clicking Pipeline painter in main toolbar. Remember, use MAIN TOOLBAR, if you want to pipeline the data to ANOTHER DATABASE.
Setup your source database and the target database profile, chooce the table(s), column(s) and criteria(s), then save as pl_mypipeline.
Choose source and target of Pipeline |
Set the table, column and criteria of your pipeline |
save your pipeline |
Create a window, then put 1 datawindow object and 1 button object. You don't need to put dataobject for the datawindow, just keep it blank. And put the script below at clicked event in button object.
integer iReturn
pipeline myPipeline
myPipeline = CREATE pipeline
myPipeline.DataObject = "pl_mypipeline"
iReturn = myPipeline.Start(SQLCA, SQLCAtarget, dw_1)
// always disconnect your database connection
DISCONNECT USING SQLCA;
DISCONNECT USING SQLCAtarget;
iReturn should be has 0 (zero) value if the pipeline run smoothly.
integer iReturn
pipeline myPipeline
myPipeline = CREATE pipeline
myPipeline.DataObject = "pl_mypipeline"
iReturn = myPipeline.Start(SQLCA, SQLCAtarget, dw_1)
// always disconnect your database connection
DISCONNECT USING SQLCA;
DISCONNECT USING SQLCAtarget;
iReturn should be has 0 (zero) value if the pipeline run smoothly.
Thanx man, you are the best
ReplyDeletewhats the structure of the dw_1 error object and how to pass argument to pipeline
ReplyDelete