<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>SOLVED: Multi-database queries attempt</title>
        <description> I am trying to follow the &amp;quot;Multi-database queries&amp;quot; in the help with the code below where I am using SQL Server Native driver and HF CS. When I attempt the join between HF and SQL Server I get an error on the first gwsdQRY_xx_Test file saying it does not exist alhough both have records and the where condition records are both there.

Any suggestions would be appreciated.


gwsdQRY_HF_Test is Data Source
gwsdQRY_PO_Test is Data Source
gwsdQRY_Join is Data Source

sHFSQL is string = [
SELECT 
PurcLineBinary.PurcLineBinaryID,
PurcLineBinary.ROWID,
PurcLineBinary.PURC_ORDER_ID,
PurcLineBinary.PURC_ORDER_LINE_NO,
PurcLineBinary.TYPE,
PurcLineBinary.BITS,
PurcLineBinary.BITS_LENGTH,
PurcLineBinary.Description 
FROM 
PurcLineBinary
WHERE
PurcLineBinary.Description LIKE &amp;#039;%ANODIZE%&amp;#039;
]

IF NOT HExecuteSQLQuery(gwsdQRY_HF_Test,HF_Server,hNoBind,sHFSQL) THEN
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_HF_Test)
END
sPO_POL is string =[
SELECT 
	PURCHASE_ORDER.ROWID+10 AS ROWID_PO10,	
	PURCHASE_ORDER.ID AS ID,	
	PURCHASE_ORDER.VENDOR_ID AS VENDOR_ID
FROM 
	PURCHASE_ORDER
ORDER BY 
	ORDER_DATE DESC,	
	VENDOR_ID ASC

]

IF NOT HExecuteSQLQuery(gwsdQRY_PO_Test,SQL_Server,hQueryWithoutCorrection+hNoBind,sPO_POL) // HExecuteSQLQuery()gwsdQRY_PO_Test,SQL_Server,hNoBind,sPO_POL) then
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_PO_Test)
	HReadSeekFirst(gwsdQRY_PO_Test,rowid_po10,gwsdQRY_HF_Test.rowid)
END

Info(&amp;quot;HF recs: &amp;quot;+HNbRec(gwsdQRY_HF_Test),&amp;quot;PO_POL recs: &amp;quot;+HNbRec(gwsdQRY_PO_Test))

sJoin is string = [
select * FROM gwsdQRY_HF_Test,gwsdQRY_PO_Test
where gwsdQRY_HF_Test.ROWID = gwsdQRY_PO_Test.ROWID_PO10
]

IF NOT HExecuteSQLQuery(gwsdQRY_Join,hNoBind,sJoin) THEN 
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_Join)
END

Info(&amp;quot;Join recs:&amp;quot;+HNbRec(gwsdQRY_Join))


