plsqldeveloper

How to create recursive query to get all dates between two dates

主宰稳场 提交于 2020-01-16 05:25:12
问题 I want to get all dates between two dates arrival date and leaving date . I tried that recursive query but it didn't work. ;with dates as ( SELECT GuestID, ArrivalDate as reserveddate from dbo.Guest union all SELECT GuestID, dateadd (day,1,dbo.Guest. ArrivalDate) as reserveddate from dbo.Guest where dateadd (day,1,dbo.Guest. ArrivalDate) <dbo.Guest.leavingate ) SELECT * from dates option (maxrecursion 0) 回答1: You need recursive CTE: DECLARE @arrival_date date = '2016-01-01', @leaving_date

how to concatenate more than two columns in plsql developer? [duplicate]

被刻印的时光 ゝ 提交于 2020-01-09 11:58:52
问题 This question already has answers here : Oracle SQL, concatenate multiple columns + add text (6 answers) Closed 4 years ago . when I run the below query select concat(column1,column2,column3) as concatcolumn from table I get an error " ORA-00909:INVALID NUMBER OF ARGUMENTS " 回答1: Concat only takes two arguments. See: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions026.htm Use the concatenation operator: select column1 || column2 || column3 ... 回答2: select ([column1]+','+

Check if row exist

≯℡__Kan透↙ 提交于 2020-01-06 14:54:46
问题 The following PL/SQL code behaves differently if the WHERE looks like this: WHERE USERNAME = 'aaaaaa' and differently if looks like this: WHERE USERNAME = userName Why is the result not the same if userName := 'aaaaaa' ? What am I doing wrong? Thank you! declare isFound NUMBER; userName VARCHAR2(30); begin isFound := 0; userName := 'aaaaaa'; SELECT COUNT(*) INTO isFound FROM MyTable WHERE USERNAME = 'aaaaaa' -- userName AND ROWNUM = 1; IF isFound > 0 THEN dbms_output.put_line('Found'); ELSE

generate xml file from oracle table

混江龙づ霸主 提交于 2020-01-06 08:32:53
问题 when I ran below store procedure then it shows error. here some special char related issue ,so i cant generate xml file , here xml format same as generate XML from oracle tables Connecting to the database DB_old. ORA-29285: file write error ORA-06512: at "SYS.UTL_FILE", line 148 ORA-06512: at "SYS.UTL_FILE", line 889 ORA-06512: at "DBO_17FEB.EXPOR1", line 60 ORA-06512: at line 6 Process exited. Disconnecting from the database DB_old. ------------------- create or replace PROCEDURE Expor1 ( V

generate xml file from oracle table

会有一股神秘感。 提交于 2020-01-06 08:30:33
问题 when I ran below store procedure then it shows error. here some special char related issue ,so i cant generate xml file , here xml format same as generate XML from oracle tables Connecting to the database DB_old. ORA-29285: file write error ORA-06512: at "SYS.UTL_FILE", line 148 ORA-06512: at "SYS.UTL_FILE", line 889 ORA-06512: at "DBO_17FEB.EXPOR1", line 60 ORA-06512: at line 6 Process exited. Disconnecting from the database DB_old. ------------------- create or replace PROCEDURE Expor1 ( V

Updating a big table in oracle without drooping the base table

对着背影说爱祢 提交于 2020-01-06 06:54:37
问题 I am trying to update a table in sql query. My table contains half a million records and it is taking around 10 minutes of time. It is my dev environment. When i will go for UAT or prod, the table there will contain a lot more data than the dev environment. updating the whole table and then putting a commit will consume a lot of memory. Can someone suggest me a good way of updating a table in batches. I have gone through net and the most common solution i found is creating a new table by

PL/SQL Update values using DUP_VAL_ON_INDEX

痞子三分冷 提交于 2020-01-03 05:31:20
问题 DECLARE ins NUMBER := 0; upd NUMBER := 0; CURSOR c1 IS SELECT cid FROM tbl_cust WHERE cid IN ('1','2','3','4'); BEGIN FOR rec IN c1 LOOP INSERT INTO tbl2 (id_tbl2, name_tbl2) VALUES(rec.cid, DECODE(rec.cid, '1', 'A', '2', 'B', '3', 'C', '4', 'D')); ins := ins + 1; END LOOP; dbms_output.put_line('Updated: ' || ins); dbms_output.put_line('Inserted: ' || upd); EXCEPTION WHEN DUP_VAL_ON_INDEX THEN FOR rec IN c1 LOOP UPDATE tbl2 set name_tbl2 = DECODE(rec.cid, '1', 'A', '2', 'B', '3', 'C', '4', 'D

How to convert VARCHAR2 to BLOB inside Oracle 11g PL/SQL after ORA-06502

蓝咒 提交于 2020-01-02 02:18:54
问题 I have a function, that calculates hash value of big string! First of all I wrote a cursor T1_CUT, which can include variable count of SELECT statements, something like: SELECT T1.COL1||T1.COL2||...||T1.COLn FROM T1 WHERE id=documentid SELECT T2.COL1||T2.COL2||...||T2.COLn FROM T2 WHERE id=documentid ... SELECT Tn.COL1||Tn.COL2||...||Tn.COLn FROM Tn WHERE id=documentid Each SELECT can contain one or more rows. So, I concat ALL values in rows in each SELECT and ALL SELECTs values in one big

Invoking a function call in a string in an Oracle Procedure

家住魔仙堡 提交于 2020-01-01 19:00:11
问题 I writing an application using Oracle 10g. I am currently facing this problem. I take in "filename" as parameter of type varchar2. A sample value that filename may contain is: 'TEST || to_char(sysdate, 'DDD')'. In the procedure, I want to get the value of this file name as in TEST147. When i write: select filename into ffilename from dual; I get the value ffilename = TEST || to_char(sysdate, 'DDD') whick makes sense. But how can I get around this issue and invoke the function in the string

update using for loop in plsql

末鹿安然 提交于 2019-12-30 18:52:50
问题 i'm having problem updating and insert into below column. Please advise on this. This is the input depnto extra comm ---------------------------- 20 300 NULL 20 300 400 20 NULL NULL 20 500 NULL This is the expected output depnto Extra comm --------------------- 20 300 300 20 300 400 20 NULL NULL 20 500 500 I need to update comm column with extra column on below conditions. If comm Is null then extra value is updated to comm. If comm Is not null, no need to update, If both are null, leave as