- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有这样的调用
some_proc(sysdate, sysdate);
select some_func(sysdate, sysdate) from dual
我想知道两个 sysdate 调用是否有可能给出不同的值? sysdate 是否仅因执行速度而改变?
最佳答案
some_proc(sysdate, sysdate);
- 在 PL/SQL 语句中使用时 sysdate 并不总是相同
select some_func(sysdate, sysdate) from dual;
- 在 SQL 语句中使用时 sysdate 将始终相同(即使该 SQL 语句正在调用 PL/SQL)
来自Statement-Level Read Consistency概念指南部分:“Oracle 始终强制语句级读取一致性。这保证单个查询返回的所有数据都来自单个时间点 - 查询开始的时间。”
该页面暗示纯 PL/SQL 函数并非如此。
我们可以通过创建接受许多时间戳参数的大型函数(SQL 上下文)和过程(PL/SQL 上下文)来演示这一点,然后比较输入参数是否存在差异。我使用时间戳而不是日期,因为它们在一致性方面应该以相同的方式工作,但时间戳(9)的更改可能性比日期高十亿倍。 (粗略地说 - 可能有很多我不知道的舍入和内部时钟细节,这使得这变得更加复杂。)
--First, use functions like these to create long strings of variables.
--PL/SQL can go to 64K parameters, but luckily differences appear much sooner.
--Parameters for function and procedure
select listagg('a'||level||' timestamp', ',') within group(order by level)
from dual connect by level <= 100 order by level;
--Columns for least/greatest
select listagg('a'||level, ',') within group(order by level)
from dual connect by level <= 100;
--Systimestamps for select/exec
select listagg('systimestamp',',') within group(order by 1)
from dual connect by level <= 100;
--FUNCTION - SQL context
create or replace function function_test(
a1 timestamp,a2 timestamp,a3 timestamp,a4 timestamp,a5 timestamp,a6 timestamp,a7 timestamp,a8 timestamp,a9 timestamp,a10 timestamp,a11 timestamp,a12 timestamp,a13 timestamp,a14 timestamp,a15 timestamp,a16 timestamp,a17 timestamp,a18 timestamp,a19 timestamp,a20 timestamp,a21 timestamp,a22 timestamp,a23 timestamp,a24 timestamp,a25 timestamp,a26 timestamp,a27 timestamp,a28 timestamp,a29 timestamp,a30 timestamp,a31 timestamp,a32 timestamp,a33 timestamp,a34 timestamp,a35 timestamp,a36 timestamp,a37 timestamp,a38 timestamp,a39 timestamp,a40 timestamp,a41 timestamp,a42 timestamp,a43 timestamp,a44 timestamp,a45 timestamp,a46 timestamp,a47 timestamp,a48 timestamp,a49 timestamp,a50 timestamp,a51 timestamp,a52 timestamp,a53 timestamp,a54 timestamp,a55 timestamp,a56 timestamp,a57 timestamp,a58 timestamp,a59 timestamp,a60 timestamp,a61 timestamp,a62 timestamp,a63 timestamp,a64 timestamp,a65 timestamp,a66 timestamp,a67 timestamp,a68 timestamp,a69 timestamp,a70 timestamp,a71 timestamp,a72 timestamp,a73 timestamp,a74 timestamp,a75 timestamp,a76 timestamp,a77 timestamp,a78 timestamp,a79 timestamp,a80 timestamp,a81 timestamp,a82 timestamp,a83 timestamp,a84 timestamp,a85 timestamp,a86 timestamp,a87 timestamp,a88 timestamp,a89 timestamp,a90 timestamp,a91 timestamp,a92 timestamp,a93 timestamp,a94 timestamp,a95 timestamp,a96 timestamp,a97 timestamp,a98 timestamp,a99 timestamp,a100 timestamp
) return varchar2 is
v_min timestamp(9);
v_max timestamp(9);
begin
v_min := least(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71,a72,a73,a74,a75,a76,a77,a78,a79,a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,a90,a91,a92,a93,a94,a95,a96,a97,a98,a99,a100
);
v_max := greatest(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71,a72,a73,a74,a75,a76,a77,a78,a79,a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,a90,a91,a92,a93,a94,a95,a96,a97,a98,a99,a100
);
if v_min <> v_max then
return 'different';
else
return 'the same';
end if;
end;
/
--No matter how many times you run this, you'll always get "the same".
select function_test(systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp)
from dual;
--PROCEDURE - PL/SQL context
set serveroutput on;
create or replace procedure procedure_test(
a1 timestamp,a2 timestamp,a3 timestamp,a4 timestamp,a5 timestamp,a6 timestamp,a7 timestamp,a8 timestamp,a9 timestamp,a10 timestamp,a11 timestamp,a12 timestamp,a13 timestamp,a14 timestamp,a15 timestamp,a16 timestamp,a17 timestamp,a18 timestamp,a19 timestamp,a20 timestamp,a21 timestamp,a22 timestamp,a23 timestamp,a24 timestamp,a25 timestamp,a26 timestamp,a27 timestamp,a28 timestamp,a29 timestamp,a30 timestamp,a31 timestamp,a32 timestamp,a33 timestamp,a34 timestamp,a35 timestamp,a36 timestamp,a37 timestamp,a38 timestamp,a39 timestamp,a40 timestamp,a41 timestamp,a42 timestamp,a43 timestamp,a44 timestamp,a45 timestamp,a46 timestamp,a47 timestamp,a48 timestamp,a49 timestamp,a50 timestamp,a51 timestamp,a52 timestamp,a53 timestamp,a54 timestamp,a55 timestamp,a56 timestamp,a57 timestamp,a58 timestamp,a59 timestamp,a60 timestamp,a61 timestamp,a62 timestamp,a63 timestamp,a64 timestamp,a65 timestamp,a66 timestamp,a67 timestamp,a68 timestamp,a69 timestamp,a70 timestamp,a71 timestamp,a72 timestamp,a73 timestamp,a74 timestamp,a75 timestamp,a76 timestamp,a77 timestamp,a78 timestamp,a79 timestamp,a80 timestamp,a81 timestamp,a82 timestamp,a83 timestamp,a84 timestamp,a85 timestamp,a86 timestamp,a87 timestamp,a88 timestamp,a89 timestamp,a90 timestamp,a91 timestamp,a92 timestamp,a93 timestamp,a94 timestamp,a95 timestamp,a96 timestamp,a97 timestamp,a98 timestamp,a99 timestamp,a100 timestamp
) is
v_min timestamp(9);
v_max timestamp(9);
begin
v_min := least(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71,a72,a73,a74,a75,a76,a77,a78,a79,a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,a90,a91,a92,a93,a94,a95,a96,a97,a98,a99,a100
);
v_max := greatest(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71,a72,a73,a74,a75,a76,a77,a78,a79,a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,a90,a91,a92,a93,a94,a95,a96,a97,a98,a99,a100
);
if v_min <> v_max then
dbms_output.put_line('different');
else
dbms_output.put_line('the same');
end if;
end;
/
--I see "different" about 50% of the time.
--The ratio of differences decreases as you decrease the number of parameters.
exec procedure_test(systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp,systimestamp);
关于oracle - 系统日期差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7954509/
我从NVIDIA手册Eg中复制了以下代码:__threadfence()。他们为什么有 在以下代码中使用了__threadfence()。我认为使用__syncthreads()而不是__thread
我在使用 SVN 更改列表和 svn diff 时遇到了一些麻烦.特别是我想获取特定修订范围的特定文件列表的更改历史记录。 SVN 变更列表似乎是完美的解决方案,所以我的方法是: svn change
我有两个 IP 地址列表。我需要将它们合并到三个文件中,交集,仅来自 list1 的文件和仅来自 list2 的文件。 我可以用 awk/diff 或任何其他简单的 unix 命令来做到这一点吗?如何
假设自上次更新(恢复)到我的 a.b 文件以来我做了一些更改。 此 a.b 文件也在存储库中更改。 现在我想将我所做的更改与 repos 更改进行比较。 如果我 svn revert 文件,我可以看到
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我使用的是 openssl 1.0.1c , linux x86_64 我正在创建包含“hello”的文件(没有换行符) openssl dgst -sha256 hello_file i get :
假设我们有几个库。 有什么区别核心和 普通 图书馆?他们应该如何被认可,我们是否组织了两者的职责? +Common -Class1 +Core -Class2 +Lib1 has : Comm
如何在 SQLite 中计算以毫秒为单位的最小时间间隔? 好的,提供一些背景信息, 这是我的 table 的样子: link_budget table 所以有这个时间列,我想发出一个请求,以毫秒为单位
我想知道,乐观并发控制 (OCC) 和多版本并发控制 (MVCC) 之间的区别是什么? 到目前为止,我知道两者都是基于更新的版本检查。 在 OCC 中,我读到了没有获取读取访问锁的事务,仅适用于以后的
说到 SignalR,我有点菜鸟。刚刚开始四处探索和谷歌搜索它,我想知道是否有人可以向我解释完成的事情之间的一些差异。 在我见过的一些示例中,人们需要创建一个 Startup 类并定义 app.Map
我在 Ogre 工作,但这是一个一般的四元数问题。 我有一个对象,我最初对其应用旋转四元数 Q1。后来,我想让它看起来好像我最初通过不同的四元数 Q2 旋转了对象。 我如何计算四元数,该四元数将采用已
我了解 javascript 模块模式,但我使用两种类型的模块模式,并且想从架构 Angular 了解它们之间的区别。 // PATTERN ONE var module = (function()
我有两个具有完全相同键的 JSON。 val json1 = """{ 'name': 'Henry', 'age' : 26, 'activities' : {
我发现使用 VBA 在 Excel 中复制单个文件有两种不同的方法。一是文件复制: FileCopy (originalPath), (pathToCopyTo) 另一个是名称: Name (orig
我想知道查找两个 float 组之间差异的绝对值的最有效方法是什么? 是否是以下内容: private float absDifference(float[] vector1, float[] vec
我有一个关于 wicket getApplication 的问题。 getApplication() 和 getSession().getApplication 有什么区别? 部署 wicket 应用
我刚刚开始使用activemq,我有一个关于追溯消费者的问题,为了启用这个功能,你需要有一个持久的订阅。但是在主题上启用和不启用追溯的持久订阅有什么区别? activemq 文档说。 http://a
我有两个具有完全相同键的 JSON。 val json1 = """{ 'name': 'Henry', 'age' : 26, 'activities' : {
得到另一个 Erlang 二进制表示查询('因为这就是我最近正在阅读的内容,并且需要二进制协议(protocol)实现)。 如果我正确理解了类型说明符,那么对于“浮点”类型值,8 字节表示似乎很好(这
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
我是一名优秀的程序员,十分优秀!