Sybase IQ 12.7 isql命令疑问?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sybase IQ 12.7 isql命令疑问?相关的知识,希望对你有一定的参考价值。

新公司有用Sybase IQ,主管让安装一个sybase数据库,但是安装完后,isql不能用,不知为何。HQYWAPP-TEST1:sybase > isqlPassword: CT-LIBRARY error: ct_connect(): directory service layer: internal directory control layer error: Requested server name not found.看了网上说要配置interfaces文件,但是具体不知道如何配,目前该文件是空的。环境:AIX5.3

参考技术A 应该是环境没设好:Requested server name not found. 参考技术B isql -Uxxx -Pxxx -Sxxx这些要一起写好才行呀。

将查询从 Sybase IQ 转换为 impala

【中文标题】将查询从 Sybase IQ 转换为 impala【英文标题】:Converting a query from Sybase IQ to impala 【发布时间】:2019-02-17 16:58:55 【问题描述】:
SELECT f.exch 
FROM   ( 
              SELECT 
                     CASE 
                            WHEN sourcedesk IN ('GOBUS_NY', 
                                                'GOBUS_UK', 
                                                'PETRDAES', 
                                                'PEETRAD') THEN clientid 
                            WHEN sourcedesk = 'AESLDN' 
                            AND    clientid != '' THEN clientid 
                            ELSE owner 
                     END                               AS aclient, 
                     clientid                          AS client, 
                     orderid                           AS gaotag, 
                     exchange                          AS exch, 
                     side                              AS side, 
                     securityid                        AS sym, 
                     cumulativequantity*executionprice AS value, 
                     cumulativequantity                AS qdone, 
                     fillid                            AS gaftag, 
                     executionexchangetimestamplcl     AS xstamp, 
                     executionprice                    AS lprice, 
                     executionexchangeid               AS xftag, 
                     serverid                          AS srvid, 
                     reasoncode                        AS rescode, 
                     rootfillid                        AS rgaftag, 
                     miccode                           AS miccode, 
                     mifidtradeflags                   AS mifidtradeflags, 
                     sourcedesk                        AS desk 
              FROM   fillsastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    exchange = 'VEX' 
              AND    sourceservicename LIKE 'vexprod%' 
              AND    securityid LIKE '%.%' 
              UNION ALL 
              SELECT 
                     CASE 
                            WHEN sourcedesk IN ('GOBUS_NY', 
                                                'GOBUS_UK', 
                                                'PETRDAES', 
                                                'PEETRAD', 
                                                'VEXSVC', 
                                                'LLSOR') THEN clientid 
                            WHEN sourcedesk = 'AESLDN' 
                            AND    clientid != '' THEN clientid 
                            ELSE owner 
                     END                               AS aclient, 
                     clientid                          AS client, 
                     orderid                           AS gaotag, 
                     exchange                          AS exch, 
                     side                              AS side, 
                     securityid                        AS sym, 
                     cumulativequantity*executionprice AS value, 
                     cumulativequantity                AS qdone, 
                     fillid                            AS gaftag, 
                     executionexchangetimestamplcl     AS xstamp, 
                     executionprice                    AS lprice, 
                     executionexchangeid               AS xftag, 
                     serverid                          AS srvid, 
                     reasoncode                        AS rescode, 
                     rootfillid                        AS rgaftag, 
                     miccode                           AS miccode, 
                     mifidtradeflags                   AS mifidtradeflags, 
                     sourcedesk                        AS desk 
              FROM   fillsastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    sourceservicename IN ('SORUK', 
                                           'PRODSorBkFlr', 
                                           'PRODFixBkFlr', 
                                           'PRODFixBkFlr1', 
                                           'PRODFixBkFlr2', 
                                           'PRODSmgBkFlr', 
                                           'ECGaia2Agora') 
              AND    owner NOT LIKE 'tree%' 
              AND    securityid LIKE '%.%' 
              UNION ALL 
              SELECT 
                     CASE 
                            WHEN sourcedesk IN ('GOBUS_NY', 
                                                'GOBUS_UK', 
                                                'PETRDAES', 
                                                'PEETRAD', 
                                                'VEXSVC', 
                                                'LLSOR') THEN clientid 
                            WHEN sourcedesk = 'AESLDN' 
                            AND    clientid != '' THEN clientid 
                            ELSE owner 
                     END                               AS aclient, 
                     clientid                          AS client, 
                     orderid                           AS gaotag, 
                     exchange                          AS exch, 
                     side                              AS side, 
                     securityid                        AS sym, 
                     cumulativequantity*executionprice AS value, 
                     cumulativequantity                AS qdone, 
                     fillid                            AS gaftag, 
                     executionexchangetimestamplcl     AS xstamp, 
                     executionprice                    AS lprice, 
                     executionexchangeid               AS xftag, 
                     serverid                          AS srvid, 
                     reasoncode                        AS rescode, 
                     rootfillid                        AS rgaftag, 
                     miccode                           AS miccode, 
                     mifidtradeflags                   AS mifidtradeflags, 
                     sourcedesk                        AS desk 
              FROM   fillsastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    securityid LIKE '%.%' 
              AND    exchange = 'BENCHMKX' 
              AND    sourceservicename LIKE 'BENCHM_%' 
              UNION ALL 
              SELECT 
                     CASE 
                            WHEN sourcedesk IN ('GOBUS_NY', 
                                                'GOBUS_UK', 
                                                'PETRDAES', 
                                                'PEETRAD', 
                                                'VEXSVC', 
                                                'LLSOR') THEN clientid 
                            WHEN sourcedesk = 'AESLDN' 
                            AND    clientid != '' THEN clientid 
                            ELSE owner 
                     END                               AS aclient, 
                     clientid                          AS client, 
                     orderid                           AS gaotag, 
                     exchange                          AS exch, 
                     side                              AS side, 
                     securityid                        AS sym, 
                     cumulativequantity*executionprice AS value, 
                     cumulativequantity                AS qdone, 
                     fillid                            AS gaftag, 
                     executionexchangetimestamplcl     AS xstamp, 
                     executionprice                    AS lprice, 
                     executionexchangeid               AS xftag, 
                     serverid                          AS srvid, 
                     reasoncode                        AS rescode, 
                     rootfillid                        AS rgaftag, 
                     miccode                           AS miccode, 
                     mifidtradeflags                   AS mifidtradeflags, 
                     sourcedesk                        AS desk 
              FROM   fillsastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    sourceservicename = 'ECGaia2Agora' 
              AND    owner NOT LIKE 'tree%' 
              AND    exchange IN ('BATS', 
                                  'CHIX') 
              AND    reasoncode = 'NT' 
              AND    side = 'B' 
              UNION ALL 
              SELECT 
                     CASE 
                            WHEN sourcedesk IN ('GOBUS_NY', 
                                                'GOBUS_UK', 
                                                'PETRDAES', 
                                                'PEETRAD', 
                                                'VEXSVC', 
                                                'LLSOR') THEN clientid 
                            WHEN sourcedesk = 'AESLDN' 
                            AND    clientid != '' THEN clientid 
                            ELSE owner 
                     END                               AS aclient, 
                     clientid                          AS client, 
                     orderid                           AS gaotag, 
                     exchange                          AS exch, 
                     side                              AS side, 
                     securityid                        AS sym, 
                     cumulativequantity*executionprice AS value, 
                     cumulativequantity                AS qdone, 
                     fillid                            AS gaftag, 
                     executionexchangetimestamplcl     AS xstamp, 
                     executionprice                    AS lprice, 
                     executionexchangeid               AS xftag, 
                     serverid                          AS srvid, 
                     reasoncode                        AS rescode, 
                     rootfillid                        AS rgaftag, 
                     miccode                           AS miccode, 
                     mifidtradeflags                   AS mifidtradeflags, 
                     sourcedesk                        AS desk 
              FROM   fillsastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    sourceservicename LIKE 'tars_%' ) AS f, 
       ( 
              SELECT orderid             AS gaotag, 
                     serverid            AS srvid, 
                     securityidasentered AS enteredsym, 
                     securityid          AS sym, 
                     rootorderid         AS rgaotag, 
                     timeinforce         AS tif, 
                     settletype          AS settletype, 
                     sourceservicename   AS appl, 
                     account             AS acct 
              FROM   ordersastextdatestring 
              WHERE  agoralocaltradedate = '190205' 
              AND    destinationdesk IN ('BENCHX', 
                                         'VEXSVC', 
                                         'SORMKT', 
                                         'MAIA', 
                                         'LLSOR', 
                                         'TARSSVC')) AS o, 
