//********************************************************************** // DbQuery.df3 - Query tool for DataFlex 3.2 (October 2004) // // Version: 2.00 // // Differences between the query that is shipped with DF 3.2 (DFQ) and this // query includes: // // * The ability to optimize the table scans based on the selection criteria // entered (it does not try to optimize on descending segments though). // * The screen preview lets you browse forwards and backwards through the // report and let's you search for text strings. // * A report may be printed after previewing it without re-generating it // // // This source code was programmed by Sture Andersen // // // You may feedback may be given via one of these public newsgroups: // // The newsgroup of VDF-GuiDance // // news://news.mijnwebapp.nl/OpenSource // // The newsgroup of Data Access WorldWide // // news://news.dataaccess.com/dac-public-newsgroups.dataflex-support #IFDEF 0 DBQuery Version: 2.00 - Query tool for DataFlex 3.2 --------------------------------------------------- DBQuery is a DataFlex application that will let you define and run queries much like DFQ and the DFQuery program of earilier versions of DataFlex. Differences between the query that is shipped with DF 3.2 (DFQ) and this query includes: * User may specify calculated columns in reports * The ability to order the output based on any combination of field values (including parent fields) * Report breaks may be specified according to the selected ordering. * Selection criteria based on an expression * The screen preview lets you browse forwards and backwards through the report and lets you search for text strings. * A report may be printed after previewing it without re-generating it On Calculated Columns On the tab page called "Fields" there is a button called "Expression". Clicking this will enable you to insert a calculated column. You must specify a label, a width and the type of column. If 'Numeric' is selected you should also specify the number of decimals. Clicking the 'Edit' button allows you to specify the actual expression. When doing so two things are important: 1. Make sure that the expression is put inside parenthesis. 2. Take care that the return type of the expression is the same as hat indicated in the combo form of the previous dialog. On Expression as Selection Criteria On the second tab called "Selection" you may click the "Expression" button to enter an integer expression that will be evaluated for each records. If it evaluates to a non zero integer value the record will go in the report. These things should be noted: 1. The integer expression needs to be inside parenthesis. 2. Take care that the return type is integer 3. The expression will only be evaluated if the other criteria (if any) includes the record 4. Selections done in the expression dialog will not be used as basis for report optimization. Company address: Sture ApS Ndr. Fasanvej 92 st tv DK-2000 Frederiksberg Denmark Tel: +45 40 59 70 20 e-mail: sture.aps@mail.tele.dk *********************************************************************** If you know anybody that might benefit from this tool, please tell them about it. -Sture Andersen #ENDIF // // // // // To navigate between the tabs: // // Press: Alt+1,2,3,4 // Ctrl+F1,F2,F3,F4 // Ctrl+PgUp/PgDn (previous/next tab) // // Secrets: Ctrl+D in Table and Fields lists display table definition // Ctrl+R in Previewer displays a ruler in the top // // // or use the mouse (if you have one and click the number of the // tab you wish to activate. // // To display the table definition press Ctrl+D while in the list of // tables (on either tab 1 or 2) // // // NOTE THAT: It is very important that you compile this source // on the target platform (if UNIX/LINUX don't transfer from DOS) // // // Create: Tue 02-10-2001 // Mon 08-10-2001 - Sent to WfA (0.1) // Update: Tue 09-10-2001 - Fixed date selection. // - Ctrl+D displays table definition when // focus is with the table selector on T1 or T2. // - Ctrl+D pops up the calendar when entering // selection criteria on a date field. // - Now also possible to navigate between the // tabs using Ctrl+F1/F2/F3/F4. // - Enter in Main table field will popup the // table selector if main table has not already // been selected. // Wed 10-10-2001 - On user-contributed-files (0.2) // Thu 11-10-2001 - Command line interface fixed // - Ruler added to preview (Ctrl+R) // Mon 15-10-2001 - Adjust button fixed // - Login/Logout added // - Advanced table selection added // Wed 17-10-2001 - Default values on tab 4 // Tue 23-10-2001 - Prepared to use constraints of a application DDO // to generate a report. // Tue 30-10-2001 - File/Field are now indicated when moving up and // down the list of printed fields and the list of // current selection criteria // Thu 04-04-2002 - Hot keys enhanced on tab 2 // - Field lengths in action bar in previewer adapted // to all languages. // - Strange looking button object removed from main // dialog. // - Made expr selection visible in tab 2 and report. // // // // Use AllEntry use base.nui Set_Option AUTOCLEAR Use LangSymb.pkg // Language symbols define lng_default for LNG_ENGLISH //define lng_default for LNG_PORTUGUESE Use DfApp // Character Mode DataFlex application stuff Use Login.utl // DBMS_GetDriverLogin function set verbose_state of error_info_object to DFTRUE // Always display line number on errors! define CM_QUERY_VERSION for "2.0" send DfApp.About_Fill "dbQuery" CM_QUERY_VERSION "SBA" "" use traceobj Use wObs Use Array.dbu Use CmdLine.nui // Simple thing for reading command line parameters /Main_Menu ______ ______ ÿ /FilePullDown.img ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ _____________________ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ _____________________ ³ ³ _____________________ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ _____________________ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ _____________________ ³ ³ _____________________ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ _____________________ ³ ³ _____________________ ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ _____________________ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /ViewPullDown.img ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ _____________________ ³ ³ _____________________ ³ ³ _____________________ ³ ³ _____________________ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ /* create_menu main_menu location 1 0 absolute set action_bar_keys_msg to main_menu_keys on_item " &File " begin_pull_down FilePullDown.img on_item "New query" send Activate_Query_View_Clear to desktop on_item "O&pen...\aCtrl+O" send Query_View_Open to desktop on_item "Open 3.1 Query" send Query_View_OldOpen to desktop on_item "Run \aCtrl+R" send Query_View_Run to desktop on_item "&Save \aCtrl+S" send Query_View_Save to desktop on_item "Sav&e as... \aCtrl+E" send Query_View_SaveAs to desktop on_item "Log&in" send Query_Login to desktop on_item "Lo&gout" send Query_Logout to desktop // on_item "Large file" send DisplayLargeFile to desktop on_item "Exit \aAlt+F4" send exit_area end_pull_down on_item " &View " begin_pull_down ViewPullDown.img on_item "Fields \aAlt+1" send Query_View_Display_Tab1 to desktop on_item "Selections \aAlt+2" send Query_View_Display_Tab2 to desktop on_item "Ordering \aAlt+3" send Query_View_Display_Tab3 to desktop on_item "Parameters \aAlt+4" send Query_View_Display_Tab4 to desktop end_pull_down end_menu procedure main_menu_keys for desktop integer lhObj on_key key_alt+key_f send activate to (FilePullDown.img(lhObj)) PRIVATE on_key key_alt+key_v send activate to (ViewPullDown.img(lhObj)) PRIVATE end_procedure procedure DisplayLargeFile global local string lsFile get SEQ_SelectInFile "B‘h si'r det lille lam" "*.prp" to lsFile if lsFile ne "" send output.display_file lsFile end_procedure procedure Query_Login global local integer rval# driver# local string server# user# pw# get DBMS_GetDriverLogin 0 to rval# if rval# begin get DBMS_GetDriverLoginDriverID to driver# get DBMS_GetDriverLoginServer to server# get DBMS_GetDriverLoginUserID to user# get DBMS_GetDriverLoginPassWord to pw# login server# user# pw# (DBMS_TypeToDriverName(driver#)) end end_procedure procedure Query_Logout global logout end_procedure use dbquery.pkg // use output.utl object oDbQueryConfig is a cDbQueryLauncher register_object oDFQ_Output register_object oQueryDefinition procedure ReadConfigFileName string lsFile local string lsSendMailProgramPath lsDefaultPrinterPort forward send ReadConfigFileName lsFile get psSendMailProgramPath to lsSendMailProgramPath set psSendMailProgramPath of (oDFQ_Output(self)) to lsSendMailProgramPath get psDefaultPrinterPort to lsDefaultPrinterPort set psDefaultPort of (oQueryDefinition(self)) to lsDefaultPrinterPort end_procedure end_object /WhatItWillDo DBQuery is an ad-hoc report generator that allows its user to perform bottom up reporting on tables much like DFQuery of DF 3.1 and DFQ of DF 3.2. It features: * Calculated columns (expressions). * Selection criteria specified as an expression. * Any output ordering may be applied based on the value of any fields in the table and its parents. * Report breaks may be specified according to the selected ordering. * The report pre-viewer features browsing forwards and backwards through the report and searching for text strings in the report. /* use DfQuery.vw // View for querying tables Use Spec0007.utl // Display modal text (DoDisplayText) Use Spec0012.utl // Read image to string (sTextDfFromImage function) send DfApp.Title_Bar ("dbQuery "+CM_QUERY_VERSION) Send Activate to (Main_Menu(self)) procedure DoCmdLine local integer liItem liFile local string lsArg lsFileName lsConfigFile send DoReadCmdLine get CmdLineParamValue 0 to lsArg get CmdLineFindParamValue "-config" true to liItem if (liItem<>-1) begin get CmdLineParamValue (liItem+1) to lsConfigFile end else move "dbquery.cfg" to lsConfigFile send ReadConfigFileName to (oDbQueryConfig(self)) lsConfigFile move -1 to liFile if (StringIsInteger(lsArg)) begin move lsArg to liFile end else begin get CmdLineFindParamValue "-file" true to liItem if (liItem<>-1) begin get CmdLineParamValue (liItem+1) to liFile end end //if (liFile=-1) begin // get CmdLineFindParamValue "-filename" true to liItem // if (liItem<>-1) begin // get CmdLineParamValue (liItem+1) to lsFileName // blablabla // end // //end if (liFile<>-1) send Activate_Query_View_PrepareTable liFile else begin get CmdLineFindParamValue "-def" true to liItem if (liItem<>-1) begin get CmdLineParamValue (liItem+1) to lsArg send Activate_Query_View_LoadDef lsArg end else begin send Activate_Query_View_Clear end end end_procedure send DoCmdLine start_ui