PL/SQL :: Unpivot Query Error?

Nov 15, 2012

am running an oracle 11gR2 Database.

I have a table of the structure..
CREATE TABLE "RP_RESOLUTION_MASTER"
( "RM_ID" NUMBER,
"SR_ID" NUMBER,
"REQUEST_STATUS" VARCHAR2(200 BYTE),

[code]....

But I get an error

ORA-01790: expression must have same datatype as corresponding expression
01790. 00000 - "expression must have same datatype as corresponding expression" *Cause:
*Action: Error at Line: 3 Column: 51

View 4 Replies


ADVERTISEMENT

PL/SQL :: Unpivot Or Union

Dec 11, 2012

Cant find any artice on what is better to use unpivot or union all. I can achive same results using either but cant decide what would be better. For example a table has columns:

Name 1, Phone1, Name 2, Phone 2. The result I want would be:

Name 1, Phone 1
Name 2, Phone 2.

View 5 Replies View Related

SQL & PL/SQL :: Implementing Unpivot In Oracle 11g

Sep 27, 2011

implementing UNPIVOT in..I am using Oracle 11g Release 11.2.0.1.0

OS: windows

Table Structure
CREATE TABLE "EMPLOYEE_ROLE"
("EMPLOYEE_ID" NUMBER(10,0),
"MANAGER_1" VARCHAR2(10 BYTE),
"MANAGER_2" VARCHAR2(10 BYTE),
"MANAGER_3" VARCHAR2(10 BYTE),
"MANAGER_4" VARCHAR2(10 BYTE),
[code]....

EMPLOYEE_ID MANAGER_1 MANAGER_2 MANAGER_3 MANAGER_4 MANAGER_5 ROLE_1 ROLE_2 ROLE_3 ROLE_4 ROLE_5 1345 John Mike Ram Kumar null DBA Sql Dev PLSQL Admin null

1 rows selected

I want a output like this

EMPLOYEE_ID MANAGER ROLE1
1345 John DBA
1345 Mike SQL DEV
1345 Ram PLSQL
1345 Kumar Admin

*I have tried with UNPIVOT *

SELECT
EMPLOYEE_ID
,MANAGER
FROM
EMPLOYEE_ROLE
UNPIVOT( MANAGER
FOR col1
in (MANAGER_1,
MANAGER_2,
MANAGER_3,
MANAGER_4,
MANAGER_5
))

i am able to get manager and role in two different queries

EMPLOYEE_ID MANAGER

1345 John
1345 Mike
1345 Ram
1345 Kumar

4 rows selected

SELECT
EMPLOYEE_ID
,ROLE1
FROM
EMPLOYEE_ROLE
UNPIVOT( ROLE1
FOR col1
in (ROLE_1,
ROLE_2,
ROLE_3,
ROLE_4,
ROLE_5
))
[code]....

Is it possible to add two unpivots in a single UNPIVOT query.

View 5 Replies View Related

SQL & PL/SQL :: Generate Dynamic Unpivot?

Oct 16, 2012

I want to be able to generate unpivot for 1 row of data dynamically.what i am trying to do is based on this linkI just need to be able to pass the table name in format : SCHEMA_NAME.TABLE_NAME and the query should unpivot the data for 1 row. (Will always be 1 row, just need to transpose the column names and the values for 1 row of data)

I made the below query so far. But I am getting an error and can't figure out a way to fix it.pass any table name from your database in the define step

define TAB_NAME='SCOTT.EMPLOYEE'
WITH sel_col AS
(
SELECT DECODE (data_type,

[code]...

ERROR at line 33:
ORA-00904: : invalid identifier

Its the last line of the code. The same seems to work in the select part but not in the IN part.

P.S: I cannot do PL/SQL - as i simply dont have access.

View 9 Replies View Related

PL/SQL :: Pivot / Unpivot Data?

Mar 20, 2013

I am not sure if we can do this as i tried many solution for pivoting/unpivot My data looks like from table when i do Select * from table_name

col1                       col2                 col3      col4  col5 col6    col7 col8
20130320_0938      C11               1416      98    93   30    30    32                                    
20130320_0938      C22                   26      92    73   50    50    65                                    
20130320_0938      C33                    86      95    81   63    63    76

I want the data to look like

[code]...

View 5 Replies View Related

PL/SQL :: Unpivot Using Order By Clause

May 15, 2013

explain the difference in the VALUE column when DESCRIPTION = 'dept' when the query is run with and without the order by clause.

SELECT * FROM
(
SELECT * FROM emp
--ORDER BY job
)UNPIVOT (VALUE FOR DESCRIPTION IN (sal AS 'salary', deptno AS 'dept'));

View 12 Replies View Related

PL/SQL :: Query On Other_xml Column Error?

Jun 3, 2013

I am trying to run the below query to extract the outline data from v$sql_plan(querying other_xml column), but i get the below error...this works perfectly fine on 10.2.0.4 + version...but on 10.2.0.2 and and 10.2.0.1 i get the below error... how to fix it ?

SQL> @sql_hint
Enter value for sql_id: d15cdr0zt3vtp
Enter value for child_no: 0
extractvalue(value(d), '/hint') as outline_hints
*
ERROR at line 2:
ORA-00904: "D": invalid identifier

the query is taken from below...[URL]....

select
extractvalue(value(d), '/hint') as outline_hints
from
xmltable('/*/outline_data/hint'
passing (

[code]...

View 3 Replies View Related

SQL & PL/SQL :: Dynamic Sql Query String - Getting Error?

Aug 22, 2010

FUNCTION get_attributed_sedol( p_ref_number IN VARCHAR2,
p_field IN VARCHAR2 )
RETURN VARCHAR2
IS
l_query VARCHAR2(1000);

[code]...

It gives me an error on the line where the execute immediate statement is.
Quote:
ORA-00905
missing keyword

Cause: A required keyword is missing.

Action: Correct the syntax.

But when I check my stack trace table to see what the actual query string looks like, I see this

Quote:
SELECT sedol INTO l_attributed_sedol_code FROM integration.tmp_attributed_sedol WHERE CLIENT_LEDGER_REF='LEAE057090' AND ROWNUM=1

There's nothing wrong with that, is there? It executes fine if I try it manually.

View 3 Replies View Related

SQL & PL/SQL :: Date Error In Execute Immediate Query Through Function?

Jun 25, 2012

I've used a date in execute immediate query in function, but at the time passing the date as input parameter and getting the result i'm getting following error.

CREATE TABLE MIS.TEMP
(
ID NUMBER(8),
STOCKDATE DATE,
STOCKQTY NUMBER(10,2)
);

[code]....

SQL> select getstockqty(1,to_date('31/03/2012','dd/mm/yyyy')) from dual;
select getstockqty(1,to_date('31/03/2012','dd/mm/yyyy')) from dual
*
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "MIS.GETSTOCKQTY", line 11

View 12 Replies View Related

SQL & PL/SQL :: Expression Not Supported Error For Query Rewrite

Aug 13, 2013

I am trying to create a materialized view with the following script :

CREATE MATERIALIZED VIEW "MRT"."MV_RV_SMALL_BUSINESS"
(
"batch_id"
,"small_business_flag"
,"account_count"
,"naics_count"
,"mra_count"
[code].......

IT GIVES ME THE FOLLOWING ERROR:

SQL Error: ORA-30353: expression not supported for query rewrite
30353. 00000 - "expression not supported for query rewrite"
*Cause: The select clause referenced UID, USER, ROWNUM, SYSDATE,
CURRENT_TIMESTAMP, MAXVALUE, a sequence number, a bind variable,
correlation variable, a set result,a trigger return variable, a
parallel table queue column, collection iterator, etc.

View 2 Replies View Related

Server Utilities :: EXPDP With Query Error?

Jun 3, 2010

While trying to expdp using Query logics, getting syntax related erros shown below:

expdp system/xxxx SCHEMAS=LOG NETWORK_LINK=DBLINK1 INCLUDE=TABLE:"IN('DAILY_LOG')" QUERY=LOG.DAILY_LOG:"where entry_date< to_char(sysdate -1,'yyyymmdd')" DIRECTORY=dump DUMPFILE=log_exp.dmp logfile=log_exp.log

But gives the following error
ORA-31693: Table data object "LOG"."DAILY_LOG" failed to load/unload and is being skipped due to error:
ORA-00904: "YYYYMMDD": invalid identifier

I tried with simple sql with YYYMMDD and it works fine, the entry_date is a char field. in QUERY where i'm doing wrong here?

View 4 Replies View Related

SQL & PL/SQL :: Error In Query - ORA-00905 - Missing Keyword?

Jun 1, 2010

Check out following query

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;

ORA-00905: missing keyword

View 8 Replies View Related

Spatial :: Error While Executing Oracle Query From C#

Apr 18, 2013

I am trying to execute an inline spatial query from c# using ODP.NET. This is a select query and I am passing 2 parameters to this query, one is string and other one is SDO_GEOMETRY. I am able to send SDO_Geometry parameter from c# using Oracle UDT custom designed classes.

Query is working as intended but occasionally giving the following errors:

ORA-29902: error in executing ODCIIndexStart() routine
ORA-13033: Invalid data in the SDO_ELEM_INFO_ARRAY in SDO_GEOMETRY object
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 333
ORA-29902: error in executing ODCIIndexStart() routine
ORA-13031: Invalid Gtype in the SDO_GEOMETRY object for point object
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 333

I could not figure out the cause of this issue (as it is not failing frequently). Am i getting this issue with the actual query or with Oracle UDT conversion.

View 5 Replies View Related

PL/SQL :: Create A Procedure For SELECT Query - Error?

Nov 1, 2013

how do I create a procedure for a SELECT query like the following?

When I create a procedure; I get an error "Error(80,1): PLS-00428: an INTO clause is expected in this SELECT statement" PROCEDURE  MyProcISBEGINselect 'Dakota' as ALIAS      ,A.StartDate      ,B.EndDatefrom Customer A    ,Clients bwhere  a.cType = b.cTypeand b.Active =0ORDER BY StartDate, EndDateEND  MyProc;

View 17 Replies View Related

Parenthesis Create Error In Query / How To Clean Text Before Use

Nov 10, 2008

i am binding a string to a CONTAINS search (oracle text) and its throwing an error because of characters within the string.

this causes the error.
Quote:
(A. A.)
if i take out ( and ) it works
Quote:
A. A.

i thought binding took care of these issues as well as sql injection?

example:

SELECT
score(1) the_score,
id
FROM
t_table
WHERE
contains(text_column, :BINDVAR1, 1) > 0

how can i get around this and other character errors on the fly?

View 4 Replies View Related

Client Tools :: How To Query Tablename That Don't Exist And Not Get Any Error

Oct 24, 2012

Here is the query I want to be able to run...

select * from NonExistingTableName

I want the query above to be ignored and return no results (rather than generating an error) when the tablename does not exist.

View 14 Replies View Related

SQL & PL/SQL :: Update Query Fail With Error - Missing Right Parenthesis

Feb 17, 2010

my update query seems to fail with error

ORA-00907: missing right parenthesis

Below is my test case:

create table t1(
sn varchar2(30),
inv_org number);
create table s1(
sn varchar2(30),
trx_date date,
inv_org number);

[code]...

View 8 Replies View Related

Forms :: FRM-40505 / Unable To Perform Query Error

May 13, 2010

I am getting the same error on a form I am setting up under version 10.1.2 Form Builder. But when I press Shift-F1 I get a Getting Started with Internet Explorer popup. I am running the form under OAS. I have a parent/child relationship between 2 tables that I query on the form.

A copy of the fmb file is attached to access it.

View 11 Replies View Related

SQL & PL/SQL :: Very Long Query With Ref Cursor - Buffer Too Small Error

Jun 21, 2011

I want to pass a damn long query(which includes a lot of column names, tables, joins, union, where clauses etc. and whose length is more than 120000) in a Ref cursor (that's length is more than 32767). Query is stored in a LONG type variable V_QRY in stored procedure, and I am opening that ref cursor like below-

OPEN P_RPT_TEST FOR V_QRY;

at run time its giveing string buffer too small error.

View 7 Replies View Related

SQL & PL/SQL :: Query Over Database Link Ambiguous Column Error Not Raised

Apr 1, 2011

why this query is not raising an error:

select memberid, mi.typeid, emailaddress
from memberdata@prod_db m
join memberitems@prod_db mi on m.memberid = mi.memberid;

These are the tables:

SQL> desc memberdata@prod_db
Name Null? Type
----------------------------------------- -------- ----------------------------
MEMBERID NUMBER
EMAILADDRESS VARCHAR2(50)
ADDRESS1 VARCHAR2(50)

SQL> desc memberitems
Name Null? Type
----------------------------------------- -------- ----------------------------
MEMBERID NUMBER
ITEMID NUMBER

Shouldn't we raise an 'ambiguous column' error on memberid?

View 9 Replies View Related

Server Utilities :: Syntax Error In Using Query Parameter In Expdp

Aug 17, 2013

I want to take an export of table MESSAGE, and filter it for the day of 17 JUL 2013 (just to limit the size). i used the following expdp command but its not working.

expdp SYSTEM directory=DATA_PUMP_DIR dumpfile=DB_16_08_2013.dmp logfile=FA0001P_BG_16_08_2013.log TABLES=schema.MESSAGE QUERY=schema.MESSAGE:where created_on between to_date('17-July-13 00:00:00','DD-Mon-YY hh24:MI:SS') and to_date('17-July-13 23:59:00','DD-Mon-YY hh24:MI:SS')

But with select query i am able to retrieve the rows for the specific date.

select * from MESSAGE where created_on between to_date('17-July-13 00:00:00','DD-Mon-YY hh24:MI:SS') and to_date('17-July-13 23:59:00','DD-Mon-YY hh24:MI:SS')
Here is the command with syntax error.
[oracle@orcl log]$ expdp SYSTEM directory=DATA_PUMP_DIR dumpfile=DB_16_08_2013.dmp logfile= DB_16_08_2013.log TABLES=schema.MESSAGE QUERY=schema.MESSAGE:where created_on between to_date('17-July-13 00:00:00','DD-Mon-YY hh24:MI:SS') and to_date('17-July-13 23:59:00','DD-Mon-YY hh24:MI:SS')
-bash: syntax error near unexpected token `('

View 3 Replies View Related

Server Administration :: Query Fails With Error ORA-01555 / Snapshot Too Old

Jun 23, 2011

We are running a query in one of our databases using the database the link. The query fails in the middle with "ORA-01555: snapshot too old". Not sure, about the database which this error message points to? Will it be the database we have logged in or it is the database where db link points ?

View 7 Replies View Related

Getting Deadlock Detected While Waiting For Resource Error For Select Query

Nov 4, 2013

i am getting a below error whenever executing the below select query. some times it will show dead lock detected while waiting for resource and terminated...some times it executes and gives result..but all the time it writes an alert to alert log 

Env: Linux / Oracle 11.2.0.3.3..Error from alert log:Errors in file /u01/oracle/oracle/diag/rdbms/bdrdb/bdrdb/trace/bdrdb_p017_6076.trc:ORA-00060: deadlock detected while waiting for resourceORA-10387: parallel query server interrupt (normal)  Trace file info... bdrdb_p017_6076.trc:Trace file /u01/oracle/oracle/diag/rdbms/bdrdb/bdrdb/trace/bdrdb_p017_6076.trcOracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsORACLE_HOME = /u01/oracle/oracle/product/11.2.0/dbhome_1System.
[code]....

View 11 Replies View Related

SQL & PL/SQL :: Union Query Need To Add Extra Dummy Field To One Side Of Query

Dec 8, 2005

I have inherited a query that union alls 2 select statements, I added a further field to one of the select statements ( a date field). However I need to add another dummy field to the 2nd select statement so the union query marries up I have tried to do this by simply adding a

select
'date_on'
to add a field called date on populated by 'date_on' (the name of the column in the first query)

however when I run the union query i get the error Ora-01790 expression must have same datatype as corresponding expression.

View 6 Replies View Related

SQL & PL/SQL :: Create View From Dynamic Query (or Function Returning Query)

Dec 5, 2012

I have a dynamic query stored in a function that returns a customized SQL statement depending on the environment it is running in. I would like to create a Materialized View that uses this dynamic query.

View 1 Replies View Related

Reports & Discoverer :: Excluding SQL Query Data When Linked With XML Query?

Apr 26, 2013

I have data in a table and another in XML file,I used SQL query to retrive the data placed on the table, and link this query with XML query that retrieves the data stored in the xml file. The data stored in the table and xml file sharing a key field, but the xml contents are less than what in the table.I want to show only the data shared between the two queries, how can I do that?

e.g.:

Table emp:

e_id | e_name | e_sal
023 | John | 6000
143 | Tom | 9000
876 | Chi | 4000
987 | Alen | 7800

XML File

<e_id>
143
876

So, I want the output to be:

e_id | e_name | e_sal | e_fee
143 | Tom | 9000 | 300
876 | Chi | 4000 | 100

View 2 Replies View Related

Storing Select Query Result Into Array And Using It In Another Query?

Aug 7, 2009

I am looking to simplify the below query,

DELETE FROM A WHERE A1 IN (SELECT ID FROM B WHERE BID=0) OR A2 IN (SELECT ID FROM B WHERE BID=0)

Since both the inner queries are same,I want to extract out to a local variable and then use it.

Say,

Array var = SELECT ID FROM B WHERE BID=0;

And then ,

DELETE FROM A WHERE A1 IN (var) OR A2 IN (var)

How to do this using SQLPLUS?

View 8 Replies View Related

SQL & PL/SQL :: Oracle Query Joining A Table With Existing Query?

Jun 19, 2012

I have the following four tables with the following structures Table A

ColA1 ColA2 ColA3 ColA4 ColA5 AA 100 CC DD EE

Table B

ColB1 ColB2 ColB3 ColB4 ColB5 AA 100 40452 A9 CDE

when these two tables were joined like the following:

Select colA1,ColA2, ColA3, ColA4, ColB3,ColB4, ColB5 from table A Left outer join (select ColB3, ColB4, ColB5 from table B where colB3 = (select max(colB3) from table B ) on (colA1 = colB1 and ColA2 = col B2)

Now i have to join the next table C with table B

Table C structure is

ColD1 ColD2 ColD3 Desc1 A9 Executive Desc1 A7 Engineer

I have the common column such as ColD2 and colB4 to get the Col D3

how do i join the existing query + join between table b and table c?

View 4 Replies View Related

Forms :: F11(Query Mode) And Execute Query In Oracle?

Jul 17, 2011

how to achieve F11(Query mode) and Execute Query in Oracle Forms?

View 1 Replies View Related

SQL & PL/SQL :: Query Using DBLink Returns More Rows Than Direct Query?

Apr 6, 2010

I have a query that is pulling back more rows when I use the dblink than when I hit the linked database directly.

For example:

select
x,y,z
from
mytable@dblink

returns 788,324 rows

while
select
x,y,z
from
mytable

returns 712,102 rows

It's the exact same query, with the only difference being the dblink. It's not pulling the data into a cursor or array, it's a simple, straightforward query on a remote database.

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved