I want to create an text index for a single column for a table using this command:
CREATE INDEX product_fulltext_index
ON products( computed_name )
INDEXTYPE IS ctxsys.context
I tried to search but I have not found the solution yet, maybe the error message is too vague
This is my table design:
Error screenshot suggests that you're trying to create index on name column. Text of your question says that column name is computed_name. So, which one of them is it, really?
Anyway: if it is on
name Nvarchar2(500)
^
|
then you can't do what you want because you can't create Oracle Text index on a column whose datatype uses the National Character set (NVARCHAR2). Why not? Because Oracle doesn't support it.
Either change column's datatype to e.g. VARCHAR2, or accept the fact that you can't have what you wanted.
Related
I imported a Excel spreadsheet into Apex 20.1. Several of my columns were formatted as currency eg. $30 but they've all been imported as varchar. Many of the cells were empty so maybe that's why it didn't automatically recognise the column type.
There didn't seem to be a way to alter the table definition before it loaded the data either.
To change it back to a numeric type ( ? float ), do I need to add another column, import the data from the original column recast as float, delete the first column and then rename the new column back to the original name?
I also want to truncate some varchar(4000) down to varchar(100) but that's another question.
If column looked exactly like $30, then yes - it is a string, not a number, so Oracle created a VARCHAR2 column. If you removed formatting in Excel before doing anything with Apex, it would have been a NUMBER.
Now, yes - as you said:
create a new column
update table and set new column to numeric value of the old column
drop the old column
rename new column to the "old/original" name
Or, alternatively (from point #3)
empty the old column
modify its datatype
move data back into it
drop the new column
As of truncating varchar2(4000) column to (100): first shorten its contents to 100 characters, then modify its datatype:
update your_table set that_column = substr(that_column, 1, 100);
alter your_table modify that_column varchar2(100);
Because of such problems, I prefer to
precreate the target table (using create table command), specifying each column's datatype as I want it to be
load file contents into such a table
I've created a simple table in Oracle 12c like so:
CREATE TABLE TEST
(
ID NUMBER GENERATED ALWAYS AS IDENTITY,
TEXT VARCHAR2(2000 CHAR),
CONSTRAINT ID_PK PRIMARY KEY (ID)
);
Then I linked it in MS Access using ODBC driver. The problem is that when I input value into TEXT and click away both ID and TEXT show #Deleted. My value gets recorded in the database but I have to requery in MS Access in order to see it.
I also noticed that if I change the datatype of TEXT field to NUMBER, it works fine. After saving the record in MS Access both auto generated ID and value in TEXT field are there. I don't have to requery anything.
This happens only when inserting. Updating works just fine.
Please advise.
So, it would appear you already found the solution, but this is more of an explanation as to why it works that way. Simply speaking, if the base-table uses non-integer values as primary keys, Access rounds these integers to the nearest whole number and then (since it was not a numeric value) Access can no longer find the applicable records. So, changing the data type from TEXT to INTEGER in the table structure would give you your desired result.
Alternatively, if you're using a query to run through these, if you cannot change the keys in the Oracle table then altering the Access query type to a snapshot (in the query properties) will also bypass this problem. But from the sounds of it, this is not how you are utilizing the data.
In my case, the Oracle ODBC driver (using the rather old version 11.02.00.01 that otherwise works ok and Microsoft Access 2016 32Bit) seems to use the unique indices and not the primary key constraint for determining the primary key.
I had a field with NUMBER(11) as PK with an unique index, then added a VARCHAR2 field with another unique index. The name of the index of the VARCHAR2 field was alphabetically before that of the NUMBER field.
Now, the linked table in Microsoft Access showed the VARCHAR2 field as primary key and I had the problem with '#Deleted' appearing after entering & saving a record as you describe.
After renaming the unique index on the NUMBER field in Oracle to be alphabetically before that of the VARCHAR2 field and re-linking the table in Microsoft Acces, the NUMBER field was the primary key again in Microsoft Access and the '#Deleted' problem was solved.
I have created an interactive report in oracle apex 5.1 in which I have 4 columns. One of those columns is blob column named as doc_pic. I made it download blob type column and fill all the requirements, IE: MIME type, file name, last updated, primary key 1 according to the view from where it belong.
In that view I have multiple tables and most of them contain composite primary key which is based on number and varchar2 columns. The problem is when I run the page it gives me no data found error but when I hide that column report is running fine.
I tried created it by making unique id through rownum but still it is giving the same error.
I also tried to make a unique column by concatenating it with another column which is varchar2 but, then it gave me error
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
Somebody please tell me where I am going wrong in creating a download blob link. Thanks in advance.
You shouldn't use the BLOB column directly in IR's query. Instead of it, use this:
select column_list_here,
dbms_lob.getlength(doc_pic) doc_pic --> this
from your_table
...
The rest should be easy.
im trying to add a new column to my existing table 'Results', and it seems to be very easy but I cant see the mistake.
Here is my code:
SQL> Alter table results add column CAL ENUM('A','B');
ERROR at line 1: ORA-00904: : invalid identifier
What am I missing?
I've read this from w3 and this from java2s but cant see the difference to mine.
Thanks, and sorry for the dumb question.
OK, with an ORA- error I am assuming that this is an oracle database, and not mysql. you have both tags and you are linking to MySQL example, but the error is not a MySQL error.
Assuming that this IS an Oracle DB, then there is no native ENUM data type. You have to do this as follows: First - you add the column with a correctly defined data type, and second you create a constrained list of permitted values on that column as a check constraint.
Alter table results add (cal varchar2(1));
Alter table results add constraint chk_cal CHECK (cal in ('A','B')) ENABLE;
(EDITED to fix brackets in constraint creation line)
I created a table and one of the columns is address. I then created a view with a WHERE CONTAINS clause that states select can only be performed on address that contain a specific word.
I then created an index of the address column on the original table.
It says index created.
When I type
select * from myview
It says
drg-10599: column is not indexed.
Any idea why this isn't working?
You would need to create an Oracle Text index, not a standard b-tree index. There are quite a few options for creating and maintaining Oracle Text indexes that you should really read through in order to figure out exactly what options you want to use.
The simplest possible DDL statement would be
CREATE INDEX myindex ON table_a(address)
INDEXTYPE IS CTXSYS.CONTEXT;