I just so happen to be the one trail blazing the pivot function for the section of the company I work in. (Needless to say, a Sesame Street style answer will not be offensive.) We are literally in the process of upgrading to 11g (11.2.0.1.0). Sadly, none of our more experienced programmers now anything about the pivot function. Not really surprising to me since we've been working in 10g. Anyway, I am using SQL Developer version 3.0.04 which I know is not the newest but I don't yet have permission to upgrade. I used [URL] to get me as far as I am on this function.
The script I am having problems with is:
SELECT *
FROM
(SELECT
[Code]....
The error I'm getting is:
ORA-01738: missing IN keyword
01738. 00000 - "missing IN keyword"
*Cause:
*Action:
Error at Line: 16 Column: 2
The error indication bounces between line 15 and 16. If I put IN at the end of 15 I then have a missing right parenthesis error...
SELECT LOCALTIMESTAMP,SYSTIMESTAMP,EXTRACT(hour FROM LOCALTIMESTAMP) +2, CASE WHEN EXTRACT(HOUR FROM LOCALTIMESTAMP) +2 Between 9 and 17 OR (EXTRACT(HOUR FROM LOCALTIMESTAMP)+2 = '5' AND EXTRACT(MINUTE FROM LOCALTIMESTAMP)+2 > '60') THEN TO_CHAR(FROM_TZ(LOCALTIMESTAMP,'GMT') AT TIME ZONE '+05:30','DD-MON-YYYY HH24:MI:SS') CASE WHEN EXTRACT(HOUR FROM LOCALTIMESTAMP)+2 < '9' THEN TO_CHAR(FROM_TZ(SYSTIMESTAMP,'GMT')+2 AT TIME ZONE '+05:30','DD-MON-YYYY HH24:MI:SS') END FROM dual;
I have a task to code a procedure and function in sql developer that will extract data within a date range (Jan 1 to April 3) from a source (source_name: expenses)and produce a text-file in pipe-delimited format.
I tried to write a dynamically changing filename and file type so that i can dump some data. But the code I wrote is not producing any file at all even though it compiles with no errors. I run this code at XE database which comes free from the oracle website. I did all the directory settings. No problem with it because I can produce file with different codes. The code is as following:
CREATE OR REPLACE PROCEDURE dump_csv_file IS
TYPE number_array IS VARRAY(10000) OF NUMBER; TYPE string_array IS VARRAY(10000) OF VARCHAR2(100); TYPE date_array IS VARRAY(10000) OF DATE; TYPE v_file_array IS VARRAY(10000) OF UTL_FILE.FILE_TYPE;
i am trying to export table using datapump in oracle 10g, this expdp takes 5 hours time, so i want use use parallel keyword in expdp, my question is how should i know number of parallels can i use...?
grant select(employee_id, job_id) on employees to scott;
But it returns error as
HR:orcl > grant select(employee_id, job_id) on employees to classuser; select(employee_id, job_id) on employees to classuser * ERROR at line 1: ORA-00969: missing ON keyword
I am having some difficulties with this trigger. It keeps giving me the error "ERROR at line 5: PL/SQL: ORA-00923: FROM keyword not found where expected" when I am not even using a SELECT before the line it says the error is on? Here is the trigger that I am attempting to create.
CREATE OR REPLACE TRIGGER ClassRestraint BEFORE INSERT ON Enrolled FOR EACH ROW DECLARE numCourses NUMBER :=0; myException EXCEPTION; BEGIN [code]...
I have this script which should find tablespaces and their size, joined with free bytes. Trying to run this gives me the SQL Error: ORA-00923: FROM keyword not found where expected.
I have two questions:
1. Where should the FROM be?
2. Is there something wrong with the join.
============================================== set linesize 120 col "TOTAL (KB)" format 99999999999999999 col "FREE (KB)" format 9999999999999999 col TSNAME format a35 col "% FREE" format a10;
SELECT a.tablespace_name TSNAME, sum(a.bytes/1024) "TOTAL (KB)", Sum(b.bytes/1024) "FREE (KB)" To_char(round((sum(a.bytes/1024)/sum(a.bytes/1024))*100),2), 'FM99990D999999') || ' % ' "% FREE" FROM dba_data_files a, dba_free_space b Where a.tablespace_name = b.tablespacename Group by a. tablespace_name [/i] =============================================
I used the script from [URL]
It worked great but I'm not sure how to use the arithmetic functions to show me MB instead of bytes.
I am trying to compile this block for updating a record. In the P_ADD_LOV_SQL column, I have to update the following select statment, but when ever I am compiling it it shows error in the Select statement as : ORA-00923: FROM keyword not found where expected. rearrange the select statement so that it doesn't show the error.The coding is :
This code run fine in Toad BUT giving me error in forms.
SELECT LEVEL LOC_NAME, LOCATION_NAME LOC_ID, LOCATION_ID HLOC_ID, HEAD_LOC_ID MUDRA FROM AS_LOCATION_HDR CONNECT BY PRIOR LOCATION_ID = HEAD_LOC_ID START WITH HEAD_LOC_ID is null ORDER SIBLINGS BY LOC_ID
The error is: "Encountered sysbol "SIBLINGS" when expecting one of the following: by The symbol "by inserted before the "SIBLINGS" to continue.
Is the SIBLINGS keyword not acepted in forms? What would be the alternative?
We have an Oracle UCM and Oracle SES implementation.Currently there are too many tags returned for certain keywords by SES which breaks the UI,some of the tags being irrelevant too.Is there any configuration variable in SES by which these tags can be limited to say 20 most relevant tags.?
We are running on Oracle 10g. The following script results in ORA-00928: missing SELECT keyword. what causes this error? Both 'select' statements when run by themselves, complete successfully.
[code]WITH A1 AS WITH A1 AS ( SELECT MIN (VAPS_RPT_INTV_DMSN.INTV_DT), VAPS_RPT_INTV_DMSN.RPT_ID, VAPS_RPT_INTV_DMSN.RPT_INTV_ID FROM APS.VAPS_RPT_INTV_DMSN, APS.VAPS_RPT_CL_INTV_DMSN WHERE APS.VAPS_RPT_INTV_DMSN.RPT_INTV_ID =
I have one query regarding how to retrieve the CLOB data.
The requirement is something that in the select statement there are around 20+ columns which i need to retrieve from around 5 tables after joining.
Since the result set after joining also will get duplicate values i need to use distinct keyword to filter the resultset. But in the 20+ columns there are 2 CLOB data columns which i need to retrieve.
Whenever i use DISTINCT i'm getting ORA-00932: inconsistent datatypes: expected - got CLOB error. I know that DISTINCT keyword cannot be used for CLOB datatypes.
I am importing data from excel to database table with column mapping.I have created package with a procedure. I am calling this procedure from oracle forms 6i. while executing the package procedure,I am getting following error ora-00928 missing select keyword ora-06512 at" abcd.pk_ excel_ to_ db" line 26 i.e befor forms_ddl.there is no problem in code and my form gets compiled but at run time i am getting this error.I also want to check, array is populating with anything or not.
PACKAGE PK_EXCEL_TO_DB IS TYPE tKeyValue IS RECORD ( CROUTE VARCHAR2(255), VROUTE VARCHAR2(1000), CTRNDATE VARCHAR2(255), VTRNDATE VARCHAR2(1000), CTTIME VARCHAR2(255), VTTIME VARCHAR2(1000), CTID VARCHAR2(255), VTID VARCHAR2(1000)); TYPE tDataList IS TABLE OF tKeyValue index by binary_integer; [code].....
i have a table that contains employee id, employee name , so if i gave the correct employee id in where clause of select statement it will show employee name, in case if i give the employee id that does not exist in the table it will show 'Employee name is not found'..
Is pivot the right command to use? If so, how do I do this? Most pivot examples I've looked at use an aggregate like SUM, which is not really want I am trying to accomplish here.
I'm trying to use a PIVOT on the following data set:
ID STATUS_DESC PAY_STATUS PAID_DATE TRANSACTION_TYPE TRANSACTION_DESC DEBIT TOTAL -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9876 In Progress 2nd Payment Made 11-DEC-12 19.38.57 Card Payment Payment 2 349 349 9876 In Progress 2nd Payment Made 06-DEC-12 14.33.57 Card Payment Payment 1 100 100
However I'm still getting two rows as per the below. Ideally all data should be on a single row.
ID STATUS_DESC PAY_STATUS PAYMENT_1_DATE PAYMENT_1_AMT PAYMENT_2_DATE PAYMENT_2_AMT TOTAL -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9876 In Progress 2nd Payment Made 06-DEC-12 14.33.57 100 100 9876 In Progress 2nd Payment Made 11-DEC-12 19.38.57 349 349
I have constructed my pivot using the following on the outer select:
PIVOT (MAX (insert_timestamp) AS paid_date ,SUM (debit) AS amt
FOR transaction_desc IN ('Payment 1' AS payment_1, 'Payment 2' AS payment_2)) ;
I've used MAX to pivot the date and also tried using NVL on the insert_timestamp but still no luck.
I have a requirement to write a single sql query where i can generate the pivot report. Found some of the examples in Google search. But here we are hard coding the values if it is limited like month in this example.
i want to write similar query to represent the amount based on product type , i have around 200 types of products. I can't write case/ decode statement those many times.
query which will produce the output in pivot format , dynamically depending the number of values.
select Product, sum(case when Month=�Jan� then Amount else 0 end) Jan, sum(case when Month=�Feb� then Amount else 0 end) Feb, sum(case when Month=�Mar� then Amount else 0 end) Mar from Sales group by Product