where  f.gaotag = o.gaotag

上述查询失败,在 impala 中出现以下错误:

AnalysisException:第 4 行中的语法错误:undefined: where f.gaotag = o.gaotag ^ 遇到:WHERE Expected: DEFAULT, IDENTIFIER CAUSED BY: Exception: Syntax error

我浏览了以下 cloudera 链接: https://www.cloudera.com/documentation/enterprise/5-4-x/topics/impala_subqueries.html 但无法完成这项工作。

我是 Sybase IQ 和 Imapala 的新手。

【问题讨论】:

至少尝试以可读的方式格式化代码 @deb 。 . .简化!尝试在 Impala 中逐个、逐列、逐表地构建查询。 【参考方案1】:

你可以尝试用下面的查询替换最后一个查询并尝试运行它 -

SELECT f.exch 
FROM   (SELECT CASE 
                 WHEN sourcedesk IN ( 'GOBUS_NY', 'GOBUS_UK', 'PETRDAES', 
                                      'PEETRAD' ) 
                       THEN 
                 clientid 
                 WHEN sourcedesk = 'AESLDN' 
                      AND clientid != '' THEN clientid 
                 ELSE owner 
               END                                 AS aclient, 
               clientid                            AS client, 
               orderid                             AS gaotag, 
               exchange                            AS exch, 
               side                                AS side, 
               securityid                          AS sym, 
               cumulativequantity * executionprice AS value, 
               cumulativequantity                  AS qdone, 
               fillid                              AS gaftag, 
               executionexchangetimestamplcl       AS xstamp, 
               executionprice                      AS lprice, 
               executionexchangeid                 AS xftag, 
               serverid                            AS srvid, 
               reasoncode                          AS rescode, 
               rootfillid                          AS rgaftag, 
               miccode                             AS miccode, 
               mifidtradeflags                     AS mifidtradeflags, 
               sourcedesk                          AS desk 
        FROM   fillsastextdatestring 
        WHERE  agoralocaltradedate = '190205' 
               AND exchange = 'VEX' 
               AND sourceservicename LIKE 'vexprod%' 
               AND securityid LIKE '%.%' 
        UNION ALL 
        SELECT CASE 
                 WHEN sourcedesk IN ( 'GOBUS_NY', 'GOBUS_UK', 'PETRDAES', 
                                      'PEETRAD', 
                                      'VEXSVC', 'LLSOR' ) THEN clientid 
                 WHEN sourcedesk = 'AESLDN' 
                      AND clientid != '' THEN clientid 
                 ELSE owner 
               END                                 AS aclient, 
               clientid                            AS client, 
               orderid                             AS gaotag, 
               exchange                            AS exch, 
               side                                AS side, 
               securityid                          AS sym, 
               cumulativequantity * executionprice AS value, 
               cumulativequantity                  AS qdone, 
               fillid                              AS gaftag, 
               executionexchangetimestamplcl       AS xstamp, 
               executionprice                      AS lprice, 
               executionexchangeid                 AS xftag, 
               serverid                            AS srvid, 
               reasoncode                          AS rescode, 
               rootfillid                          AS rgaftag, 
               miccode                             AS miccode, 
               mifidtradeflags                     AS mifidtradeflags, 
               sourcedesk                          AS desk 
        FROM   fillsastextdatestring 
        WHERE  agoralocaltradedate = '190205' 
               AND sourceservicename IN ( 'SORUK', 'PRODSorBkFlr', 
                                          'PRODFixBkFlr', 
                                          'PRODFixBkFlr1', 
                                          'PRODFixBkFlr2', 'PRODSmgBkFlr', 
                                          'ECGaia2Agora' ) 
               AND owner NOT LIKE 'tree%' 
               AND securityid LIKE '%.%' 
        UNION ALL 
        SELECT CASE 
                 WHEN sourcedesk IN ( 'GOBUS_NY', 'GOBUS_UK', 'PETRDAES', 
                                      'PEETRAD', 
                                      'VEXSVC', 'LLSOR' ) THEN clientid 
                 WHEN sourcedesk = 'AESLDN' 
                      AND clientid != '' THEN clientid 
                 ELSE owner 
               END                                 AS aclient, 
               clientid                            AS client, 
               orderid                             AS gaotag, 
               exchange                            AS exch, 
               side                                AS side, 
               securityid                          AS sym, 
               cumulativequantity * executionprice AS value, 
               cumulativequantity                  AS qdone, 
               fillid                              AS gaftag, 
               executionexchangetimestamplcl       AS xstamp, 
               executionprice                      AS lprice, 
               executionexchangeid                 AS xftag, 
               serverid                            AS srvid, 
               reasoncode                          AS rescode, 
               rootfillid                          AS rgaftag, 
               miccode                             AS miccode, 
               mifidtradeflags                     AS mifidtradeflags, 
               sourcedesk                          AS desk 
        FROM   fillsastextdatestring 
        WHERE  agoralocaltradedate = '190205' 
               AND securityid LIKE '%.%' 
               AND exchange = 'BENCHMKX' 
               AND sourceservicename LIKE 'BENCHM_%' 
        UNION ALL 
        SELECT CASE 
                 WHEN sourcedesk IN ( 'GOBUS_NY', 'GOBUS_UK', 'PETRDAES', 
                                      'PEETRAD', 
                                      'VEXSVC', 'LLSOR' ) THEN clientid 
                 WHEN sourcedesk = 'AESLDN' 
                      AND clientid != '' THEN clientid 
                 ELSE owner 
               END                                 AS aclient, 
               clientid                            AS client, 
               orderid                             AS gaotag, 
               exchange                            AS exch, 
               side                                AS side, 
               securityid                          AS sym, 
               cumulativequantity * executionprice AS value, 
               cumulativequantity                  AS qdone, 
               fillid                              AS gaftag, 
               executionexchangetimestamplcl       AS xstamp, 
               executionprice                      AS lprice, 
               executionexchangeid                 AS xftag, 
               serverid                            AS srvid, 
               reasoncode                          AS rescode, 
               rootfillid                          AS rgaftag, 
               miccode                             AS miccode, 
               mifidtradeflags                     AS mifidtradeflags, 
               sourcedesk                          AS desk 
        FROM   fillsastextdatestring 
        WHERE  agoralocaltradedate = '190205' 
               AND sourceservicename = 'ECGaia2Agora' 
               AND owner NOT LIKE 'tree%' 
               AND exchange IN ( 'BATS', 'CHIX' ) 
               AND reasoncode = 'NT' 
               AND side = 'B' 
        UNION ALL 
        SELECT CASE 
                 WHEN sourcedesk IN ( 'GOBUS_NY', 'GOBUS_UK', 'PETRDAES', 
                                      'PEETRAD', 
                                      'VEXSVC', 'LLSOR' ) THEN clientid 
                 WHEN sourcedesk = 'AESLDN' 
                      AND clientid != '' THEN clientid 
                 ELSE owner 
               END                                 AS aclient, 
               clientid                            AS client, 
               orderid                             AS gaotag, 
               exchange                            AS exch, 
               side                                AS side, 
               securityid                          AS sym, 
               cumulativequantity * executionprice AS value, 
               cumulativequantity                  AS qdone, 
               fillid                              AS gaftag, 
               executionexchangetimestamplcl       AS xstamp, 
               executionprice                      AS lprice, 
               executionexchangeid                 AS xftag, 
               serverid                            AS srvid, 
               reasoncode                          AS rescode, 
               rootfillid                          AS rgaftag, 
               miccode                             AS miccode, 
               mifidtradeflags                     AS mifidtradeflags, 
               sourcedesk                          AS desk 
        FROM   fillsastextdatestring 
        WHERE  agoralocaltradedate = '190205' 
               AND sourceservicename LIKE 'tars_%') AS f 
       INNER JOIN (SELECT orderid             AS gaotag, 
                          serverid            AS srvid, 
                          securityidasentered AS enteredsym, 
                          securityid          AS sym, 
                          rootorderid         AS rgaotag, 
                          timeinforce         AS tif, 
                          settletype          AS settletype, 
                          sourceservicename   AS appl, 
                          account             AS acct 
                   FROM   ordersastextdatestring 
                   WHERE  agoralocaltradedate = '190205' 
                          AND destinationdesk IN ( 'BENCHX', 'VEXSVC', 'SORMKT', 
                                                   'MAIA' 
                                                   , 
                                                   'LLSOR', 'TARSSVC' )) o 
               ON f.gaotag = o.gaotag;

【讨论】:

您能否运行每个单独的查询并告诉我们哪个特定查询有问题.. 取 union all 的每个部分并尝试获取结果 问题似乎出在内部联接或 where 子句上,其余的查询在单独运行时运行良好。 问题是我添加的连接语法,你现在可以再检查一下吗

以上是关于Sybase IQ 12.7 isql命令疑问?的主要内容,如果未能解决你的问题,请参考以下文章

isql自动加载sql脚本

Sybase:SAP IQ学习笔记

linux中执行crontab定时任务时无法连接sybase iq15.1数据库,shell脚本中的sybase iq的环境变量怎么设置

Hibernate + Sybase Iq

将查询从 Sybase IQ 转换为 impala

Sybase IQ使用过程中注意事项