GVKun编程网logo

Oracle UNION 和 ORDER BY 的奇怪问题(oracle union all order by)

15

本文将分享OracleUNION和ORDERBY的奇怪问题的详细内容,并且还将对oracleunionallorderby进行详尽解释,此外,我们还将为大家带来关于ApacheSuperset向ORA

本文将分享Oracle UNION 和 ORDER BY 的奇怪问题的详细内容,并且还将对oracle union all order by进行详尽解释,此外,我们还将为大家带来关于Apache Superset 向 ORACLE 传递参数的奇怪问题、Fiori UI上my contact加了Dr. 后搜索不出数据的奇怪问题、iphone – UIDocumentInteractionController的奇怪问题、iphone – 谁能更清楚地解释CLError(kCLErrorLocationUnknown,kCLErrorDenied,kCLErrorNetwork ……)?的相关知识,希望对你有所帮助。

本文目录一览:

Oracle UNION 和 ORDER BY 的奇怪问题(oracle union all order by)

Oracle UNION 和 ORDER BY 的奇怪问题(oracle union all order by)

以下查询在几乎所有数据库(提供或采用虚拟表)中都完全有效dual,包括 Oracle:

select ''A'' as x from dual union allselect ''B''      from dualorder by x asc

返回:

| X ||---|| A || B |

现在这个查询仍然是相当标准的 SQL,但在 Oracle 上不起作用

select ''A'' as x from dual union allselect ''B''      from dual union allselect ''C''      from dualorder by x asc

我越来越

ORA-00904: "X": invalid identifier

然而,这有效:

select ''A'' as x from dual union allselect ''B'' as x from dual union allselect ''C''      from dualorder by x asc

我一直在解决这个问题,并发现显然,至少第一个子选择和倒数第二个(??) 子选择需要有一个名为x. 在第一个示例中,两个子选择似乎只是重合。工作示例:

select ''A'' as x from dual union allselect ''B''      from dual union allselect ''C''      from dual union allselect ''D''      from dual union allselect ''E''      from dual union allselect ''F'' as x from dual union allselect ''G''      from dualorder by x asc

您可能已经猜到了,这行不通:

select ''A'' as x from dual union allselect ''B''      from dual union allselect ''C''      from dual union allselect ''D''      from dual union allselect ''E'' as x from dual union allselect ''F''      from dual union allselect ''G''      from dualorder by x asc

有趣的旁注:

派生表似乎不受此限制。这有效:

select * from (  select ''A'' as x from dual union all  select ''B''      from dual union all  select ''C''      from dual)order by x asc

问题:

这是 Oracle SQL 解析器中的(已知的?)错误,还是语言语法中是否有任何非常微妙的细节,绝对需要第一个和倒数第二个子选择来保存从ORDER BY子句中引用的名称列?

答案1

这并没有真正回答问题,但它似乎是解析器错误(或“功能”)而不是语言要求。

根据 My Oracle Support,这似乎是作为错误 14196463 提出的,但没有解决就关闭了。社区线程 3561546 中也提到了它。您需要一个 MOS 帐户,或者至少是一个 Oracle 帐户,才能查看其中任何一个。

据我所知,在 OTN 线程中也讨论过它需要基本的 Oracle 登录名而不是 MOS 帐户。这也没有太多信息,但重复了您的发现,并且还表明该行为至少可以追溯到 9.2.0.8 甚至更早。

该文档有点含糊,但并不表明这预计会成为问题:

对于包含集合运算符UNIONINTERSECTMINUS或 的复合查询UNION ALL,该ORDER BY子句必须指定位置或别名而不是显式表达式。此外,该ORDER BY子句只能出现在最后一个组件查询中。该ORDER BY子句对整个复合查询返回的所有行进行排序。

您正在为您的表达式添加别名并使用它,它并没有说您必须为特定组件添加别名(尽管当然它也没有说您不必)。

该行为似乎与对最终投影有效的别名不一致,并且关于别名的通常规则仅在 order by 子句中有效 - 这似乎介于两者之间。

Apache Superset 向 ORACLE 传递参数的奇怪问题

Apache Superset 向 ORACLE 传递参数的奇怪问题

如何解决Apache Superset 向 ORACLE 传递参数的奇怪问题?

我最近遇到了一个奇怪的问题。我创建了一个数据集,并在 sql 字段中输入了以下查询

SELECT group_code,user_name FROM V_USER_GROUP_ACCESS WHERE user_name=''{{ current_username() }}''

点击保存按钮后,我被重定向到一个显示 0 计数的图表窗口。点击“查看查询”后,我看到

SELECT "count" FROM (SELECT COUNT() AS "count" FROM (SELECT group_code,user_name FROM V_BAY0_USER_GROUP_ACCESS WHERE user_name=''1234567'') expr_qry ORDER BY COUNT() DESC) WHERE ROWNUM

{{ current_username() }} 已成功替换为 ''1234567'' 如果我直接在 ORACLE 数据库中运行该查询,它将返回 count=90。我在使用 MSsql 数据库时从未遇到过同样的问题。

我希望有人能解释发生了什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Fiori UI上my contact加了Dr. 后搜索不出数据的奇怪问题

Fiori UI上my contact加了Dr. 后搜索不出数据的奇怪问题

Sent: Thursday, April 16, 2015 1:13 PM

在My task UI上维护了Account后,再点Contact F4 value help:
clipboard1

我们发现在GM6上,只要在search field里加了”Dr”, 就搜索不出来contact,如下图。但是换成诸如“Florianna Adler”就可以。

