首页 \ 问答 \ 精确控制SQL排序顺序(Fine control over SQL Sort Order)

精确控制SQL排序顺序(Fine control over SQL Sort Order)

我有一个SQL查询由一个查询按照某个数值的升序对其进行排序。 但是用户需要两行特定的数据,它们恰好出现在查询结果的不同顺序位置,并列。 有没有办法做到这一点,无论是通过报告的驱动SQL还是.rdl文件本身?


I have a SQL Report driven by a query that sorts it in ascending order of some numerical value. But the user wants two particular rows of data, which happen to appear at different ordinal positions in the query results, to be juxtaposed. Is there a way to do this, either through the report's driving SQL or the .rdl file itself?


原文:https://stackoverflow.com/questions/1929373
更新时间:2022-03-11 21:03

最满意答案

PhantomJS的page.open()是一个异步函数。 最早在完全传输和解析对页面请求的响应时调用其回调。 在调用回调时没有明确定义,但根据经验我会说,一旦所有直接资源也被加载(不是异步资源),它总会被调用。

这意味着在页面上触发DOMContentLoaded事件后很长时间调用回调。 这反过来意味着如果你在激活后注册到DOMContentLoaded,你的事件处理程序将永远不会触发。

现在它看起来像这样:

page.evaluate(function(){
    var links = document.querySelectorAll('a.link');
    Array.prototype.forEach.call(links, function(e){ 
        e.click();
    });
});

问题是element.click()在大多数页面上都不起作用。 PhantomJS的问题; 点击一个元素有多种解决方案来应对这种困境。 你这样做:

page.evaluate(function(){
    var links = document.querySelectorAll('a.link');
    Array.prototype.forEach.call(links, function(e){
        var ev = document.createEvent('MouseEvents');
        ev.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, 
                false, false, false, false, 0, null);
        e.dispatchEvent(ev);
    });
});

PhantomJS's page.open() is an asynchronous function. Its callback is called at the earliest when the response to the page request was fully transmitted and parsed. It's not clearly defined when exactly the callback is called, but from experience I would say it is always called as soon as all immediate resources are also loaded (not async resources).

This means that the callback is called long after the DOMContentLoaded event was triggered on the page. Which in turn means that if you register to the DOMContentLoaded after it was fired, your event handler will never fire.

Now it looks like this:

page.evaluate(function(){
    var links = document.querySelectorAll('a.link');
    Array.prototype.forEach.call(links, function(e){ 
        e.click();
    });
});

The problem is that element.click() doesn't work on most pages. The question PhantomJS; click an element has multiple solutions for this predicament. You do it like this:

page.evaluate(function(){
    var links = document.querySelectorAll('a.link');
    Array.prototype.forEach.call(links, function(e){
        var ev = document.createEvent('MouseEvents');
        ev.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, 
                false, false, false, false, 0, null);
        e.dispatchEvent(ev);
    });
});

相关问答

