Why does my SQL code tell me that paddling is not a good identifier? - oracle

I AM ON CLOUD VERSION OF ORACLE
so what I need to do is insert data from an already established table into a new table. I am a student and I pretty much copied what they told me to do, just changing the table and what i need to grab
here is my code:
INSERT INTO PADDLING
SELECT TRIP_ID, TRIP_NAME, STATE, DISTANCE,
MAX_GRP_SIZE,
SEASON
FROM TRIP
WHERE TYPE = Paddling;
and here is the error
ORA-00904: "PADDLING": invalid identifier
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_200200",
line 670
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1658
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_200200",
line 656
ORA-06512: at
"APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 1768
4. WHERE TYPE = Paddling;
I tried PADDLING in all uppercase, however it is lowercase in the table i am grabbing from.

You want to quote the string literal :
INSERT INTO PADDLING
SELECT TRIP_ID, TRIP_NAME, STATE, DISTANCE,
MAX_GRP_SIZE,
SEASON
FROM TRIP
WHERE TYPE = 'Paddling';
If you do not have the quotes then Oracle assumes it is an identifier, typically for a column name. To show that it is a string literal and not an identifier you need to use single quotation marks.

Related

Oracle Text truncate words to 64 CHARS but token limit is 64 BYTES

I'm using Oracle 19c.
I have a table with a VARCHAR2(4000) column for which I'm creating a full-text index using Oracle Text.
The SQL creating the index is as follow:
begin
ctx_ddl.create_index_set('ix_iset');
ctx_ddl.create_preference('ix_pref', 'BASIC_LEXER');
ctx_ddl.set_attribute('ix_pref', 'skipjoins', '-');
ctx_ddl.set_attribute ( 'ix_pref', 'index_stems', 'portuguese');
ctx_ddl.set_attribute ( 'ix_pref', 'index_text', 'YES');
ctx_ddl.set_attribute ( 'ix_pref', 'base_letter', 'YES');
end;
CREATE INDEX ix_tx_column ON MYTABLE(tx_column)
INDEXTYPE IS CTXSYS.CTXCAT
PARAMETERS ('index set ix_iset lexer ix_pref');
Everything works very well, but when there is a word with more than 64 chars, an error is raised:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000: Oracle Text Error:
DRG-50857: oracle error in dreii1fsh
ORA-12899: value too large for column "CAD"."DR$IX_TX_COLUMN$I"."DR$TOKEN" (actual: 65, maximum: 64)
ORA-06512: em "CTXSYS.DRUE", line 186
ORA-06512: em "CTXSYS.CATINDEXMETHODS", line 102
29855. 00000 - "error occurred in the execution of ODCIINDEXCREATE routine"
*Cause: Failed to successfully execute the ODCIIndexCreate routine.
*Action: Check to see if the routine has been coded correctly.
I've looked into the documentation and the only reference to this limitation is this item:
2.14 Token Limitations for Oracle Text Indexes
After some research I realized that probably the Oracle-Text internal functions are truncating the words to 64 CHARS, but the token limit is 64 BYTES.
The text word causing this error have Diacritical Characters within its first 64 chars like ç ã õ é and so on... Each char are 2 bytes in size.
I tried to set NLS_LENGTH_SEMANTICS=BYTE with no success.
As long as I researched, there is no way how to change the size of the index token.
Edit:
The result of SELECT * FROM v$nls_parameters is:

oracle column not allowed here

I got this error:
Error report -
ORA-00984: column not allowed here
ORA-06512: at line 14
00984. 00000 - "column not allowed here"
here is the code. I copy and paste the field name (all in cap). The field name should be correct
set serveroutput on
DECLARE
my_creation_dt date;
mysql varchar2(6000) := '';
BEGIN
select creation_dt into my_creation_dt from role_table where security_role = 'admin';
mysql := 'insert into role_grant_table (PERSON_ID, CREATION_DT, SECURITY_ROLE,
SSS_CREATE_DT, UPDATE_WHO, UPDATE_ON) values (1234, SYSDATE,
"ADMIN",
:my_creation_dt,
"myname",
SYSDATE)'; -- line 14, column not allowed here
execute immediate mysql using (my_creation_dt);
END;
Double-quotes are used to enclose identifiers (usually when they have mixed case or punctuation characters). So Oracle is interpreting "ADMIN" and "myname" as identifiers, which in this context the parser takes to be column names. The error is telling you that referencing a column here is not allowed.
Presumably, you intended those to be the string values to be inserted. Use
single-quotes to enclose string literals, i.e. 'ADMIN' and 'myname'.

"ORA-12401: invalid label string: " error

