oracle11g

Mutating Table in Oracle 11 caused by a function

落爺英雄遲暮 提交于 2019-12-17 20:45:34
问题 We've recently upgraded from Oracle 10 to Oracle 11.2. After upgrading, I started seeing a mutating table error caused by a function rather than a trigger (which I've never come across before). It's old code that worked in prior versions of Oracle. Here's a scenario that will cause the error: create table mutate ( x NUMBER, y NUMBER ); insert into mutate (x, y) values (1,2); insert into mutate (x, y) values (3,4); I've created two rows. Now, I'll double my rows by calling this statement:

Grant SELECT on multiple tables oracle

给你一囗甜甜゛ 提交于 2019-12-17 20:05:27
问题 I have 3 tables table1,table2,table3. I want to grant(select for example) these tables to a user, user1. I know that I can grant with: grant select on table1 to user1; grant select on table2 to user1; grant select on table3 to user1; Can I grant the 3 tables to user1 using only 1 query? Thanks 回答1: No. As the documentation shows, you can only grant access to one object at a time. 回答2: You can do it with dynamic query, just run the following script in pl-sql or sqlplus: select 'grant select on

Underscore is not working in oracle like clause

£可爱£侵袭症+ 提交于 2019-12-17 19:33:15
问题 When development, I used 'test_1%' to find 'test_123' in like. But in production environment its not working. Using 'escape '\'' is working. is there any setting needs to set in oracle? I want to use without escape '\''. 回答1: try this in SQL Developer: SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%' escape '\' in sql plus: set escape '\' SELECT * FROM TABLE1 WHERE NAME LIKE 'test\_1%'; 回答2: In Oracle, you can also use ESCAPE like this: SELECT * FROM name_of_table WHERE description LIKE

Oracle pivot with subquery

泪湿孤枕 提交于 2019-12-17 19:28:43
问题 I'm using pivot in Oracle PL SQL Developer as follows: SELECT * FROM population PIVOT (AVG(Total) for Data_Type IN ('Group1','Group2','Group3')) This works fine, but I don't want to have to edit every time a new column is added or one is changed (i.e. Group4, 5, 6 etc), so I tried a sub-query as follows: SELECT * FROM population PIVOT (AVG(Total) for Data_Type IN (SELECT Data_Type FROM population)) This results in the following error: ORA-00936: missing expression. After some research, it

How to connect to Oracle 11g database remotely

岁酱吖の 提交于 2019-12-17 18:49:20
问题 I have Oracle 11g XE installed on computer A. I can connect through the sql command line using the command connect username/password . I also can send SQL instructions to the Demo database: Select * from demo_customers; The database is running on localhost of computer A. I want computer B to connect to computer A's database on localhost. How can I do that? 回答1: You will need to run the lsnrctl utility on server A to start the listener. You would then connect from computer B using the

Insert into from CTE

百般思念 提交于 2019-12-17 18:37:56
问题 WITH DTL AS (SELECT CMPI_CODE, CMN_CDTY_MTRL, CMI_WT_FACTOR, CMI_CNTRCT_RATE, 'PL', PRESENT_PRICE, TRM_CODE, ROUND(((NVL(PRESENT_PRICE,1)*CMI_WT_FACTOR) / CMI_CNTRCT_RATE),2) AS PL_FACTOR FROM VW_CMD_MATERIAL WHERE TRM_CODE = 41) INSERT iNTO IPA_PRCADJ_HDR(TRM_CODE,IPAPH_ADJ_FACTOR,IPAPH_AMT_CUR,IPAPH_REMARKS) SELECT TRM_CODE,SUM(PL_FACTOR) AS PL_FACTOR,((SUM(PL_FACTOR)*10)) AS AMT_CUR,'asdf' FROM DTL GROUP BY (TRM_CODE); showing an error ORA-00928: missing SELECT keyword 回答1: This is the

Difference between number and integer datatype in oracle dictionary views

∥☆過路亽.° 提交于 2019-12-17 17:48:08
问题 I used oracle dictionary views to find out column differences if any between two schema's. While syncing data type discrepancies I found that both NUMBER and INTEGER data types stored in all_tab_columns/user_tab_columns/dba_tab_columns as NUMBER only so it is difficult to sync data type discrepancies where one schema/column has number datatype and another schema/column has integer data type. While comparison of schema's it show datatype mismatch. Please suggest if there is any other

How to tweak LISTAGG to support more than 4000 character in select query?

丶灬走出姿态 提交于 2019-12-17 16:41:36
问题 Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production. I have a table in the below format. Name Department Johny Dep1 Jacky Dep2 Ramu Dep1 I need an output in the below format. Dep1 - Johny,Ramu Dep2 - Jacky I have tried the 'LISTAGG' function, but there is a hard limit of 4000 characters. Since my db table is huge, this cannot be used in the app. The other option is to use the SELECT CAST(COLLECT(Name) But my framework allows me to execute only select queries and no PL

Why non-greedy quantifier sometimes doesn't work in Oracle regex?

白昼怎懂夜的黑 提交于 2019-12-17 16:37:26
问题 IMO, this query should return A=1,B=2, SELECT regexp_substr('A=1,B=2,C=3,', '.*B=.*?,') as A_and_B FROM dual But it returns whole string A=1,B=2,C=3, instead. Why? UPD: Oracle 10.2+ required to use Perl-style metacharacters in regular expressions. UPD2: More clear form of my question (to avoid questions about Oracle version and availability of Perl-style regex extension): Why ON THE SAME SYSTEM non-greedy quantifier sometimes works as expected and sometimes doesn't? This works correctly:

How to add offset in a “select” query in Oracle 11g?

不问归期 提交于 2019-12-17 16:27:56
问题 How to add an offset in a "select" query in Oracle 11g. I only know how to add the limit by e.g rownum <= 5 this question is not a duplicate, I already checked the other questions and are not related to mine. So, how to add the offset in Oracle 11g ? 回答1: You can do it easily on 12c by specifying OFFSET . In 12c , SELECT val FROM table ORDER BY val OFFSET 4 ROWS FETCH NEXT 4 ROWS ONLY; To do the same on 11g and prior, you need to use ROWNUM twice, inner query and outer query respectively. The