函数参数列表出错:'='无法识别。无法解析查询文本

时间:2013-01-17 12:52:25

标签: sql visual-studio-2008 odbc

我在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数据库中“WORKS”的示例条件代码。 (取自旧应用程序中的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)

EDIT2:

也无法找到有关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无法识别条件的unims语法,但上面的代码仍能正常工作。根据服务器,旧查询被卡住并且大小超过100 MB,从而杀死了这些进程。 10年的数据库确实很奇怪。

1 个答案:

答案 0 :(得分: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) 

这些在其他一些数据库中有效。