Oracle

Retrieving the data from the table using the PL/SQL

孤者浪人 提交于 2021-02-05 11:37:19
问题 I want to retrieve all the information about each department from the DEPARTMENT table and display the information on the screen. Column name Data type Constraints DEPARTMENT_ID NUMBER(5) PK DEPARTMENT_NAME VARCHAR2(25) NOT NULL LOCATION_ID VARCHAR2(15) Sample Output: Department Details are : 1000, ADMIN, HQ-101 1010, DEVELOPMENT, CBE-103 1020, TESTING, CHN-102 I have a code which is as follows- set serveroutput on; declare v_dno department.department_id%type; v_dname department.department

Oracle - deleting duplicates

风格不统一 提交于 2021-02-05 11:36:23
问题 I have found the following way for removing duplicates: DELETE FROM table_name A WHERE a.rowid > ANY ( SELECT B.rowid FROM table_name B WHERE A.col1 = B.col1 AND A.col2 = B.col2 ); Could someone explain me step by step how does the query works? TIA! 回答1: In Oracle, ROWID is a pseudo column points to the physical location of a row. The query does a self join and fetches those rows which have the same value of column 1 & column 2 - with the assumption that these keys are enough to identify as

How to group by month including all months?

一世执手 提交于 2021-02-05 11:28:46
问题 I group my table by months SELECT TO_CHAR (created, 'YYYY-MM') AS operation, COUNT (id) FROM user_info WHERE created IS NOT NULL GROUP BY ROLLUP (TO_CHAR (created, 'YYYY-MM')) 2015-04 1 2015-06 10 2015-08 22 2015-09 8 2015-10 13 2015-12 5 2016-01 25 2016-02 37 2016-03 24 2016-04 1 2016-05 1 2016-06 2 2016-08 2 2016-09 7 2016-10 103 2016-11 5 2016-12 2 2017-04 14 2017-05 2 284 But the records don't cover all the months. I would like the output to include all the months, with the missing ones

How to retrieve host, port, sid, user and password informations in java.sql.Connection

