Mastering PowerBuilder

HomePrevious Lesson: Activate/Deactivate Events
Next Lesson: Method to Apply Changes to the Database

Method to Retrieve Data

Declare of_Retrieve() function as shown below and write the following code.
Object: n_product_master
Function: of_Retrieve()
Argument: BLOB, abl_data, By reference
Returns: Long
Long ll_rowcount
ll_rowcount = ids_data.Retrieve()
If ll_rowcount > 0 then
   ids_data.GetFullState(abl_data)
end if
return ll_rowcount

Basically, we are retrieving the data into the DataStore and storing all that data including the DataWindow object into the BLOB object using GetFullState() function. Since abl_data is passed by reference, the data is available in the calling object. The following function is another version of the code with the same functionality. However, this method generates the DataWindow object on fly.
Object: n_product_master
Function: of_Retrieve()
Argument: BLOB, abl_data, By reference
Returns: Long
Long ll_rowcount
String ls_ErrorSyntaxfromSQL, ls_CreateErrors
string ls_SQL, ls_NewSyntax
ls_SQL = 'SELECT * from product_master'
ls_NewSyntax = SQLCA.SyntaxFromSQL(ls_SQL, &
		'Style(Type=Form)', ls_ErrorSyntaxfromSQL)
ids_data.Create(ls_NewSyntax, ls_CreateErrors)
ids_data.SetTransObject(SQLCA)
ll_rowcount = ids_data.Retrieve()
If ll_rowcount > 0 then
   ids_data.GetFullState(abl_data)
end if
return ll_rowcount

You may want to keep the first version. The second version is just for demonstration of what you can do. The following picture displays this method in Jaguar after deploying. You can see the method name is suffixed with double underscore and character N. You can also see the additional structure parameter that is defined by the wizard. The additional parameter is because, we choose to 'Allow NULL Values in Parameter' in the wizard. Unless you save the object, you won't be able to see them in Jaguar Manager.

HomePrevious Lesson: Activate/Deactivate Events
Next Lesson: Method to Apply Changes to the Database