Cannot create multi-column text index in Oracle - oracle

I'm trying to create a multi-column full-text index in Oracle but can't get it working. Here's what I have so far:
CREATE TABLE DOCS (
DOCS_ID NUMBER(32,0) NOT NULL,
COLA NVARCHAR2(100),
COLB NVARCHAR2(100),
COLC NVARCHAR2(100)
);
CALL ctx_ddl.create_preference('DOCS_MC_DATASTORE', 'MULTI_COLUMN_DATASTORE');
CALL ctx_ddl.set_attribute('DOCS_MC_DATASTORE', 'COLUMNS', 'COLA, COLB, COLC');
CREATE INDEX DOCSINDEX ON DOCS(COLA) INDEXTYPE IS ctxsys.context parameters ('DATASTORE DOCS_MC_DATASTORE sync(on commit)');
This return the following errors:
SQL Error [29855] [99999]: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000: Oracle Text error:
DRG-11135: feature not generally available
ORA-06512: at "CTXSYS.DRUE", line 186
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 338
Update
Ignore the multi-column issue, can't even get the index to work:
CREATE INDEX DOCSINDEX ON DOCS(COLA) INDEXTYPE IS ctxsys.context;
Reports the exact same error. This is Oracle Express 21. Do I need to add something to the install?

In case anyone finds this. Can't use text indexing with Unicode NVARCHAR/NCHAR/NCLOB.

Related

How can i get partitioned script using get_ddl?

I am using Oracle 12c as database and getting ddl of table or other objects using :-
dbms_metadata.get_ddl('TABLE','TABLE_NAME','SCHEMA_NAME');
Same as for constraints and reference constraint i am using :-
dbms_metadata.get_dependent_ddl('CONSTRAINT','TABLE_NAME','SCHEMA_NAME');
dbms_metadata.get_dependent_ddl('REF_CONSTRAINT','TABLE_NAME','SCHEMA_NAME');
Now my problem is i want to extract partition script from table and i tried following :-
select dbms_metadata.get_dependent_ddl('PARTITIONING','TABLE_NAME','SCHEMA_NAME') from dual;
but its giving the following error :-
ORA-31600: invalid input value PARTITIONING for parameter OBJECT_TYPE in function GET_DEPENDENT_DDL
ORA-06512: at "SYS.DBMS_METADATA", line 6069
ORA-06512: at "SYS.DBMS_METADATA", line 8761
ORA-06512: at line 1
31600. 00000 - "invalid input value %s for parameter %s in function %s"
*Cause: A NULL or invalid value was supplied for the parameter.
*Action: Correct the input value and try the call again.
I have also tried :-
select dbms_metadata.get_ddl('PARTITION','PARTITION_NAME','SECONDARYUSER') from dual;
but its giving same error.
Please suggest how can i get partitioned ddl using get_ddl method in oracle.
Partitioning is a table option, not a separate object. By default, GET_DDL for a table should produce the partitioning information. If it doesn't, it's possible you have a session transformation that's disabling it. These two statements should definitely generate a DDL script that includes all the partitioning options:
begin
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'PARTITIONING',true);
end;
/
select dbms_metadata.get_ddl('TABLE','TABLE_NAME','SCHEMA_NAME') from dual;
If you're looking for a way to automatically generate a script that converts a table from nonpartitioned to partitioned, I'm afraid you're out of luck. Although 12c has the ability to convert tables with ALTER TABLE, the package DBMS_METADATA_DIFF apparently has not yet been updated to understand those commands.
For example, if you create the same table with and without partitions, this script doesn't work:
select dbms_metadata_diff.compare_alter(object_type => 'TABLE', name1 => 'TABLE2', name2 => 'TABLE1') diffs from dual;
DIFFS
--------------------------------------------------------------
-- ORA-39266: Cannot alter unpartitioned table to partitioned.
ALTER TABLE "JHELLER"."TABLE2" RENAME TO "TABLE1"
Luckily, in some cases the ALTER syntax seems easy. In my simple examples, I could change a table to partitioned with a command like this:
alter table unpartitioned_table modify
[partitioning clause]
online;
Try this to filter transformation option :-
BEGIN
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true);
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true);
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SEGMENT_ATTRIBUTES', false);
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'STORAGE', false);
END;
/
SELECT DBMS_METADATA.get_ddl ('TABLE', table_name, owner)
FROM all_tables
WHERE owner = UPPER('REFDATA')
AND table_name = DECODE(UPPER('<TBL_NM>'), 'ALL', table_name, UPPER('<TBL_NM>'));
This should give only the default partition along with table ddl.

