oracle11g

Is there a more efficient way to aggregate the top row from multiple select statements into a single result?

岁酱吖の 提交于 2020-05-16 22:01:37
问题 Ok, I have experience in various databases, but not Oracle specifically, so still trying to wrap my head around how it handles things (i.e. the lack of 'Top' drives me mad!) Anyway, here's what we're trying to do... Note: We're using Oracle 11. I understand a new feature was added to Oracle 12 (i.e. FETCH NEXT n ROWS ONLY ) but we can't use that unfortunately. To start, we have an articles table (technically it's a view, but I'm simplifying it here). Here are the relevant fields... ID

Editing the output (set brackets depending on the quantity retrieved and the semicolon)

本秂侑毒 提交于 2020-05-15 07:49:17
问题 Every time that I run my code I obtain one, or two or several rows on a JSON format. I am using Oracle 11g . This is my CODE on SQL Fiddle, you will find all the data there. For example, in this case I obtained something like this: {"sku":"99342435","PRICE":"9999",PRICES_FOR_CLIENTS:[{"group":"A","PRICE":"29223"},{"group":"B","PRICE":"33223"},{"group":"SUPERMARKET","PRICE":"48343"},{"group":"WALMART","PRICE":"40340"}]}; BUT I could get this output depending on the data stored in the tables: {

TIMESTAMP To DATE in Oracle SQL

扶醉桌前 提交于 2020-05-15 04:49:27
问题 I have a column called Create_Date which has data in the format like 19-JUN-18 10.27.00.000000000 PM and data type is TIMESTAMP(6) . I am trying to look at date range like yesterday's date or between two dates in Create_Date without using TO_DATE(TO_CHAR(P.CREATE_DATE_TIME,'dd/mon/yy')) and entering the value as '19-JUN-18' . I want to use Create_Date=SYSDATE-1 OR Create_Date=CURRENT_DATE-1 instead to filter on yesterdays date. Or Use Create_Date>=SYSDATE or Create_Date>=CURRENT_DATE to look

Get last record of result set

半城伤御伤魂 提交于 2020-05-14 01:07:41
问题 Following is the sql query (oracle) that I use to get the last record of the returning result of the select query. Is this the optimum way? SELECT HAZMAT_PLACARD_NOTATION INTO v_pcn FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd and ROWID = (SELECT MAX(ROWID) FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd); Following is an example result set of the select query where HAZMAT_CD = 4920111 But the last row with the HAZMAT_PLAYCARD_NOTATION value SPONTANEOUSLY COMBUSTIBLE should be

Get last record of result set

有些话、适合烂在心里 提交于 2020-05-14 01:05:43
问题 Following is the sql query (oracle) that I use to get the last record of the returning result of the select query. Is this the optimum way? SELECT HAZMAT_PLACARD_NOTATION INTO v_pcn FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd and ROWID = (SELECT MAX(ROWID) FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd); Following is an example result set of the select query where HAZMAT_CD = 4920111 But the last row with the HAZMAT_PLAYCARD_NOTATION value SPONTANEOUSLY COMBUSTIBLE should be

Get last record of result set

喜夏-厌秋 提交于 2020-05-14 01:04:52
问题 Following is the sql query (oracle) that I use to get the last record of the returning result of the select query. Is this the optimum way? SELECT HAZMAT_PLACARD_NOTATION INTO v_pcn FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd and ROWID = (SELECT MAX(ROWID) FROM HAZMAT_CLASS_IRF WHERE HAZMAT_CD = p_stcc_cd); Following is an example result set of the select query where HAZMAT_CD = 4920111 But the last row with the HAZMAT_PLAYCARD_NOTATION value SPONTANEOUSLY COMBUSTIBLE should be

Creating JSON and editing a complex query (oracle 11g)

限于喜欢 提交于 2020-04-07 03:46:28
问题 I have 4 different tables: table_price_product (contains information related to the products and their price) table_price_list (contains the information related to the price list) prices_per_client (contains the information related to the prices for the different clients given a specific product) clients (contains the information related to the clients) This is my SQL FIDDLE: LINK I got this: CUSTOMER_NUMBER | CUSTOMER_CLASS_CODE| PRICE (null) | A | 29223 (null) | B | 33223 112121 | E | 40340

System users password has expired

被刻印的时光 ゝ 提交于 2020-04-05 12:45:55
问题 I have just tried to login to my db via sql developer as system so i can create a new user. It has come with an error that the password has expired. I have googled a bit but cannot see how to reset the system user password. I guess this is a security issue. My problem is how can I log in as system if the password has expired? How can I unexpire the password without logging in as System users. I seem to be stuck here in a loop where I cannot reset the password expiration. 回答1: Open up cmd.exe

Updating User-defined types in Oracle 11G

杀马特。学长 韩版系。学妹 提交于 2020-03-26 05:26:49
问题 Is there any way to update part of a user-defined type in Oracle? Example: create or replace TYPE MY_TYPE AS OBJECT ( VAR_1 NUMBER, VAR_2 DATE, VAR_3 NUMBER, VAR_4 DATE ); Sample Table: create TABLE TEST_TABLE ( TBL_ID NUMBER, MY_DATA MY_TYPE ); Is there any way to do something like the following: UPDATE TEST_TABLE SET MY_DATA.VAR_3 = 1; Thanks! 回答1: Yes but for some reason you need to alias the table: UPDATE TEST_TABLE T SET T.MY_DATA.VAR_3 = 1; 来源: https://stackoverflow.com/questions

Base 64 decoding in Python and Oracle

江枫思渺然 提交于 2020-03-25 12:34:04
问题 I am trying to replicate some python 2.7 code in Oracle database. When trying to replicate base64 decoding , I am getting different output. Python Code: # -*- coding: utf-8 -*- import base64 print(base64.b64decode('rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAgGLCRnyhEZhzJJRd7EoVPp2XWTRgDNYHq4cAghvXvTaw=')) Python Code Output: �� ur [B���T� xp ���(Df�%{�O�e�M5���� ���M� Oracle Query: select utl_raw.cast_to_varchar2(UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW ('rO0ABXVyAAJbQqzzF