2

我在 Visual Studio 2008 的查询窗格中生成了一个我似乎无法弄清楚的错误。

函数参数列表中的错误:“=”无法识别。无法解析查询文本。

在对语法进行一些清理并添加一些适当的引号后,问题仍然存在。无论如何,我都尝试执行查询,最终在 Visual Studio 2008 中无休止地等待。

这是查询。

 SELECT 
 leg.tsrido, 
 leg.tsrnum, 
 shipment.dosvlg, 
 condition(leg.tsakti = 1, load.land, unload.land), 
 condition(leg.tsakti = 1, load.postun, unload.postun), 
 condition(leg.tsakti = 1, load.tsadr1, unload.tsadr1) 

 FROM 
 tsroma leg 
 LEFT OUTER JOIN (SELECT * FROM tsdsmd WHERE (srtdos = 'd')) shipment 
 ON leg.dosvlg = shipment.dosvlg 

 LEFT OUTER JOIN (SELECT * FROM tsdnaw WHERE (tsroln = 1)) load 
 ON leg.dosvlg = load.dosvlg 

 LEFT OUTER JOIN (SELECT * FROM tsdnaw WHERE (tsroln = 3)) unload 
 ON leg.dosvlg = unload.dosvlg 

 WHERE (leg.tsrido = 79106279)

 ORDER BY 2

我正在使用 ODBC,连接字符串包括 Driver={UNIMS}。这是一个非常古老的数据库,我必须在我的应用程序中支持它。

某处的语法可能有问题,但我看不到。

Edit1: 这是一个在 UNIMS 数据库上“工作”的示例条件代码。(从旧应用程序中的 AnsiString 中取出。)

condition(leg.tstohn = '" + pAuthorization[7] + "', shipment.pllaad, shipment.pllos)
condition(leg.tstohn = '" + pAuthorization[7] + "', shipment.tslzcd, shipment.tsuzcd)
condition(leg.tstohn = '" + pAuthorization[7] + "', shipment.lalaad, shipment.lalos)         
condition(leg.tstohn = '" + pAuthorization[7] + "', shipment.nmlaad, shipment.nmlos) zkafz
condition(leg.tstohn = '" + pAuthorization[7] + "', shipment.adrlaa, shipment.adrlos)

编辑2:

也找不到关于 UNIMS SQL UNIMS SQL 的很多文档。这里有更多可能有帮助的信息。

  • 司机={UNIMS};
  • 用于 ODBC 的 .NET Framework 数据提供程序
  • UNIMS SQL
  • 州公开赛
  • 版本 02.05.0028

Edit3: 这是整个 C# 代码