↘锁芯ラ 提交于 2021-02-05 11:26:07
问题 I have an Oracle connection (in a java.sql.Connection object) that is mounted from a properties file (ApplicationResources.properties). How do I capture information about host, port, sid, user and password? (I need this information to call a specific database function through my java application) Below my code: private void conectaBanco() { ServiceLocator sl = new ServiceLocator(); InitialContext ic = null; DataSource dataSource = null; try { if (conn == null) { ic = new InitialContext();

Selecting Distinct field and row num just to display an id number gives duplicated data

别来无恙 提交于 2021-02-05 11:23:29
问题 I have a table application and it has 10 columns. category is one column and this column has duplicated values. To get distinct values I have a query SELECT distinct(CATEGORY) as CategoryName FROM APPLICATION where applicationId=? . I am getting result without any issue. Here now I wanted to add a another column as categoryId. There is no such field, I have to generate one. I tried with below query. SELECT distinct(CATEGORY) as CategoryName , rownum as categoryId FROM APPLICATION where

Oracle RESET_PACKAGE does not reset value of a variable in the session

邮差的信 提交于 2021-02-05 09:42:42
问题 I have an app where JDBC connections are pooled. This is related to my question. For simplicity let's assume I have 1 connection and I need to set a variable then reset session / context state. However the idea is not reverse / reset the 'app1_ctx' variable particularly as in the actual case users can enter many procedures that set many variables so what I need is one procedure that clears all session related variables or even restart session. (please check this question too to understand the

REgex to get numeric from string in oracle

梦想与她 提交于 2021-02-05 09:33:28
问题 I have strings in the following formats Akram_88_jamesstree_20140418, Akram_8_johnstreet_20140418, Akram_888_johnstreet_20140418, Now I want to retrieve only the 88,8 and 888 value only, for which i have written the following query SUBSTR(a.file_name, 7, INSTR(a.file_name, '_')-5) as output now the problem with this query is i just get 88 -8 and 88 of 888. The output will be compared to another column so i want just 88,8 and 888 numeric values. 回答1: SELECT REGEXP_SUBSTR('Akram_88_jamesstree',

Smartbi报表工具的学习笔记,如何学好报表分析?

一个人想着一个人 提交于 2021-02-05 09:27:10
近期,因为工作需要,学习了一个报表工具Smartbi,这是国产BI软件,其功能还是挺强大的,并且学习成本很低,容易上手。 其实在学习Smartbi之前,我还学习了一段时间的微软BI工具sqlserver report service(简称***S),怎么说呢,这个工具界面不好看,另外感觉功能不全。 当我接触smartbi后,感觉豁然开朗,整个人都为之振奋,因为可以实现我想要的各种需求了。 Smartbi里面后有很多种分析,如组合分析、透视分析、多维分析等等,我感觉这些分析可以不用学,直接学习其中的电子表格分析即可,因为电子表格分析涵盖了几乎上面所有分析的功能。 另外还要提到的是,Smartbi的个人版功能是不限的,只限制并发用户数,这对于中小企业来说,可以免费使用它。当然,如果你是成规模的大用户,可以购买企业版的。 下面跟大家说说我使用Smartbi的全过程,一来可以为自己前期使用不熟悉做个步骤记录;二来相信也有很多用户跟我一样,没办法做到过目不忘,帮大家记录一下使用Smartbi使用的全过程。 一、Smartbi软件下载地址 想要使用Smartbi的用户可以到官网下载软件。 当然使用产品肯定需要有在线文档帮助,Smartbi的在线文档可以在官网的导航栏找到。 二、安装smartbi EXE安装包安装:直接运行EXE安装包即可。 软件包安装:参考Linux系统软件包部署流程。 三

2021年的十五个DevOps趋势预测

白昼怎懂夜的黑 提交于 2021-02-05 09:21:09
DevOps已经走过了很长的一段路,毫无疑问,它将在今年继续闪耀。由于许多公司都在寻找围绕其数字化转型的最佳实践,因此了解领导者认为该行业的发展方向非常重要。从这个意义上说,下面的文章收集了DevOps高层对2021年DevOps趋势的回应。 让我们看看他们每一个人在未来一年对DevOps有什么看法。 1.迁移到微服务成为必选项。 “从单一服务到微服务和容器架构的转变对所有公司的数字化转型都是必须的。它不再是一个或多个选择。Kubernetes的应用将会越来越多,当组织采用多云时,Terraform将会是自动化基础设施的最终选择。”——威普罗DevOps首席工程师Sachidananda Pattnaik 2.混合模式将成为部署规范。 “2020年加速了远程工作,加快了向云的迁移,并将DevOps从最佳实践转变为每个业务的重要组成部分。随着我们进入2021年,该行业将在多个方面采用混合动力。首先,企业将充分采用混合劳动力,将远程工作和现场团队协作的优势结合起来。第二,商业模式将变得混合,例如将虚拟规模与本地网络相结合的会议。最后,混合动力将成为部署标准,因为公司将其堆栈现代化,以利用云本地技术,但意识到并非所有东西都能脱离prem。2021年的赢家将是在其业务、模型和产品中采用混合动力的公司。”—— 杰蛙科技开发者关系VP Stephen Chin 3.DataOps 将繁荣发展。

Concatenate XMLType nodes in Oracle query

放肆的年华 提交于 2021-02-05 09:13:01
问题 I have a CLOB column that contains XML type data. For example XML data is: <A><B>123</b><C>456</C><B>789</b></A> I have tried the concat function: concat(xmltype (a.xml).EXTRACT ('//B/text()').getStringVal (),';')) or xmltype (a.xml).EXTRACT (concat('//B/text()',';').getStringVal ())) But they are giving ";" at end only not after each <B> tag. I am currently using xmltype (a.xml).EXTRACT ('//B/text()').getStringVal () I want to concatenate all <B> with ; and expected result should be 123;789