c++ - 将 < >'' 转换为 sql_oracle

标签 c++ c++builder-5

我正在将一些代码从 sql 重写到 sql_oracle,但我找不到 <>'' 的解决方案。

!= '' 将不起作用。

如果我可以翻译 <>'' 它应该可以。我已经用谷歌搜索了很多,但找不到任何遮阳篷。我在编码方面经验不足,所以也许有人可以帮助我。

这是sql代码

    SQL_genericp2.Insert(
            "from   tsdsmd  trip                            "
            "       left outer join                         "
            "       (                                       "
            "       select  tsroma.* from tsroma            "
            "       where   tsroma.tstohn <> ''             "
            "       )       leg                             "
            "       on      trip.dosvlg = leg.tsrido        "
            "       left outer join dosier shipment         "
            "       on      leg.dosvlg = shipment.dosvlg    "
            "       left outer join                         "
            "       (                                       "
            "       select  * from tsdsco                   "
            "       where   laloin = 1 and volgnr = 1       "
            "       )       tsdsco1                         "
            "       on      leg.dosvlg = tsdsco1.dosvlg     "
            "       left outer join                         "
            "       (                                       "
            "       select  * from tsdsco                   "
            "       where   laloin = 2 and volgnr = 1       "
            "       )       tsdsco2                         "
            "       on      leg.dosvlg = tsdsco2.dosvlg     "
            ,1);
    </i>

这是 sql_orcale 代码:

    SQL_Oracle_genericp2.Insert(
            "from                                                       "
            "        \"dkf_tsdsmd\"                                                             trip        "
            "                                                       "
            "        left outer join                                            "
            "        (select  * from \"dkf_tsroma\" where \"tstohn\" != '')                     leg     "
            "        on      trip.\"dosvlg\" = leg.\"tsrido\"                               "
            "                                                       "
            "   left outer join                                             "
            "        \"dkf_tsdsmd\"                                                                 shipment    "
            "        on      leg.\"dosvlg\" = shipment.\"dosvlg\"                               "
            "                                                       "
            "   left outer join                                             "
            "   (                                                   "
            "   select                                                  "
            "       \"fileNumber\"                                  \"dosvlg\", "
            "       max(case when \"addressRole\" = 0 then \"relationSearchname\"   else null end)  \"zoek0\",  "
            "       max(case when \"addressRole\" = 0 then \"nameLine1\"        else null end)  \"tsnam10\",    "
            "       max(case when \"addressRole\" = 0 then \"streetLine1\"      else null end)  \"tsadr10\",    "
            "       max(case when \"addressRole\" = 0 then \"countryCode\"      else null end)  \"land0\",  "
            "       max(case when \"addressRole\" = 0 then \"placeName\"        else null end)  \"tscity0\",    "
            "       max(case when \"addressRole\" = 0 then \"postcode\"     else null end)  \"postun0\",    "
            "                                                       "
            "       max(case when \"addressRole\" = 1 then \"relationSearchname\"   else null end)  \"zoek1\",  "
            "       max(case when \"addressRole\" = 1 then \"nameLine1\"        else null end)  \"tsnam11\",    "
            "       max(case when \"addressRole\" = 1 then \"streetLine1\"      else null end)  \"tsadr11\",    "
            "       max(case when \"addressRole\" = 1 then \"countryCode\"      else null end)  \"land1\",  "
            "       max(case when \"addressRole\" = 1 then \"placeName\"        else null end)  \"tscity1\",    "
            "       max(case when \"addressRole\" = 1 then \"postcode\"     else null end)  \"postun1\",    "
            "                                                       "
            "       max(case when \"addressRole\" = 3 then \"relationSearchname\"   else null end)  \"zoek3\",  "
            "       max(case when \"addressRole\" = 3 then \"nameLine1\"        else null end)  \"tsnam13\",    "
            "       max(case when \"addressRole\" = 3 then \"streetLine1\"      else null end)  \"tsadr13\",    "
            "       max(case when \"addressRole\" = 3 then \"countryCode\"      else null end)  \"land3\",  "
            "       max(case when \"addressRole\" = 3 then \"placeName\"        else null end)  \"tscity3\",    "
            "       max(case when \"addressRole\" = 3 then \"postcode\"     else null end)  \"postun3\",    "
            "                                                       "
            "       max(case when \"addressRole\" = 4 then \"relationSearchname\"   else null end)  \"zoek4\",  "
            "       max(case when \"addressRole\" = 4 then \"nameLine1\"        else null end)  \"tsnam14\",    "
            "       max(case when \"addressRole\" = 4 then \"streetLine1\"      else null end)  \"tsadr14\",    "
            "       max(case when \"addressRole\" = 4 then \"countryCode\"      else null end)  \"land4\",  "
            "       max(case when \"addressRole\" = 4 then \"placeName\"        else null end)  \"tscity4\",    "
            "       max(case when \"addressRole\" = 4 then \"postcode\"     else null end)  \"postun4\" "
            "   from                                                    "
            "       \"dkf_v_cw_fileAddress\"                                    "
            "   group by                                                "
            "       \"fileNumber\"                                          "
            "   )                                           tsdnaw      "
            "   on  leg.\"dosvlg\" = tsdnaw.\"dosvlg\"                              "
            "                                                       "
            "   left outer join                                             "
            "   (                                                   "
            "   select                                                  "
            "       \"dkf_tsdsco\".\"dosvlg\"                           \"dosvlg\", "
            "       max(case when \"laloin\" = 1 and \"volgnr\" = 1 then \"tsfrti\" else null end)  \"tsfrti1\",    "
            "       max(case when \"laloin\" = 1 and \"volgnr\" = 1 then \"tsttim\" else null end)  \"tsttim1\",    "
            "       max(case when \"laloin\" = 2 and \"volgnr\" = 1 then \"tsfrti\" else null end)  \"tsfrti2\",    "
            "       max(case when \"laloin\" = 2 and \"volgnr\" = 1 then \"tsttim\" else null end)  \"tsttim2\" "
            "   from                                                    "
            "       \"dkf_tsdsco\"                                          "
            "   group by                                                "
            "       \"dosvlg\"                                          "
            "   )                                           tsdsco      "
            "       on  leg.\"dosvlg\" = tsdsco.\"dosvlg\"                              "
            ,1);

最佳答案

tsroma.tstohn <> '' 

Oracle 将空字符串视为 NULL。所以在这种情况下,你必须把它写成

tsroma.tstohn IS NOT NULL

您还需要考虑空字符串变为 NULL 是否会对您的数据模型造成问题。

关于c++ - 将 < >'' 转换为 sql_oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13026330/

相关文章:

c++ - 事件响应比信号量快?

c++ - 将 Char 值分配给 vector 元素。 C++

c++ - 函数返回类型中的模板类型推导

c++ - 无法访问打印机 Borland C++ 5

c++ - 如何解决 Borland C++(5.02 版)中的 libCurl 链接器错误?

c++ - try __finally block 中可能的堆栈损坏

c# - 我怎样才能在没有点击或发件人或其他任何东西的情况下实现一个事件?

C++ 均值和中值绝对偏差返回相同的奇怪符号

delphi - 如果我有 dll 源代码,是否可以从 Delphi 调试 C++builder dll?