oracle cannot insert values into a nested table field

I have the sample CUSTOMERS table.
I exported the values from table as INSERT script.
I took one row, modified the value from PK and re-executed the insert.
Insert into oe.customers (CUSTOMER_ID,
CUST_FIRST_NAME,
CUST_LAST_NAME,
CUST_ADDRESS,
PHONE_NUMBERS,
NLS_LANGUAGE,
NLS_TERRITORY,
CREDIT_LIMIT,
CUST_EMAIL,
ACCOUNT_MGR_ID,
CUST_GEO_LOCATION,
DATE_OF_BIRTH,
MARITAL_STATUS,
GENDER,
INCOME_LEVEL,
CREDIT_CARDS)
values ( oe.customer_seq.nextval,
'Donald',
'Hunter',
OE.CUST_ADDRESS_TYP('5122 Sinclair Ln','21206','Baltimore','MD','US'),
OE.PHONE_LIST_TYP('+1 410 123 4795'),
'us',
'AMERICA',
2600,
'Donald.Hunter#CHACHALACA.EXAMPLE.COM',
145,
MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(-76.545732,39.322775,NULL),NULL,NULL),
to_date('20-JAN-60','DD-MON-RR'),
'married',
'M',
'G: 130,000 - 149,999',
OE.TYP_CR_CARD_NST(OE.TYP_CR_CARD('Visa',100000000000011)));
and I have the following error message:
Error at Command Line : 32 Column : 29 Error report - SQL Error:
ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
which refers to line:
OE.TYP_CR_CARD_NST(OE.TYP_CR_CARD('Visa',100000000000011)));
The definition of types are:
create or replace type typ_cr_card as object
( card_type VARCHAR2(25)
, card_num NUMBER);
create or replace type typ_cr_card_nst as table of typ_cr_card;
Can someone tell me, please, what is wrong with this insert line as it is the one provided by SQL DEVELOPER?
NOTE: Also, I tried to use a procedure which inserts values in this table and the error refers to TYP_CR_CARD_NST datatype.

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).

The mystic getClobVal()

I have a table (AKADMIN) with an XMLTYPE column which name is XML.
I would like to use the getClobVal() with this column.
select t.xml.getClobVal() /**/
, t.xml.getClobVal() --
, t.xml.getClobVal() as clobval
, t.xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
In the resultset the first 4 column give CLOB type, but the fifth column XMLTYPE. I have to type any comment or alias after getClobVal() to correct (CLOB) type of the result. Why?
Another issue, when I leave the alias of tablename:
select xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
It throws an ORA-00904 string: invalid identifier
Hmmm...
Does anybody have any idea?
Addition info about environment:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0;
PL/SQL Developer 10.0.5.1710
But a tried this in our Java apllication via OJDBC6 with same results
You should put xml in a brackets:
select (xml).getClobVal() from akadmin;
works for me

Can not delete Metadata entry in Spatial DB

I am trying to a spatial data table in my db using :
CREATE TABLE building (buildid VARCHAR(15) PRIMARY KEY, buildname VARCHAR(50),numpoint NUMBER,points SDO_GEOMETRY);
CREATE INDEX building_spatial_idx ON building(points) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
INSERT INTO USER_SDO_GEOM_METADATA(TABLE_NAME,COLUMN_NAME,DIMINFO,SRID)
VALUES (
'building',
'points',
SDO_DIM_ARRAY( --820*580 grid
SDO_DIM_ELEMENT('X', 0, 820, 1),
SDO_DIM_ELEMENT('Y', 0, 580, 1)
),
NULL --SRID
);
When I executed it for the first time it did not give any errors but afterwords it is giving error
insert into user_sdo_geom_metadata values
*
ERROR at line 1:
ORA-00001: unique constraint (MDSYS.UNIQUE_LAYERS) violated
ORA-06512: at "MDSYS.SDO_GEOM_TRIG_INS1", line 27
ORA-04088: error during execution of trigger 'MDSYS.SDO_GEOM_TRIG_INS1'
Is it happening because am trying to give meta-data for same table again.
Or is there any other reason. How can i delete all the index,metadata,table at a single go and remove this error.
A new Schema creation solved the problem,

Resources