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 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线