oracle11g

Oracle Pivot - converting values into columns

混江龙づ霸主 提交于 2019-12-28 04:34:06
问题 I have table in Oracle 11g with 3 fields: STUDYID | STUDY_PARAMETER | STUDY_VALUE 5268 | Age Group | ADULT (18-65) 5269 | Age Group | ADULT (18-65) 5270 | Age Group | ADULT (18-65) 5271 | Age Unit | ADULT (18-65) 1668A | Trial Type | ADULT (18-65) 5273 | Trial Type | Dispensing 5345 | Age Unit | Years 1668AC | Age Group | ADULTS (18-39) So, what I need is to display values in this order: STUDY_ID | AGE_GROUP | AGE_UNIT | TRIAL_TYPE 5268 | ADULT (18-65) | Years | Dispensing 5269 | ADULT (18-65

REGEX to select nth value from a list, allowing for nulls

寵の児 提交于 2019-12-27 11:45:57
问题 I am using REGEXP_SUBSTR() to return the nth value from a comma-separated list. This works fine when all values are present, but fails if an item is null. Here is an example that works where all values are present and I am selecting the 2nd occurrence of 1 or more characters that are not a comma: SQL> select REGEXP_SUBSTR('1,2,3,4,5,6', '[^,]+', 1, 2) data 2 from dual; D - 2 But when the second value is null, I am really getting the third item in the list, which of course really is the 2nd

Issue with PL-SQL: ORA-06550

萝らか妹 提交于 2019-12-26 05:40:58
问题 I'm trying to learn a bit of PL-SQL using a tutorial by examples book, but one of the suggested codes return the following error when run: ORA-06550: line 10, column 48: PL/SQL: ORA-00947: not enough values ORA-06550: line 9, column 1: PL/SQL: SQL Statement ignored Could you please help me understand what I'm doing wrong? Many thanks in advance! Simone. SQL Fiddle Oracle 11g R2 Schema Setup : create table product (code integer primary key, name varchar2 (20), type varchar2(8),price number(4,2

Syntax error in SQL statement “WITH” keyword throwing exception

为君一笑 提交于 2019-12-25 18:56:07
问题 I have also added another TMP2 and was not able to run the query... Could you please help me on this query? I am using Oracle 11g. WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE) SELECT TMP1.REQUEST_NO FROM TMP1; WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE), TMP2(AGENT) AS (SELECT AGENT FROM AGENT_TAB) SELECT TMP2.AGENT FROM TMP2; The exception I got is : org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE), [*

Value or Numeric error in a function and I can't detect where I have gone wrong Oracle

假装没事ソ 提交于 2019-12-25 18:52:04
问题 I have a function written in SQL developer and every time I want to execute I get value or numeric error and I simply cannot get where I have gone wrong. This is my code so if someone can give me some tips on where my mistake is hidden I would be grateful. The types that are used in the code are defined and mostly consist of varchar objects and tables of objects and I am properly putting them as an input variable. I am getting frustrated with that error because I have written similar function

Value or Numeric error in a function and I can't detect where I have gone wrong Oracle

北战南征 提交于 2019-12-25 18:51:50
问题 I have a function written in SQL developer and every time I want to execute I get value or numeric error and I simply cannot get where I have gone wrong. This is my code so if someone can give me some tips on where my mistake is hidden I would be grateful. The types that are used in the code are defined and mostly consist of varchar objects and tables of objects and I am properly putting them as an input variable. I am getting frustrated with that error because I have written similar function

check for zero rows in select query

只愿长相守 提交于 2019-12-25 17:45:04
问题 My C program has an embedded sql query. This program runs on windows and queries the oracle database. The query is similar to EXEC SQL SELECT ... I need to add here a check to know if the query returns zero rows. Basically I want to set a local valiable to know my query has returned no rows and handle this condition accordingly. How can I add it. I know that EXISTS statement can be used. But I am not getting how do I use it in embedded sql. Thanks for any help. 回答1: Use the sqlca struct EXEC

Oracle - How to handle 32K+ string length in variables

拥有回忆 提交于 2019-12-25 16:59:27
问题 I am using oracle 11g. Whenever I encountered strings larger than varchar2 size limit, In sql server I use to split the data into multiple variables as below and then join them while execution. However Oracle seems to be expecting 32K combined size before execution. I am getting "ORA-20000: ORU-10028: line length overflow, limit of 32767 bytes per line" error. I am using these variables in an oralce script (not stored procs). Last 2 statements are throwing the above error and individually I

Select the sum of occurances of first alphabetical character

和自甴很熟 提交于 2019-12-25 14:14:29
问题 Hi what i need to do is create a select statement which outputs the sum of the first character in a field within the table so the output would look something like A,12 B,0 C,20 D,14 E,0 ect... The table is called contacts, in the above there was 12 occurrences of people whose names begin with the letter A I hope i have explained this correctly 回答1: Let's understand this with EMP table example. SQL> with 2 letters 3 as 4 (select chr( ascii('A')+level-1 ) letter 5 from dual 6 connect by level <

OBIEE 11G writeback Insert XML [duplicate]

安稳与你 提交于 2019-12-25 13:59:12
问题 This question already has an answer here : Write Back Form in OBIEE (1 answer) Closed 4 years ago . I am creating an XML for inserting values into a table using the writeback feature in OBIEE 11g. Here is my XML coding and I am getting an error message that says...."The system is unable to read the Write Back Template 'STG_DE_ACCOUNTS_RECEIVABLE_insert'. Please contact your system administrator." <?xml version="1.0" encoding="utf-8" ?> <WebMessageTables xmlns:sawm="com.siebel.analytics.web