I have a situation where I need to filter the data retrieved based on retrieval argument and then display all rows available in the database. To retrieve all rows, I have to remove the where clause in the datasource of the datawindow. This is how I got through the situation
string ls_sql, ls_dw_syntax, ls_find
String ls_replace, ERRORS, presentation_str, dwsyntax_str//Create datawindow
string rc, mod_string//To modify the sql
long ll_pos
ls_dw_syntax = dw_1.Describe("Datawindow.Table.Select")//Get the sql from datasource
ls_find = "WHERE"//Find the position of where keyword in sql
ll_pos = POS(ls_dw_syntax, ls_find)
IF ll_pos > 0 THEN
ls_replace = Replace ( ls_dw_syntax, ll_pos, 999, "" )//remove string from Where
END IF
//Create datawindow without where clause
presentation_str = "style(type=grid)"
dwsyntax_str = SQLCA.SyntaxFromSQL(ls_replace, presentation_str, ERRORS)
IF Len(ERRORS) > 0 THEN
MessageBox("Caution", "SyntaxFromSQL caused these errors: " + ERRORS)
RETURN
END IF
dw_1.Create( dwsyntax_str, ERRORS)
IF Len(ERRORS) > 0 THEN//Test if creation of datawindow is successful
MessageBox("Caution", "Create cause these errors: " + ERRORS)
RETURN
END IF
dw_1.settrans( SQLCA)
dw_1.Retrieve( )
No comments:
Post a Comment