nvl

COALESCE in JPA namedQuery

杀马特。学长 韩版系。学妹 提交于 2019-11-29 10:02:57
I have the following namedQuery select new test.entity.Emp(COALESCE(k.projectId,'N') as projectId, k.projectName) from Emp o inner join o.projects k However I am getting error expecting RIGHT_ROUND_BRACKET, found '(' How to handle COALESCE in namedQuery? Are there any other ways to handle null values in JPA? gknicker Coalesce is supported by JPA 2.0 API . The new construct is proprietary to Hibernate, not necessarily supported in all JPA implementations. First try the query without also trying to construct an object: select COALESCE(k.projectId,'N') as projectId, k.projectName from Emp o inner

加了日期条件后查询结果慢了100倍

☆樱花仙子☆ 提交于 2019-11-28 19:28:08
--下面这句秒出,不加use_hash也是秒出。 select /*+use_hash(i j d)*/ count(distinct i.F3070220000101_000048002) 户,count(1) 人 from T3070220000101_000048_V1 i , T3070220000101_000042_V1 j ,dim_area_5lvl d where i.F3070220000101_000048002=j.F3070220000101_000042003 and i.F3070220000101_000048036='否' and j.F3070220000101_000042040='否' and nvl(j.F3070220000101_000042036,'正常')<>'减少' and nvl(i.F3070220000101_000048029,'没有变动')='没有变动' and substr(i.F3070220000101_000048005,1,12)=d.country_id and d.city_name_s='清远市'; --下面这句过了很久很久才有结果,不在为啥,ij表只有一个时间片的记录. select /*+use_hash(i j d)*/ count(distinct i.F3070220000101

Why does NVL always evaluate 2nd parameter

心已入冬 提交于 2019-11-28 13:29:39
Does anyone know, why Oracle's NVL (and NVL2 ) function always evaluate the second parameter, even if the first parameter is not NULL ? Simple test: CREATE FUNCTION nvl_test RETURN NUMBER AS BEGIN dbms_output.put_line('Called'); RETURN 1; END nvl_test; SELECT NVL( 0, nvl_test ) FROM dual returns 0 , but also prints Called . nvl_test has been called, even though the result is ignored since first parameter is not NULL . It's always been that way, so Oracle has to keep it that way to remain backwards compatible. Use COALESCE instead to get the short-circuit behaviour. Here is a post where Tom

PSR Report解读--AWR report

十年热恋 提交于 2019-11-28 05:27:59
AWR 是通过对比两次快照(snapshot)收集到的统计信息,来生成报表数据,生成的报表包括多个部分。 1 数据库基本信息 DB Name DB Id Instance Inst num Release RAC Host ICCI 1314098396 ICCI1 1 10.2.0.3.0 YES HPGICCI1 2 两次snapshot的基本信息 Snap Id Snap Time Sessions Cursors/Session Begin Snap: 2678 25-Dec-08 14:04:50 24 1.5 End Snap: 2680 25-Dec-08 15:23:37 26 1.5 Elapsed: 78.79 (mins) DB Time: 11.05 (mins) DB时间包括cpu在数据处理和等待(非空闲等待)所花的时间。对于批量系统,数据库的工作负载总是集中在一段时间内。如果快照周期不在这一段时间内,或者快照周期跨度太长而包含了大量的数据库空闲时间,所得出的分析结果是没有意义的.这也说明选择分析时间段很关键,要选择能够代表性能问题的时间段。 3 Cache信息 Begin End Buffer Cache: 3,344M 3,344M Std Block Size: 8K Shared Pool Size: 704M 704M Log Buffer:

sybase数据库统计记录

六眼飞鱼酱① 提交于 2019-11-28 05:05:40
概述 网上关于sybase数据库的资料很少,很多功能可能都不如oracle等其他数据库,最近在做一个涉及统计的需求,对于我这种数据库菜鸟来说,当接触到新的东西最好的方法就是记录下来,方便下次使用或者翻阅。 需求 需求单就不奉上了,主要就是统计用户测速成功率的一个统计报表,包含测速的属地,不达标的数量,达标的数量,总计以及成功率,其中同一个用户取测速结果最好的一次,测速速率的计算方式按设备的上行方式来定。 执行sql //大概思路如下,其中....是需要关联的表或者加的where条件 select sum(case when (nvl(a.rate,0)>=0.9*TO_NUMBER(a.speed)) then 1 else 0 end) reached, sum(case when (nvl(a.rate,0)<0.9*TO_NUMBER(a.speed)) then 1 else 0 end) noReached from (select round(nvl(avg,0)*8/1024,2) rate,usernm,speed from (select row_number() over(partition by usernm order by avg desc ) rn , bb.usernm,bb.speed from xxxxx bb where bb.wanType=

COALESCE in JPA namedQuery

大兔子大兔子 提交于 2019-11-28 03:29:26
问题 I have the following namedQuery select new test.entity.Emp(COALESCE(k.projectId,'N') as projectId, k.projectName) from Emp o inner join o.projects k However I am getting error expecting RIGHT_ROUND_BRACKET, found '(' How to handle COALESCE in namedQuery? Are there any other ways to handle null values in JPA? 回答1: Coalesce is supported by JPA 2.0 API. The new construct is proprietary to Hibernate, not necessarily supported in all JPA implementations. First try the query without also trying to

ETL 开发笔记

橙三吉。 提交于 2019-11-27 08:31:13
一、Oracle的NVL函数用法【从两个表达式返回一个非 null 值。】? 语法【NVL(eExpression1, eExpression2)】 参数【eExpression1, eExpression2】 如果 eExpression1 的计算结果为 null 值,则 NVL( ) 返回 eExpression2。如果 eExpression1 的计算结果不是 null 值,则返回 eExpression1。eExpression1 和 eExpression2 可以是任意一种数据类型。如果 eExpression1 与 eExpression2 的结果皆为 null 值,则 NVL( ) 返回 .NULL.。 返回值类型【字符型、日期型、日期时间型、数值型、货币型、逻辑型或 null 值】 在不支持 null 值或 null 值无关紧要的情况下,可以使用 NVL( ) 来移去计算或操作中的 null 值。 【select nvl(a.name,'空得') as name from student a join school b on a.ID=b.ID】 注意:两个参数得类型要匹配 例如: SELECT T.D_FDATE, T.VC_ZHCODE, NVL(SUM(T.F_FZQSZ), 0) f_price_b, NVL(SUM(T.F_FZQCB), 0) f

Why does NVL always evaluate 2nd parameter

别来无恙 提交于 2019-11-27 07:44:01
问题 Does anyone know, why Oracle's NVL (and NVL2 ) function always evaluate the second parameter, even if the first parameter is not NULL ? Simple test: CREATE FUNCTION nvl_test RETURN NUMBER AS BEGIN dbms_output.put_line('Called'); RETURN 1; END nvl_test; SELECT NVL( 0, nvl_test ) FROM dual returns 0 , but also prints Called . nvl_test has been called, even though the result is ignored since first parameter is not NULL . 回答1: It's always been that way, so Oracle has to keep it that way to remain

PLSQL复习笔记2014/2/16

放肆的年华 提交于 2019-11-26 21:22:05
复习笔记 Day01 一、数据库环境及历史 1、历史 文件管理系统 网状数据库管理系统 关系型数据库 nosql 2、常用数据库 sqlserver(ms) :办公室级别或部门级别的数据 mysql:中小型数据库;开源 oracle db2 sysbase: 二、数据库设计基础 1、设计和建模的必要性 节约存储空间 数据完整性 方便开发 2、操作流程 收集信息 对象识别 数据模型 信息类型 关系 3、建模 a 三种模式 b 设计模型 e-r图 4、规范化 关系型数据库的特点:数据以表格的形式呈现 范式 三、oracle的使用 环境: 本地使用sqlplus 1、sqlplus概念 作用:用于管理oracle数据库,默认形式为指令 2、登录 (scott/tiger 使用案例) sqlplus scott/tiger 这个账户在安装时没有解锁,那么不能登录 3、解锁账户 以管理员的身份登录(本机) sqlplus / as sysdba 解锁指令 alter user scott account unlock; 4、查看身份 show user; 5、切换账户 conn 账户名/密码 6、查看当前用户所有表 select table_name from user_tables; emp:员工表 dept:部门表 查看表结构 desc 表名 7、查看当前实例(管理员) select

oracle nvl nvl2 decode

[亡魂溺海] 提交于 2019-11-26 13:00:53
---------------------------------------------------------------------------------- NVL(E1, E2) 如果 E1 为 null , 返回 E2。 如果 E1 不是 null ,则返回 E1。 如果 E1 与 E2 都为 null ,返回 .NULL.。 E1 和 E2 可以是任意一种数据类型。 ---------------------------------------------------------------------------------- NVL2(E1, E2, E3) 如果E1为NULL,则函数返回E3,若E1不为null,则返回E2。 ---------------------------------------------------------------------------------- decode 的几种用法 1.使用decode判断字符串是否一样 DECODE(value,if 条件1,then 值1,if 条件2,then 值2,...,else 其他值) Sql测试: select aac001,decode(aac001,'0000000001','林海燕','0000000002','陈德财','others') as name from ac01