</description>
        <link>https://www.wxforum.info/read.php?27131,796741,796741#msg-796741</link>
        <lastBuildDate>Wed, 20 May 2026 12:42:57 +0200</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://www.wxforum.info/read.php?27131,796741,796750#msg-796750</guid>
            <title>Re: SOLVED: Multi-database queries attempt</title>
            <link>https://www.wxforum.info/read.php?27131,796741,796750#msg-796750</link>
            <description><![CDATA[ Hi Issah,<br />
...<br />
No, actually the only way I got it to work was by using existing Queries and then doing  the sJoin query.<br />
<br />
HOWEVER better than that I discovered the join can be put in an SQL Query and then the resulting field names are usable!<br />
<br />
Here is the code now:<br />
<br />
<pre class="bbcode">
QRY_PO_POL_Search.pOrderDateFrom = StringToDate(&quot;01/01/2021&quot;,maskDateSystem)
QRY_PO_POL_Search.pOrderDateTo = StringToDate(&quot;03/01/2021&quot;,maskDateSystem)
HExecuteQuery(QRY_PO_POL_Search)

QRY_PLB_ByDescription.pDescription = &quot;anodize&quot;
HExecuteQuery(QRY_PLB_ByDescription)

Info(&quot;SQL: &quot;+HNbRec(QRY_PO_POL_Search),&quot;HF: &quot;+HNbRec(QRY_PLB_ByDescription))


IF NOT HExecuteQuery(QRY_PO_POl_Seach_test) THEN 
	Error(&quot;4 HExecuteQuery(QRY_PO_POl_Seach_test)&quot;, HError,HErrorInfo())
ELSE
	Info(&quot;Join recs:&quot;+HNbRec(QRY_PO_POl_Seach_test))
	HReadFirst(QRY_PO_POl_Seach_test)
END
Info(&quot;First Vendor = &quot;+QRY_PO_POl_Seach_test.VENDOR_ID)</pre>
<br />
I will gladly share my experiences with anyone that wants to do this.]]></description>
            <dc:creator>Jeff Graham</dc:creator>
            <category>WinDev Forum</category>
            <pubDate>Mon, 05 Dec 2022 20:50:05 +0100</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27131,796741,796747#msg-796747</guid>
            <title>Re: SOLVED: Multi-database queries attempt</title>
            <link>https://www.wxforum.info/read.php?27131,796741,796747#msg-796747</link>
            <description><![CDATA[ Hi Jeff,<br />
<br />
That&#039;s great....happy to hear.  Did you have to put the hQueryDefault on each query?<br />
<br />
Regards<br />
<br />
issah]]></description>
            <dc:creator>mixgh</dc:creator>
            <category>WinDev Forum</category>
            <pubDate>Mon, 05 Dec 2022 04:10:22 +0100</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27131,796741,796746#msg-796746</guid>
            <title>Re: Multi-database queries attempt</title>
            <link>https://www.wxforum.info/read.php?27131,796741,796746#msg-796746</link>
            <description><![CDATA[ Hi issah,<br />
<br />
Thanks for the suggestion. Unfortunately the &quot;hQueryWithoutCorrection&quot;  requires specifying connection and then second file is considered an element of the SQLServer. &quot;hQueryWithoutHFCorrection&quot; is acccepted but also says the first file is invalid.<br />
<br />
I also made another test case with simple tables and text ID fields which hits the same problem.<br />
<br />
I then did a test with two exising simple Queries in the project, one HF and one SQL. That worked using hQueryDeafult.<br />
<br />
Thanks for the suggesions!]]></description>
            <dc:creator>Jeff Graham</dc:creator>
            <category>WinDev Forum</category>
            <pubDate>Sun, 04 Dec 2022 21:17:17 +0100</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27131,796741,796745#msg-796745</guid>
            <title>Re: Multi-database queries attempt</title>
            <link>https://www.wxforum.info/read.php?27131,796741,796745#msg-796745</link>
            <description><![CDATA[ Hi Jeff,<br />
<br />
Why don&#039;t you put an &quot;hQueryWithoutCorrection&quot; on the final query.  If that doesn&#039;t work, consider simplifying both queries and add additional columns one at a time.  Are the two ROWID&#039;s compatible (same type)?<br />
<br />
My two cents<br />
<br />
issah]]></description>
            <dc:creator>mixgh</dc:creator>
            <category>WinDev Forum</category>
            <pubDate>Sun, 04 Dec 2022 17:38:33 +0100</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27131,796741,796741#msg-796741</guid>
            <title>SOLVED: Multi-database queries attempt</title>
            <link>https://www.wxforum.info/read.php?27131,796741,796741#msg-796741</link>
            <description><![CDATA[ I am trying to follow the &quot;Multi-database queries&quot; in the help with the code below where I am using SQL Server Native driver and HF CS. When I attempt the join between HF and SQL Server I get an error on the first gwsdQRY_xx_Test file saying it does not exist alhough both have records and the where condition records are both there.<br />
<br />
Any suggestions would be appreciated.<br />
<br />
<pre class="bbcode">
gwsdQRY_HF_Test is Data Source
gwsdQRY_PO_Test is Data Source
gwsdQRY_Join is Data Source

sHFSQL is string = [
SELECT 
PurcLineBinary.PurcLineBinaryID,
PurcLineBinary.ROWID,
PurcLineBinary.PURC_ORDER_ID,
PurcLineBinary.PURC_ORDER_LINE_NO,
PurcLineBinary.TYPE,
PurcLineBinary.BITS,
PurcLineBinary.BITS_LENGTH,
PurcLineBinary.Description 
FROM 
PurcLineBinary
WHERE
PurcLineBinary.Description LIKE &#039;%ANODIZE%&#039;
]

IF NOT HExecuteSQLQuery(gwsdQRY_HF_Test,HF_Server,hNoBind,sHFSQL) THEN
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_HF_Test)
END
sPO_POL is string =[
SELECT 
	PURCHASE_ORDER.ROWID+10 AS ROWID_PO10,	
	PURCHASE_ORDER.ID AS ID,	
	PURCHASE_ORDER.VENDOR_ID AS VENDOR_ID
FROM 
	PURCHASE_ORDER
ORDER BY 
	ORDER_DATE DESC,	
	VENDOR_ID ASC

]

IF NOT HExecuteSQLQuery(gwsdQRY_PO_Test,SQL_Server,hQueryWithoutCorrection+hNoBind,sPO_POL) // HExecuteSQLQuery()gwsdQRY_PO_Test,SQL_Server,hNoBind,sPO_POL) then
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_PO_Test)
	HReadSeekFirst(gwsdQRY_PO_Test,rowid_po10,gwsdQRY_HF_Test.rowid)
END

Info(&quot;HF recs: &quot;+HNbRec(gwsdQRY_HF_Test),&quot;PO_POL recs: &quot;+HNbRec(gwsdQRY_PO_Test))

sJoin is string = [
select * FROM gwsdQRY_HF_Test,gwsdQRY_PO_Test
where gwsdQRY_HF_Test.ROWID = gwsdQRY_PO_Test.ROWID_PO10
]

IF NOT HExecuteSQLQuery(gwsdQRY_Join,hNoBind,sJoin) THEN 
	Error(HErrorInfo())
ELSE
	HReadFirst(gwsdQRY_Join)
END

Info(&quot;Join recs:&quot;+HNbRec(gwsdQRY_Join))


</pre>]]></description>
            <dc:creator>Jeff Graham</dc:creator>
            <category>WinDev Forum</category>
            <pubDate>Fri, 02 Dec 2022 23:30:21 +0100</pubDate>
        </item>
    </channel>
</rss>