I am trying to run a simple update statement in Oracle to modify an Integer field of a specific row.
UPDATE Mytable
SET field1 = 2
WHERE field2 = 11111;
But I receive this error
SQL Error: ORA-12401: invalid label string:
ORA-06512: at "LBACSYS.NUMERIC_LABEL_TO_CHAR", line 1
ORA-06512: at "LBACSYS.LBAC$BU0_92924", line 1
ORA-04088: error during execution of trigger 'LBACSYS.LBAC$BU0_92924'
12401. 00000 - "invalid label string: %s"
*Cause: The policy could not convert the label string to a valid
internal label.
*Action: Correct the syntax of the label string.
Google search did not bring much results. Do you have any idea about the solution of this error?

Cannot convert String to date in Oracle 11g

I'm trying to insert Date into table from user input but something doesn't work.
I have the following Query :
INSERT INTO DOCTORS.TREATMENTS
(START_OF_TREATMENT, END_OF_TREATMENT, DOCTORS_ID,PACIENTS_ID, DIAGNOSIS_ID)
VALUES (TO_DATE(&startdate, 'yyyy/mm/dd'), TO_DATE(&enddate, 'yyyy/mm/dd'), 3, 1, 1);
For start date I set :
2000/10/01
And for end date I set :
2000/11/01
It seem ok for me but I've got the following error :
Error report -
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "SYS.STANDARD", line 167
ORA-06512: at line 2
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
Any one can explain to me why this error occurred.
Best regards,
Petar.
The value of the first parameter passed to TO_DATE must be a string. After substitution with the value you've given your code will look like
TO_DATE(2000/10/01, 'yyyy/mm/dd')
which fails as shown.
The solution is to put the parameter usage in single-quotes to make the substituted value a string, as in
TO_DATE('&startdate', 'yyyy/mm/dd')
This way, when &startdate is substituted you'll get
TO_DATE('2000/10/01', 'yyyy/mm/dd')
which will work as expected.
Do the same for &enddate.
Best of luck.

Leave column out of Oracle insert statement

I have an insert statement that I am trying to run against an Oracle database. The insert statement is very simple, and I only want to insert a value into one column. The table itself has more than one column, but I am only interested in filling one of the columns with data. The format of my query is similar to the one below:
insert into myTable (col1) Values (val1)
However, this throws the following error:
ORA-00904: "col1": invalid identifier
I've checked to make sure that the column is named correctly, and my only other thought is that something is wrong with my syntax. There are no constraints on the table such as primary keys. Is it possible to only insert values into certain columns when executing an insert statement in Oracle?
Check that you didn't quote the column name on creation of the table. If you did, the column name is stored as you quoted it. For example:
create table table1 (
id number(2)
)
has a different column name to this
create table table2 (
"id" number(2)
)
Oracle by default stores the (unquoted) column names in uppercase. Quoted are stored as is.
You can use a DESC table_name to see how the columns are stored.
The following
select id from table1
select iD from table1
select ID from table1
fetch the records, while only
select "id" from table2
will fetch records.
select id from table2
will throw the ORA-00904 : "ID" : invalid identifier error.
You may have inadvertently done the quoting during creation while using tools as established below:
https://community.oracle.com/thread/2349926
Btw: Yes it is possible to insert records for only one column, as long as the other columns do not have a NOT NULL constraint on them.
Actually, I think you may be double quoting the column in the insert statement (not on table creation), although your example is misleading. I guess this because of your error, which says "col1" is invalid, not "COL1" is invalid. Consider this simple test:
SQL> create table mytable
(
col1 varchar2(10)
)
Table created.
SQL> -- incorrect column name, without double quotes
SQL> insert into mytable(col2) values ('abc')
insert into mytable(col2) values ('abc')
Error at line 9
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-00904: "COL2": invalid identifier
SQL> -- incorrect column name, with double quotes
SQL> insert into mytable("col2") values ('abc')
insert into mytable("col2") values ('abc')
Error at line 12
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-00904: "col2": invalid identifier
SQL> -- correct column name, without double quotes (works)
SQL> insert into mytable(col1) values ('abc')
1 row created.
SQL> -- correct column name, with double quotes (fails)
SQL> insert into mytable("col1") values ('abc')
insert into mytable("col1") values ('abc')
Error at line 18
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 11
ORA-00904: "col1": invalid identifier
The last failed insert attempt is what I think you may be doing:
insert into mytable("col1") values ...
based on the error message:
ORA-00904: "col1": invalid identifier
So the solution would simply be remove the double quoting around the column name in the insert.
It's most probably a syntax error
Desc myTable;
insert into myTable (col1) Values ('val1')
Ensure col1 is a valid column in the table, and you're simply not trying to say 'select the left-most column.
edit: Is it possible to only insert values into certain columns when executing an insert statement in Oracle?
Yes if you want to only insert into certain columns then simply specify it
e.g.
insert into myTable (col1, col2, col6) Values ('val1', 'val2', 'val3');
This will only work if the column itself doesn't have a NOT NULL constraint - in which case it will not allow a value to be enetered (unless again there's a default value).

Resources