clipboard2

昨晚我们纠结了好久,想知道为什么会有这种奇怪的behavior。

上午经过debug找到了原因:

  1.  起初我们怀疑加了Dr之后的search没出来结果,是因为DB 没query到数据。今早经过验证,发现不是。Contact 的open sql是下列这个方法里动态生成的:
    

clipboard3

主要就是这4张表做inner join:

clipboard4

然后在下列这个方法里动态执行OPEN SQL,命中40条数据。
clipboard5

命中40条的原因就是OPEN SQL的where条件是扫描account的mc_name1和contact的mc_name1, mc_name2这三个字段。

clipboard6

因此,像下图中第一行和第三行这种数据也命中了,只因为它们的三个column中有一个column的value包含”DR”:
clipboard7

  1.  DB search做完后,对结果集做filter.
    

逐一遍历结果集的40条entry,对每个entry,执行三轮扫描,扫描条件定义在lt_search_f­里, 每个entry只有通过所有三轮扫描,才会最后返回给UI。

clipboard8

clipboard9

扫描的具体逻辑:检查某个entry的这三个红色的field里是否包含每轮扫描指定的key word。如果不包含,将该行entry从结果集中删除,再处理下一个。
clipboard10

clipboard11

因此,加了Dr后搜不出来结果的原因:

Contact F4 search仍然将Dr作为一个free text传入后台,在后台从DB取回来数据做filter之后,如果结果集的三个column里没有包含DR这个字符串的话,就会从结果集里过滤掉。只有name1 & name2里面形如Andrew,Dragon的contact才有机会呗search出来。
Fiori ui上Contact search看起来像google like search,但其实technical 实现(指DB query那部分)还是和Webclient ui上的search一样。
clipboard12
当然,它也支持enterprise search。
clipboard13

而BP 的title Dr是以key 0001的形式存放在field TITLE_ACA1里的,Dr只是0001的可翻译的description,所以通过Dr搜索得不到期望的结果。
clipboard14

  1.  BP的code里有个bug,他们希望执行多轮扫描时,长度较长的字符串先执行:
    

clipboard15

Sort之前:2,5,7

clipboard16

Sort之后:5,2,7 – 错了。

clipboard17

只有显式加上by length才行:SORT lt_search_f by length DESCENDING.

clipboard18

尽量follow ABAP help里定义的guideline来避免类似问题:

clipboard19

本文同步分享在 博客“汪子熙”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

iphone – UIDocumentInteractionController的奇怪问题

iphone – UIDocumentInteractionController的奇怪问题

我不知道这个代码有什么问题,但是每当我运行应用程序时,在菜单显示后,应用程序崩溃.

Nsstring * path = [[NSBundle mainBundle] pathForResource:@"tung" ofType:@"doc"];

UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];

docController.delegate = self;

//[docController presentPreviewAnimated:YES];

CGRect rect = CGRectMake(0,300,300);
[docController presentOptionsMenuFromrect:rect inView:self.view animated:YES];

错误我得到:

*** Terminating app due to uncaught exception ‘NSGenericException’,
reason: ‘-[UIPopoverController
dealloc] reached while popover is
still visible.’

我现在应该怎么做 ?

解决方法

要通过“一次性”UIDocumentInteractionController预览文档,您应该在interactionControllerWithURL之后保留它,并在UIDocumentInteractionControllerDelegate方法documentInteractionControllerDiddismissOptionsMenu中自动释放该文档.正如刘大卫所说,释放它会崩溃.但自动释放工作.我已经检查了dealloc实际上被调用.

以下代码应该工作:

- (void)previewDocumentWithURL:(NSURL*)url
{
    UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
    preview.delegate = self;
    [preview presentPreviewAnimated:YES];
    [preview retain];
}
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    [controller autorelease];
}
@H_301_39@

iphone – 谁能更清楚地解释CLError(kCLErrorLocationUnknown,kCLErrorDenied,kCLErrorNetwork ……)?

iphone – 谁能更清楚地解释CLError(kCLErrorLocationUnknown,kCLErrorDenied,kCLErrorNetwork ……)?

谁能更清楚地解释CLError?
(kCLErrorLocationUnkNown,kCLErrorDenied,kCLErrorNetwork,kCLErrorheadingFailure,kCLErrorRegionMonitoringDenied,kCLErrorRegionMonitoringFailure,kCLErrorRegionMonitoringSetupDelayed)

解决方法

比 the documentation好吗?

kCLErrorLocationUnkNown

The location manager was unable to obtain a location value right Now.

kCLErrorDenied

Access to the location service was denied by the user.

kCLErrorNetwork

The network was unavailable or a network error occurred.

kCLErrorheadingFailure

The heading Could not be determined.

kCLErrorRegionMonitoringDenied

Access to the region monitoring service was denied by the user.

kCLErrorRegionMonitoringFailure

A registered region cannot be monitored.

kCLErrorRegionMonitoringSetupDelayed

Core Location Could not initialize the region monitoring feature immediately.

我们今天的关于Oracle UNION 和 ORDER BY 的奇怪问题oracle union all order by的分享已经告一段落,感谢您的关注,如果您想了解更多关于Apache Superset 向 ORACLE 传递参数的奇怪问题、Fiori UI上my contact加了Dr. 后搜索不出数据的奇怪问题、iphone – UIDocumentInteractionController的奇怪问题、iphone – 谁能更清楚地解释CLError(kCLErrorLocationUnknown,kCLErrorDenied,kCLErrorNetwork ……)?的相关信息,请在本站查询。

本文标签: