Oracle

issue with Add_month in oracle , I need to generate billing cycle

主宰稳场 提交于 2021-01-29 06:41:52
问题 I have a requirement to generate to Billing cycle date, ex if My input is 27th March then my next cycle starts from 27 april. If input is 10th Jan then next cycle should start from 10th Feb. I am using Oracle Add_Month(i/p Date, 1). This add a new month and give me same date for next month, working fine for above mentioned dates. But there is one corner case when my Input date is 28th Feb, 2018 and If I do select ADD_MONTHS(date '2018-02-28', 1) from dual then output is 31st March,2018. I am

stratified sample on ranges

主宰稳场 提交于 2021-01-29 06:13:06
问题 I have table_1, that has data such as: Range Start Range End Frequency 10 20 90 20 30 68 30 40 314 40 40 191 (here, it means we have just 40 as data point repeating 191 times) table_2: group value 10 56.1 10 88.3 20 53 20 20 30 55 I need to get the stratified sample on the basis of range from table_1, the table_2 can have millions of rows but the result should be restricted to just 10k points. Tried below query: SELECT d.* FROM ( SELECT ROW_NUMBER() OVER( PARTITION BY group ORDER BY group )

How do I re-order data in the same table?

心不动则不痛 提交于 2021-01-29 05:47:44
问题 AS-IS: ID Version 5587138 1 6460704 2 6537612 3 6264608 4 TO-BE: ID Version 5587138 1 6264608 2 6460704 3 6537612 4 I have to re-order the IDs to match the version order. The data is coming from the same table. I am currently trying to use PL/SQL. I really need help on this issue. Thank you. 回答1: You can use the merge statement as follows: merge into your_table trg using (select id, row_number() over (order by id) as version from your_table) src on (trg.id = src.id) when matched then update

Oracle - replace string by appearance

走远了吗. 提交于 2021-01-29 05:37:19
问题 I have an interesting issue here, if you could share your thoughts ... I changed data a bit, but structure is same create table TestReplace (Description varchar2(500), ParamValue1 number, ParamValue2 number, ParamValue3 number); insert into TestReplace (Description) values ('This sentence has no parameteres, and it should be shown like this'); insert into TestReplace (Description, ParamValue1) values ('This sentence has only one parametere, and it should be shown right here {param} with rest

Use dbms_xmldom.writetofile without a Named Directory

不问归期 提交于 2021-01-29 05:30:53
问题 I am trying to write an XML file using PL/SQL using the procedure dbms_xmldom.writetofile . However, the code above only works when I supply a named directory taken from DBA_DIRECTORIES like below: procedure PRINT_XML (p_xml xmltype ,p_requestid number) is l_filename varchar2(100); doc dbms_xmldom.domdocument; l_directory request_history.OUTPUTWORKDIRECTORY%type; l_dml_stmnt request_history.OUTPUTWORKDIRECTORY%type; begin l_filename := 'JPK_Accounting_Books_'||g_jpk_ess_request_id||'.xml';

Sync Oracle Database with SQL Azure

旧城冷巷雨未停 提交于 2021-01-29 04:57:47
问题 I would want to sync up on-premises Oracle database with SQL Azure. Currently I have a DTS package setup for my on-premises applications (both Oracle and SQL Server being on-premise). If I move the SQL Server to Azure, how should this process be designed? 回答1: you have to options for moving to Azure: Move to Azure SQL Database Provision a SQL Server VM in Azure the latter will have the same feature set as your regular on-premise SQL Server. The former is not fully-feature equivalent to SQL

Oracle SQL: How return several distinct columns

与世无争的帅哥 提交于 2021-01-29 04:57:20
问题 I have an Oracle Query that outputs but I wish to output all distinct column except for Incident ID, i.e. I tried adding GROUP BY to Oracle Query but get error, DataSource.Error: Oracle: ORA-00979: not a GROUP BY expression Details: DataSourceKind=Oracle DataSourcePath=dlporacle Message=ORA-00979: not a GROUP BY expression ErrorCode=-2147467259 Below is my Query ... please assist SELECT I.INCIDENTID AS "Incident ID", I.CREATIONDATE AS "Creation Date", MO.IPADDRESS AS "IP Address", MO

Sync Oracle Database with SQL Azure

自作多情 提交于 2021-01-29 04:57:07
问题 I would want to sync up on-premises Oracle database with SQL Azure. Currently I have a DTS package setup for my on-premises applications (both Oracle and SQL Server being on-premise). If I move the SQL Server to Azure, how should this process be designed? 回答1: you have to options for moving to Azure: Move to Azure SQL Database Provision a SQL Server VM in Azure the latter will have the same feature set as your regular on-premise SQL Server. The former is not fully-feature equivalent to SQL

Oracle SQL: How return several distinct columns

血红的双手。 提交于 2021-01-29 04:51:04
问题 I have an Oracle Query that outputs but I wish to output all distinct column except for Incident ID, i.e. I tried adding GROUP BY to Oracle Query but get error, DataSource.Error: Oracle: ORA-00979: not a GROUP BY expression Details: DataSourceKind=Oracle DataSourcePath=dlporacle Message=ORA-00979: not a GROUP BY expression ErrorCode=-2147467259 Below is my Query ... please assist SELECT I.INCIDENTID AS "Incident ID", I.CREATIONDATE AS "Creation Date", MO.IPADDRESS AS "IP Address", MO

Taking table name as input in sql

独自空忆成欢 提交于 2021-01-29 04:37:44
问题 I need to take a table name as input from user to my PL / SQL script and then update that table. I am not sure if this is possible because ORACLE might have problem parsing the script. Please guild me as to how to solve this problem. Thnx. 回答1: Use EXECUTE IMMEDIATE. It allows you to build a SQL statement as a VARCHAR2 string and then execute that statement. eg. lStr := 'UPDATE '||table-name||' SET COLUMN-NAME = VALUE'; EXECUTE IMMEDIATE lStr; COLUMN-NAME and VALUE can also be changed