<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>To all those who requested that I post a sample of my ODBC processing, here it is.</div><div> </div><div>Couple of things to note:</div><div>1. I run all my processing from a 1 field 1 file called 'ctrl'.</div><div>2. This sample as well as all of my ODBC processing is using the 'Low Level' method.</div><div>3. I am reading data from a program written in MS SQL Server. I write nothing to the SQL database.</div><div>4. If have set up my odbc data source as 'DSN=fp-sqlserver'. This is set up as a 'user' not a 'system' data source as I want to limit who can use it. The choice is yours. A word of caution here. If you are working on a workstation that is Windows 7 but running under a virtual XP mode (like I do) make sure you set up the 'user' data source under the XP mode NOT the Win7
mode.</div><div>5. In the processing below the SQL table is called 'PST' and I am writing to a filepro file called 'BOM'. As you may guess this copies the full Bill Of Material file from PST to BOM. 78K records in less than a minute.</div><div> </div><div>Finally, this is a simple 1 SQL table to 1 fp file with a rather simple Where condition.</div><div> </div><div>I wanted to post one I am working on now which is a complex 3 table, 3 INNER JOIN with heavy 3 statement Where condition. However, I am having some real problems in how filePro handle INNER JOINS and multiple tables. I just don't get the 'AS' 'FROM' filePro statement I found in the help files. I will be sending this to the list and fpsupport to see if they can set me straight.</div><div> </div><div>So far I have written 7 processes like the one below. Once you get the format and structure it is simple and the processing speed
fast.</div><div> </div><div>With all that said here is the table. I'll answer any questions you may have.</div><div> </div><div>Rick Hane</div><div>Controller</div><div>Deluxe Stitcher Company Inc</div><div><a href="http://www.deluxestitcher.com/">http://www.deluxestitcher.com/</a></div><div> </div><div><br> LABEL D E F I N E P R O C E S S I N G 5.0.15R9<br>────────────────────────────────────────────────────────────────────────────────<br> 1 ------- - - - - - - -
- - - - - - - - -<br> ◄ If: ◄<br> Then: declare connection(8,.0,g) ◄<br> 2 ------- - - - -
- - - - - - - - - - - -<br> ◄ If: ◄<br> Then: declare tablename(20,,g) ◄<br> 3 -------
- - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: declare
queryname(8,.0,g) ◄<br> 4 ------- - - - - - - - - - - - - - - - -<br> ◄ If:
◄<br> Then: declare recordset(5,.0,g) ◄<br> 5 ------- - - - - - - - - - - - - - - - -<br> ◄
If: ◄<br> Then: declare myquery(250,*,g) ◄<br> 6 ------- - - - - - - - - - - - - - -
- -<br> ◄ If: ◄<br> Then: declare stemp(250,*,g) ◄<br> 7 ------- - - - - - - - - -
- - - - - - -<br> ◄ If: ◄<br> Then: connection = new ODBC_CONNECTION("DSN=fp-sqlserver;") ◄<br> 8 ------- - - - - - - - - - - - - - - -
-<br> ◄ If: connection le "0" ◄<br> Then: show "@Cannot not open a connection to "<connection ◄<br> 9 ------- - - - - - - - - - - - - - - - -<br> ◄ If: connection le
"0" ◄<br> Then: msgbox "Last ODBC error:\n" & @odbcerror["1"] & @odbcerror["2"] ◄<br> 10 ------- - - - - - - - - - - - - - - - -<br> ◄
If: ◄<br> Then: tablename = "PST" ◄<br> 11 ------- - - - - - - - - - - - -
- - - -<br> ◄ If: ◄<br> Then: stemp="Select PST_ParentItemID," ◄<br> 12 ------- - - - - - - - - - - -
- - - - -<br> ◄ If: ◄<br> Then: stemp=stemp<"PST_CompItemID," ◄<br> 13 ------- - - - - - - - -
- - - - - - - -<br> ◄ If: ◄<br> Then: stemp=stemp<"PST_QtyPerAssy," ◄<br> 14 ------- - - - - -
- - - - - - - - - - -<br> ◄ If: ◄<br> Then: stemp=stemp<"PST_EffStartDate" ◄<br> 15 ------- - - -
- - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: stemp=stemp<"from"<tablename ◄<br> 16 -------
- - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: stemp=stemp<"WHERE PST_EffStopDate is Null" ◄<br> 17 ------- - -
- - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: recordset = new ODBC(connection, stemp) ◄<br> 18 ------- - - -
- - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: odbc recordset query stemp ◄<br> 19 -------
- - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: n(3,.0)=@odbc.recordset["0"]; r(5,.0)="1" ◄<br> 20 ------- - -
- - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: odbc recordset getfirst
◄<br> 21 ------- - - - - - - - - - - - - - - - -<br>setfld ◄ If: ◄<br> Then: a(20,*)=@odbc.recordset ("PST_ParentItemID") ◄<br> 22 ------- - -
- - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: show "Processing Record"<r<"Part"<a{"" ◄<br> 23 ------- - -
- - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: b(20,*)=@odbc.recordset ("PST_CompItemID") ◄<br> 24 ------- - - - -
- - - - - - - - - - - -<br> ◄ If: ◄<br> Then: q(9,.4)=@odbc.recordset ("PST_QtyPerAssy") ◄<br> 25 ------- - - - - - -
- - - - - - - - - -<br> ◄ If: ◄<br> Then: d(10,mdyy/)=@odbc.recordset ("PST_EffStartDate") ◄<br> 26 ------- - - - - - - - - - -
- - - - - -<br> ◄ If: ◄<br> Then: r=r+"1" ◄<br> 27 -------
- - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then: gosub
sendit ◄<br> 28 ------- - - - - - - - - - - - - - - - -<br> ◄ If: @odbc.recordset.eof ne "1" ◄<br> Then: odbc recordset getnext; goto
setfld ◄<br> 29 ------- - - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then:
end ◄<br> 30 ------- - - - - - - - - - - - - - - - -<br>sendit ◄ If: a eq
"" ◄<br> Then: return ◄<br> 31 ------- - - - - - - - - - - -
- - - - -<br> ◄ If: ◄<br> Then: lookup miv = bom r=free -e ◄<br> 32 ------- - - - - - - - -
- - - - - - - -<br> ◄ If: ◄<br> Then: miv(1)=a;miv(2)=b;miv(3)=q;miv(4)=d ◄<br> 33 ------- - - - - - - - -
- - - - - - - -<br> ◄ If: ◄<br> Then: write miv ◄<br> 34
------- - - - - - - - - - - - - - - - -<br> ◄ If: ◄<br> Then:
return ◄<br> 35 ------- - - - - - - - - - - - - - - - -<br> ◄
If: ◄<br></div></div></body></html>