| Hyderabad Jobs | Book Website | ![]() |
I Love Hyderabad | Hyderabad Colleges |
| Home | Business Emails | Hyderabad Classifieds | Contact Us | |
| 7 Wonders of Hyderabad | Web Hosting | Yellow Pages | Our Network | |
Advanced PowerBuilder
Review Questions & AnswersQ: What are the various buffers available in a DataWindow? Ans: Primary, Original, Delete, Filter Q: Which buffer contains the retrieved data? Ans: Primary buffer. Q: After changing the retrieved data, which buffer contains the original data that was retrieved from the data source? Ans: Original buffer. Q: Why PowerBuilder keeps a copy of original data in the Original buffer, when the latest data is available in the Primary buffer? Ans: PowerBuilder uses the data from the original buffer to generate WHERE clause. Data from the Primary buffer is used in the INSERT/ DELETE/ UPDATE statements. Q: What SQL statement PowerBuilder generates for those rows that are in the Filtered buffer. Ans: In terms of generating SQL statements, Filter buffer belongs to the same category of Primary buffer, meaning, PowerBuilder will generate INSERT statement for NewModified! row status and UPDATE statement for DataModified! row status. Q: What SQL statement PowerBuilder generates for those rows that have New!, NewModified! row status. Ans: PowerBuilder doesn't generate any SQL statement for those rows that have New! row status. NewModified! row status will result in INSERT statement generation. Q: What are the different statuses a row can have in the Primary buffer? Ans: New!, NewModified!, DataModified! and NotModified! Q: What are different statuses that a column can have in a DataWindow? Ans: A column can have NotModified! or DataModified! statuses. It can not have NewModified! and New! statuses since every column's data in the row that has NewModified! row status is used in the INSERT statement, hence there is no need to keep track of column status in a row with New! or NewModified! row status. Q: What is the difference between NewModified! and DataModified! row statuses? Ans: A row would have NewModified! status when a blank row is inserted using InsertRow() function and data is populated in at least one of those fields in that row. Rows that are imported using ImportFile(), ImportString(), ImportClipboard() functions also have NewModified! row status. It will retain the status till next successful update() function call. A row would have DataModified! status when that row is retrieved from the data source and is modified. It will retain the status till next successful update() function call. Q: PowerBuilder generates DELETE SQL statement for all rows that are in the Delete buffer. Is it correct? Ans: No. PowerBuilder doesn't generate any SQL statement for rows with New! and NewModified! row statuses in the Delete buffer. Q: Explain how to find a row or column status. Ans: You can use GetItemStatus() function to get both column and row status. If you pass the column number/name to this function, you will get that specific column's status in the specified row. If you pass zero as the column number, then you will get the row status. Q: How many times PowerBuilder retrieves data into a DropDownDataWindow when the parent DataWindow has one thousand rows? Ans: The answer varies depending on how the rows in that DataWindow got there. If those 1000 rows are retrieved from the database, then PowerBuilder retrieves the DropDownDataWindow only once unless the DropDownDataWindow has at least one row (even an empty row has the same effect). If DDDW has some data, then PowerBuilder doesn’t retrieve at all. Not even once. If you imported those 1000 rows using ImportClipboard() or ImportFile() functions are copied/moved data from other DataWindows/DataStores using RowsCopy() or RowsMove() functions, then PowerBuilder does not retrieve data into DDDW at all. Q: How do you prevent PowerBuilder from retrieving data into a Child DataWindow (DropDownDataWindow) automatically? Ans: Insert a row in the DDDW when you are in the DW painter. That row doesn’t have to have data in it, it can even be empty. The thumb rule is, if PowerBuilder sees at least one row in DDDW, then it doesn’t retrieve data into DDDW. Q: I have a DataWindow which has a DropDownDataWindow.I have a situation where I need to retrieve data into the parent DataWindow from Sybase, but data into the Child DataWindow should come from Informix. Is there any solution for this problem. Ans: Yes, there is a solution. Declare a DataWindowChild type variable and get reference of the DDDW using GetChild() function. Then set the Informix transaction object to that DataWindow using SetTransObject() and retrieve the data. Q: I have a situation where I need to do some manipulation before data from a DropDown DataWindow displays on the screen. Is there any way of solving this problem? Ans: Define a user-defined event in that DataWindow and map it to pbm_dwndropdown PowerBuilder event. Write your code to that event. PowerBuilder fires this event as soon as it completes retrieving from the DDDW and displays it on the screen. Q: I have a DataWindow that has a DDDW. The parent DataWindow has 1000 rows and the DDDW has 40 rows. In this scenerio, how many times the RetrieveRow event is fired? Ans: PowerBuilder doesn’t fire RetrieveRow event for the DDDW rows. It only fires for the parent DataWindow. In this case, it fires 1000 times, not 1040 times. Q: What would be the status of a row in the target DataWindow when copied using RowsCopy() function? Ans: The row status in the target DataWindow will be NewModified!, meaning it will result in INSERT statement generation for the Update() call on the target DataWindow. Q: What would be the status of a row in the target DataWindow when copied using RowsMove() function? Ans: The row status in the target DataWindow will be NewModified!, meaning it will result in INSERT statement generation for the Update() call on the target DataWindow. Q: There is a DataWindow which contains a DropDownDataWindow. The DataWindow contains no data. If you insert a new row in the parent DataWindow, Will PowerBuilder automatically retrieves the data into the DropDownDataWindow? Ans: The answer is Yes when you insert rows using InsertRow(). The answer is No when you insert rows using RowsCopy() / RowsMove(), ImportClipboard()/ ImportFile() functions. In the later case, it is your responsibility to retrieve the data into the child DataWindow. Q: Given the situation where the user wants to print only selected range of rows or all selected rows in a DataWindow. How do you solve this problem? Ans: You can use a DataStore and set the DataWindow object same as the selected DataWindow control's object and copy rows to the DataStore using RowsCopy() function and print DataStore. Q: Can I use RowsCopy() and RowsMove() functions to copy/move data between buffers in the same DataWindow? Ans: You can move rows between buffers using RowsMove() function. However, RowsCopy() doesn't allow to copy rows between buffers within the same DataWindow, and I don't think you ever need that functionality. If you need, you can copy to a different buffer in the target DataWindow using RowsCopy() function. Q: What would be the status of a row when moved using RowsMove() function? Ans: If you are moving rows between buffers in the same DataWindow, then there will be no change in the row/column status. However, if you move between DataWindows, then the row status in the target DataWindow would be NewModified!, meaning, an INSERT statement will be generated for the Update() function call. Q: I know pressing the Escape key after changing the data in a column will restore the old data—basically the Undo functionality. Does PowerBuilder provide Undo functionality for row insert/delete/update? Ans: There is no built-in functionality like that. If you need that functionality, you can maintain a DataStore and move rows to the DataStore whenever user wants to delete them. You need to maintain those row and column statuses in another DataStore or in an array. When user wants to undo it, move those rows from the DataStore back to the original DataWindow and set row and column statuses appropriately. Q: Can I move/copy rows from Primary buffer to Original buffer? Ans: There is no direct function or attribute to do that for you. However, as soon as you change the data using SetItem() function or interactively, PowerBuilder copies the original data into the Original buffer automatically. But, you can not have the same data both in Primary and Original buffer at the same time and I don’t see any need of that in real-world projects. Q: I have a DataWindow with 10000 rows. I want to get rid of selected rows from the DataWindow, i.e., PowerBuilder should not generate DELETE statement for those rows when I call Update() function. What should I do? Ans: You can delete those rows using DeleteRow() function, however, it will result in DELETE statement generation when Update() function is called. You can create a DataStore and move those rows into that DataStore using RowsMove() function, and never call Update() on the DataStore; but it will be additional overhead. The best method is, call RowsDiscard() function. This function doesn’t move data to Delete buffer, it simply gets rid of those rows from the DataWindow altogether. Q: I have a DataWindow which has 10,000 rows and 200 rows among them are modified. For some reason, I want to have all rows in the DataWindow including the modified rows look like as if the DataWindow is retrieved just now. but I do not want to retrieve them all over again from the database. Is it possible? Ans: Yes, it is possible. Solution 1: You can set the status of all those rows that are modified to NotModified! using setItemStatus() function which might take longer time than the later solution. Solution 2: You can just call ResetUpdate() function which resets the flags for you and empties the Delete buffer. You can use RowsDiscard() to discard all rows that have New! or NewModified! status. Do not confuse ResetUpdate() with Reset() function; the later function clears all rows from the DataWindow and looks like as if no data was retrieved into this DataWindow. Q: What exactly AcceptText() function does? Explain in detail. Ans: AcceptText() function, after successful validation and ItemChanged event execution, takes the content of the DataWindow's Edit control and copies into the Primary buffer. This function triggers ItemChanged event; it triggers ItemError event in the case of validation rule failure or datatype test failure or non-zero return code from ItemChanged event. By default, this function is called by the Update() function, unless you specify not to call in the Update() function. Q: I have a DataWindow with one thousand rows and some rows among them are modified. I set the DataWindow into QueryMode, and set it back to normal mode, without retrieving from the database. Does this reset my DataWindow? Ans: No. As long as you do not call Retrieve() function on that DataWindow, switching between query mode and normal mode doesn’t affect the data in the DataWindow. Q: How do you update a DataWindow that is based on a multiple table join? Ans: Well, you set one table as updatable in the DataWindow painter. At run-time, call Update() function with FALSE as the second parameter. Upon successful execution, make the second table as updatable and all other tables as non-updatabale and call the Update() as described above and continue till the last table. For the last table, call Update() function with TRUE as the second parameter and commit the transaction upon successful operation. Finally, make the first table as updatable which will be useful for the next update. Q: What kind of DataWindows are not updatable? Ans: DataWindows with Crosstab, Group, Composite, OLE presentation styles are not updatable. You can set Group presentation style DataWindow updatable, however you can't change the columns on which the group is based on. Q: Explain the major difference between RetrieveRow, DeleteRow, InsertRow and UpdateRow events in a DataWindow. Ans: Other than the RetrieveRow event, the rest of the events doesn’t exist for a DataWindow control/DataStore object. UpdateStart event is fired before PowerBuilder starts applying DataWindow changes to the data source. Since then, for each INSERT/ UPDATE/ DELETE statement, PowerBuilder fires SQLPreview event. The functionality you are expecting in those non-existing events in your question is available in the SQLPreview event.
|
| Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com |