{"id":87,"date":"2014-07-22T10:39:08","date_gmt":"2014-07-22T14:39:08","guid":{"rendered":"http:\/\/salzlechner.com\/dev\/?p=87"},"modified":"2016-03-11T07:14:38","modified_gmt":"2016-03-11T12:14:38","slug":"using-sql-statements-to-run-your-report","status":"publish","type":"post","link":"http:\/\/salzlechner.com\/dev\/2014\/07\/22\/using-sql-statements-to-run-your-report\/","title":{"rendered":"Using SQL Statements to run your  report"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>VPE for Visual DataFlex has built in capabilities to use a SQL statement to fetch the records for the report. This makes reporting in VDF much more powerful as you are not constrained by the use of indexes.<\/p>\n<p>In order to tell VPE for VDF to use a SQL statement we need to set a few properties.<\/p>\n<pre class=\"lang:default decode:true\" abp=\"2347\">Set pbUseSQL to True\r\nSet psDriverID to \"MSSQLDRV\"\r\nSet pbBindMainFile to True<\/pre>\n<p>The pbUseSQL property tells the report class to use SQL statements<\/p>\n<p>Then\u00a0 we set the psDriverID property to &#8216;MSSQLDRV&#8217;.<\/p>\n<p>In addition we can set the pbBindMainFile property which will cause the report to automatically bind the main file\u00a0 buffer after fetching a row<\/p>\n<p>We also need to set the psConnectionString property<\/p>\n<pre class=\"lang:default decode:true \" abp=\"2352\">String sConnStr\r\nGet_Attribute DF_FILE_LOGIN of ORDER.File_Number to sConnStr\r\nSet psConnectionString to sConnStr\r\n<\/pre>\n<p>in the above example we get the connection string from the order table and use it.<\/p>\n<p>now we need to supply a sql statement<\/p>\n<pre class=\"lang:default decode:true\" abp=\"2355\">Function GetSQLStatement Returns String\r\n    String sStmt\r\n\r\n    Move \"Select * from order .... \" to sStmt\r\n\r\n    Function_Return sStmt\r\nEnd_Function\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>if you are using a SQL database you can run your VPE for DataFlex reports using SQL statements<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","ngg_post_thumbnail":0,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-vpe-for-vdf"],"_links":{"self":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":4,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":289,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/87\/revisions\/289"}],"wp:attachment":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}