更多
  • 简洁版本: 你正在进入欠规范的行为领域。 我建议你使用load事件来触发转换。 长版本: 当元素的CSS属性的计算值发生变化( 规格 )时,会触发CSS转换,因此在样式系统首次计算文档样式之前无法触发CSS转换。 样式系统应该在加载相关样式表之后对文档进行初始样式传递(即第一次计算出计算值),否则在样式表加载完成后必须重新进行工作。 另一方面, DOMContentLoaded的想法是在解析HTML源代码后立即触发 - 不必等待任何其他资源(包括样式表)完成加载,因此在计算任何样式之前它自然会触发 。 浏览 ...
  • 我声称事件类型“DOMContentReady”在当前实现中不存在(意思是没有当前的实现触发这种事件类型),并且这样的名称的外观仅仅是lapsus memoriae 。 名称“DOMContentLoaded”不容易被记住,并且由于jQuery库使用.ready()方法来绑定这个事件类型,我猜有些人错误地使用名称“DOMContentReady”来引用正确的名称“DOMContentLoaded” 。 I'm making the claim that the event type "DOMContentR ...
  • 我不知道我是否会认为这是“正常”,但外部应用程序影响插件操作的可能性是无穷无尽的。 也就是说,我认为无论AVG如何导致这种异化,像你所说的那样,聪明的事情就是在插入之前检查列是否存在,因为AVG可能不是影响Firefox事件触发器的唯一外部应用程序。 我非常厌倦了DOM驱动的事件,因为在我自己的插件中,并且在整个开发过程中对它进行的测试显示了许多基于很多变量的异常(不同的操作系统,FF的不同版本,主机上的不同应用程序,任何给定的用户FF等)。 总结: AVG中的错误? 也许。 您的插件性能受到许多其他来源的 ...
  • 检索从初始html页面引用的所有文件时,会发生load和DOMContentLoaded事件。 在DOMContentLoaded的情况下,事件发生在页面的初始DOM完全加载时。 从初始html文档加载的文件将相对于时间轴上的该文档显示。 一旦JavaScript开始执行,通常通过XmlHttpRequests到源服务器或另一个服务器,就会发生额外的网络流量。 将鼠标悬停在这些请求上时,这些请求不会显示进度事件(已加载,DOMContentLoaded)。 因为这些请求可以基于Web应用程序中发生的事件而被 ...
  • 您可以从evaluate回调中return 。 我想你想要的 function(user, pass, debug){ // step 3 submit Login reloadAfterLogin = page.evaluate(function(user, pass, debug){ if($("form").attr("action").indexOf("login.do") > 0){ $('form').submit(); return true; } ...
  • PhantomJS的page.open()是一个异步函数。 最早在完全传输和解析对页面请求的响应时调用其回调。 在调用回调时没有明确定义,但根据经验我会说,一旦所有直接资源也被加载(不是异步资源),它总会被调用。 这意味着在页面上触发DOMContentLoaded事件后很长时间调用回调。 这反过来意味着如果你在激活后注册到DOMContentLoaded,你的事件处理程序将永远不会触发。 现在它看起来像这样: page.evaluate(function(){ var links = docume ...
  • 我弄清楚导致问题的原因。 该页面使用的是Telerik Ajax TreeView控件,它具有非常复杂的节点结构。 树在FF中呈现得非常快,但在Chrome中却非常慢。 我删除它后,Chrome也会快速呈现页面。 因此,我将使用不同的控件重新设计页面,从而在不同的浏览器中提供一致的性能 I figured out what was causing the problem. The page was using Telerik Ajax TreeView control, which had a very c ...
  • 当HTML解析器遇到任何脚本元素时,它假定document.write可能存在于脚本中并阻止HTML加载。 这就是为什么建议在页面底部加载所有脚本以确保快速加载页面的原因。 通过语句, Angular initializes automatically upon DOMContentLoaded event ,这意味着一旦DOM准备好,角度就会引导应用程序。 When the HTML parser comes across any script elements, It assumes that docu ...
  • 那些萤火虫的统计信息告诉你: 从您开始请求服务器端代码开始返回响应开始,需要2.1秒 然后下载响应需要19ms(即HTML) 71ms左右之后,DOMContentLoaded事件触发 页面完全加载后(图像全部下载完毕后),将触发加载事件。 一旦DOM准备好,DOMContentLoaded就会触发。 加载事件等待,直到加载整个页面(包括任何外部资源,如图像) 您的请求中的大部分时间(除了下载图像)都花在等待服务器构建HTML上。 也许你的服务器端代码可以优化运行得更快? Those firebug sta ...
  • PhantomJS支持const关键字,其行为与var相同。 这意味着您可以重新分配声明为const变量。 以下代码在PhantomJS 1.9.7和2.0.0中按原样运行。 phantomscript.js var page = require("webpage").create(); page.open("http://example.com",function(status){ if (page.injectJs('inc.js')) { console.log("out: ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。