I cannot seem to successfully implement the cursor what I change the statement name picked from select,
For example:
SELECT userid as user_no, CURSOR(SELECT user_no
FROM my_table.punter P
WHERE P.user_no = Q.user_no)
FROM another_table.maria_punter Q;
I get the following error:
ORA-00904: "Q"."USER_NO": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 4 Column: 22
You cannot use the column alias given in the same SELECT clause; instead, use the unaliased column name from the table:
SELECT userid as user_no,
CURSOR(
SELECT user_no
FROM my_table.punter P
WHERE P.user_no = Q.userid
)
FROM another_table.maria_punter Q;
fiddle
I have the below query
select avg(to_number(pst_adm_scr)) from dmereg01.tst_scr
I keep getting the error:
ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause: The specified number was invalid.
*Action: Specify a valid number.
The field is originally a varchar with numeric values (scores)
Depending on your database version (which you haven't specified), you may be able to use the ON CONVERSION ERROR component of TO_NUMBER to ignore the invalid values
SELECT TO_NUMBER('-' DEFAULT null ON CONVERSION ERROR)
from dual;
Anyone idea why am I getting error ?
create or replace view PROD as
select
mytable.name as description
from table_name mytable
join another_table another on another.id in (
select mytable1.id
from table_name mytable1
start with mytable1.id = mytable.id
connect by prior mytable1.id = mytable1.parent_id);
Error at Command Line:8 Column:41
Error report:
SQL Error: ORA-00904: "MYTABLE"."ID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
This actually works for my local database installation. However, not on any other. Running on Oracle database.
Thank you
Version problem:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 -
Production
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit
Production
Where 1. is the one where this syntax does not work.
This article here suggests using dbms_random.value to select random values from a table.
My query
select value1, value2 from
(select value1, value2 from my.table order by dbms_random.value)
where rownum <100;
Gives me
Error at Command Line:2 Column://column after the 'by').
Error report:
SQL Error: ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
Any suggestions?
Insufficient user priviledges. Don't have access to the dbms_random package.
You need to GRANT EXECUTE to your schema. Login as your SYS user and run the following, replacing 'your-schema-name' with the Oracle user who you wish to allow run DBMS_RANDOM.
GRANT EXECUTE ON DBMS_RANDOM TO your-schema-name;
I'm getting the flowing error:
Error starting at line 1 in command:
INSERT INTO driver (registration, make, model, gvw, year, body) VALUES('4585 AW','ALBION','RIEVER',20321,1963, ' ');
Error at Command Line:1 Column:53
Error report:
SQL Error: ORA-00904: "BODY": invalid identifier
00904. 00000 - "%s: invalid identifier"
When I do the following
INSERT INTO driver
(registration, make, model, gvw, year)
VALUES
('4585 AW','ALBION','RIEVER',20321,1963, ' ');
So I temporally deleted the body data and then give the error
Error starting at line 1 in command:
INSERT INTO driver (registration, make, model, gvw, year) VALUES('4585 AW','ALBION','RIEVER',20321,1963)
Error at Command Line:1 Column:53
Error report:
SQL Error: ORA-00904: "YEAR": invalid identifier
00904. 00000 - "%s: invalid identifier"
I have columns both called year and body, yet I'm getting errors. How can I fix this?
Seems like you specified the column names under quotes in your DDL.
Oracle considers identifiers under quotes as a case sensitive, so creating a table with a column name as "body" or "year" will not resolve body or year in your query, because when you omit the quotes, it considers the upper case variant.
So when you have this:
create table driver_case (registration varchar2(60),
make varchar2(60),
model varchar2(60),
gvw number,
"year" number,
"body" varchar2(60));
and then try to do
select year, body from driver_case
then Oracle tries to find column "YEAR", "BODY" (remember, without an identifier without quotes gets converted to upper case) which is not the same as "year", "body" in your table.
Your solutions?
Don't mention column names under quotes in the DDL
If you disregard the above point, then you must mention the column names under quotes in all your DML statements.
I demonstrate the above point in this SQL Fiddle
Try this:
INSERT
WHEN city='palanpur' THEN INTO Ashish
When city='Aburoad' THEN INTO abhi
SELECT no, name
FROM arpit;