public string qShipments(string a)
{
    string q = "";
    #region Oracle
    if (env == "Oracle")
    {
        /* string Oracle_Shipment
         * Alias issue: http://stackoverflow.com/questions/14218695/ora-00972-identifier-is-too-long
                        SELECT DISTINCT
                        csl."tripNumber",
                        csl."shipmentNumber",
                        csl."legType",
                        csl."planSequence",
                        csl."toHubSearchname",
                        CASE WHEN csl."legType" = 1 THEN Address1."countryCode" ELSE Address3."countryCode" END countryCode,
                        CASE WHEN csl."legType" = 1 THEN Address1."postcode" ELSE Address3."postcode" END postcode,
                        CASE WHEN csl."legType" = 1 THEN Address1."streetLine1" ELSE  Address3."streetLine1" END streetLine

                        FROM 
                        "cef_v_cw_trip" ct 
                        LEFT OUTER JOIN "cef_v_cw_shipmentLegs" csl 
                        ON ct."tripNumber" = csl."tripNumber"

                        LEFT OUTER JOIN "cef_v_cw_shipment" cs 
                        ON csl."shipmentNumber" = cs."shipmentNumber"

                        LEFT OUTER JOIN (SELECT * FROM "cef_v_cw_fileAddress" WHERE "addressRole" = 1) Address1
                        ON cs."shipmentNumber" = Address1."fileNumber"

                        LEFT OUTER JOIN (SELECT * FROM "cef_v_cw_fileAddress" WHERE "addressRole" = 3) Address3
                        ON cs."shipmentNumber" = Address3."fileNumber"

                        WHERE ct."tripNumber" = '1045013'
                        AND csl."toHubSearchname" <> ' '
                        ORDER BY 4
         */
        q = string.Format("SELECT DISTINCT " +
                             "csl.\"tripNumber\", " +
                             "csl.\"shipmentNumber\", " +
                             "csl.\"legType\", " +
                             "csl.\"planSequence\", " +
                             "csl.\"toHubSearchname\", " +
                             "CASE WHEN csl.\"legType\" = 1 THEN Address1.\"countryCode\" ELSE Address3.\"countryCode\" END countryCode, " +
                             "CASE WHEN csl.\"legType\" = 1 THEN Address1.\"postcode\" ELSE Address3.\"postcode\" END postcode, " +
                             "CASE WHEN csl.\"legType\" = 1 THEN Address1.\"streetLine1\" ELSE  Address3.\"streetLine1\" END streetLine " +
                             "FROM " +
                             "\"{0}v_cw_trip\" ct " +
                             "LEFT OUTER JOIN \"{0}v_cw_shipmentLegs\" csl " +
                             "ON ct.\"tripNumber\" = csl.\"tripNumber\" " +
                             "LEFT OUTER JOIN \"{0}v_cw_shipment\" cs " +
                             "ON csl.\"shipmentNumber\" = cs.\"shipmentNumber\" " +
                             "LEFT OUTER JOIN (SELECT * FROM \"{0}v_cw_fileAddress\" WHERE \"addressRole\" = 1) Address1 " +
                             "ON cs.\"shipmentNumber\" = Address1.\"fileNumber\" " +
                             "LEFT OUTER JOIN (SELECT * FROM \"{0}v_cw_fileAddress\" WHERE \"addressRole\" = 3) Address3 " +
                             "ON cs.\"shipmentNumber\" = Address3.\"fileNumber\" " +
                             "WHERE ct.\"tripNumber\" = {1} " +
                             "AND csl.\"toHubSearchname\" <> ' ' " +
                             "ORDER BY 4", prefix, a.ToString());
    }
    #endregion

    #region UNIMS
    if (env == "UNIMS")
    {
        /* string Unims shipment  
         * http://stackoverflow.com/questions/14379573/error-in-list-of-function-arguments-not-recognized-unable-to-parse-query-t
             SELECT 
             leg.tsrido, 
             leg.tsrnum, 
             shipment.dosvlg, 
             condition(leg.tsakti = 1, load.land, unload.land), 
             condition(leg.tsakti = 1, load.postun, unload.postun), 
             condition(leg.tsakti = 1, load.tsadr1, unload.tsadr1) 

             FROM 
             tsroma leg 
             LEFT OUTER JOIN (SELECT * FROM tsdsmd WHERE (srtdos = 'd')) shipment 
             ON leg.dosvlg = shipment.dosvlg 

             LEFT OUTER JOIN (SELECT * FROM tsdnaw WHERE (tsroln = 1)) load 
             ON leg.dosvlg = load.dosvlg 

             LEFT OUTER JOIN (SELECT * FROM tsdnaw WHERE (tsroln = 3)) unload 
             ON leg.dosvlg = unload.dosvlg 

             WHERE (leg.tsrido = 79106279)

             ORDER BY 2
         */
        q = string.Format("SELECT " +
                        "leg.tsrido, " +
                        "leg.tsrnum, " +
                        "shipment.dosvlg, " +
                        "condition(leg.tsakti = 1, load.land, unload.land), " +
                        "condition(leg.tsakti = 1, load.postun, unload.postun), " +
                        "condition(leg.tsakti = 1, load.tsadr1, unload.tsadr1) " +
                        "FROM " +
                        "tsroma leg " +
                        "LEFT OUTER JOIN (SELECT * FROM tsdsmd WHERE srtdos = 'd') shipment " +
                        "ON leg.dosvlg = shipment.dosvlg " +
                        "LEFT OUTER JOIN (SELECT * FROM tsdnaw where tsroln = 1) load " +
                        "ON leg.dosvlg = load.dosvlg " +
                        "LEFT OUTER JOIN (SELECT * FROM tsdnaw where tsroln = 3) unload " +
                        "ON leg.dosvlg = unload.dosvlg " +
                        "WHERE leg.tsrido = {1} " +
                        "ORDER BY 2", prefix, a.ToString());
    }
    #endregion
    return q;
}

Edit4: 我注意到当我删除下面的案例时查询是无止境的。我想我将首先重新考虑我的 ODBC 连接。

Edit5: 在大多数情况下,似乎不适用于 PuTTY 或直接用于机器。由于某种原因,它最终会导致资源占用查询。新方法:在 PuTTY 中使用正确的查询解决了问题,但在 ODBC Unims 中尚未接受

                select 
                    leg.tsrido, 
                    leg.tsrnum, 
                    dosier.dosvlg, 
                    condition(leg.tsakti = 1, dosier.lalaad, dosier.lalos), 
                    condition(leg.tsakti = 1, dosier.pklaad, dosier.pklos), 
                    condition(leg.tsakti = 1, dosier.tsla1,  dosier.tsua1) 

                from 
                    tsroma leg 
                    left outer join dosier 
                    on leg.dosvlg = dosier.dosvlg 
                where 
                    leg.tsrido = 79106279

                order by 2;

最终编辑:

尽管 Visual Studio 无法识别条件的 unim 语法,但上述代码仍能正常工作。根据服务器,旧查询被卡住并且大小超过 100 MB,杀死了这些进程。有 10 年历史的数据库确实是一件奇怪的事情。

4

1 回答 1

2

我对 UniMS 不熟悉,但也许以下其中一种方法会起作用:

             (case when leg.tsakti = 1 then load.land else unload.land end), 
             (case when condition(leg.tsakti = 1 then load.postun else unload.postun end), 
             (case when condition(leg.tsakti = 1 then load.tsadr1 else unload.tsadr1 end) 

或者:

             iif(leg.tsakti = 1, load.land, unload.land), 
             iif(leg.tsakti = 1, load.postun, unload.postun), 
             iif(leg.tsakti = 1, load.tsadr1, unload.tsadr1) 

或者:

             if(leg.tsakti = 1, load.land, unload.land), 
             if(leg.tsakti = 1, load.postun, unload.postun), 
             if(leg.tsakti = 1, load.tsadr1, unload.tsadr1) 

这些在其他一些数据库中工作。

于 2013-01-17T14:18:48.193 回答