doupingtang9627 2012-10-22 19:20
浏览 87
已采纳

通过OpenEdge ODBC和PHP交叉加入Progress数据库

I currently have 2 ODBC connections set up on my web server. One that connects to the our enterprise QAD database and another that connects to our custom database used to extend our database. In this paticular example I have my employee records in the QAD database, and then an employee number in another table in the custom database.

Is there any way for me to set up a cross join between the two odbc connections in php so that I don't have to loop through the results of the first query and send several queries based on the returned results to tie my records together in a php array?

The best i've been able to come up with is to build an IN clause from my first query from our custom database, send the second query to the QAD database, and then do an array merge in php. However, this is an extremely slow process compared to a normal SQL join.

  • 写回答

3条回答 默认 最新

  • duansang8388 2012-11-16 23:44
    关注

    Not sure if you've already found a solution to this but there is a Progress article on how to do this.

    Quick Guide To Setting Up MultiDatabase ODBC Connectivity

    I had a similar requirement - I wanted to create a join between a table in the primary QAD database and a custom table in our custom database. I have tested this and it works well although my setup is slightly different. I needed to connect to QAD from Microsoft SSRS to create reports against the QAD data - I needed to create some reports that the standard QAD report designer could not handle.

    I have tested this on Progress 10.1c (this method is only supported in 10.1b+).

    So the steps I took were:

    1. Create the oesql.properties config file as per the article relevant to the primary and custom databases.
    2. Create the ODBC System DSN on the client machine (in my case a Windows Server 2008 R2 machine running SQL Server 2008 R2 with SSRS) with the additional database references as per the article.
    3. Create a Linked Server in SQL Server via the ODBC DSN
    4. Create a view which uses the OpenQuery syntax to extract data from QAD (in my case this was created in the ReportServer database) via the linked server.
    5. Create standard T-SQL query using the view in point 3 as the data source. This was ultimately the datasource for my SSRS report.

    I believe it is important that the bit versions of the OS/Database and the ODBC drivers match but haven't confirmed this yet.

    Whilst my requirement is different to your's ultimately it's the QAD server config and ODBC setup that's key. As long as your PHP client can perform a similar capability in terms of the OpenQuery command then you may get this working. I don't have any experience with PHP so can't help you there.

    It seems a bit convoluted but actually works very well and in a lot of cases actually outperforms querying data using QAD browses!

    Hope this helps.

    Edit: Here's a sample of an OpenQuery command - you can see that the table joins work in the normal way but just require and additional piece in the table reference.

    CREATE VIEW [dbo].[vQADData] AS SELECT * FROM OPENQUERY(LinkedServerName,
    '
    SELECT custTable.item_date AS DESP_DATE, so_mstr.so_site AS SITE, so_mstr.so_po AS PO_NO, so_mstr.so_inv_nbr AS INV_NO,
          ad_mstr.ad_name AS ADNAME, ad_mstr.ad_city AS ADCITY, ad_mstr.ad_state AS ADSTATE
    FROM customdbname.pub.customtable custTable
    INNER JOIN pub.so_mstr ON so_mstr.so_nbr = custTable.so_nbr
    INNER JOIN pub.ad_mstr ON ad_mstr.ad_addr = so_mstr.so_ship
    INNER JOIN pub.sod_det ON sod_det.sod_nbr = custTable.so_nbr
    WHERE so_mstr.so_site = ''SiteName'' AND so_mstr.so_shipvia = ''SHIPPER'' AND custTable.item_date IS NULL
    ')
    

    Then just access the view using normal SQL syntax.

    SELECT * FROM vQADData
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值