Impossible to create trigger in a table with a reserved name in Oracle - oracle

I have a table named BLOB, and I can select, update, insert normally via SQL, but it's impossible to define a trigger for it, obviously the cause is the name.
In PL/SQL as a procedure, I work around the problem by creating a view which selects all the columns of the table, and using it in the body but it doesn't work on the table itself.
Does anyone have a solution? I cannot rename the table. Also using a synonym is out.
Structure of the table:
CREATE TABLE BLOB
(
BLOBID CHAR(7 BYTE) NOT NULL,
OGGETTO BLOB
)
The problem is related to the presence of a column of type BLOB in a table named BLOB, but only in PL/SQL environment (procs, triggers, ...)

Related

Creating a Cross-Schema Spatial Index in Oracle impossible with single user?

The oracle documentation here:
https://docs.oracle.com/en/database/oracle/oracle-database/21/spatl/indexing-querying-spatial-data.html#GUID-8E6AE949-758B-4A5E-9453-CC3D00647497
Talks about creating an index in schema A with user B
CREATE INDEX t1_spatial_idx on A.T1(geometry) INDEXTYPE IS mdsys.spatial_index_v2;
This, however, requires you to insert into user_sdo_geom_metadata. I'm trying to do this as one single connected user and that seems impossible. Let's say I'm user B, whenever I insert into user_sdo_geom_metadata the resulting changes won't get picked up by the view that the CREATE INDEX statement uses, which is ALL_SDO_GEMO_METADATA. As an example try:
INSERT INTO user_sdo_geom_metadata (table_name,column_name,diminfo,srid) VALUES
('T1','geometry', sdo_dim_array(sdo_dim_element('X',-180.0,180.0, 0.005),sdo_dim_element('Y',-90.0,90.0, 0.005)), 4326);
There is no way to specify the schema to get this into the correct format. In fact, if the T1 table here doesn't exist in your schema then nothing appears in ALL_SDO_GEMO_METADATA. I've tried
ALTER SESSION SET CURRENT_SCHEMA = 'A'
But that doesn't work. I'm trying to use Schemas as a way of collating together self-contained groupings of tables, views, indexes, etc. like you would in a normal database. In other words, I'm trying to use them like actual schemas. Oracle makes this challenging at the best of times, and I don't want to manage separate logins for each schema, but I can't see how it's possible to do this for spatial indexes.
Well, this was an epic struggle but got there in the end. The only way to create the metadata AND the index as another user is to create a stored procedure that does the INSERT but it's not as easy as just following the instructions, you have to call the package proc directly like so:
CREATE OR REPLACE PROCEDURE "<user name>".ADDMETADATA(
schema_name VARCHAR2, table_name VARCHAR2, column_name VARCHAR2, srid NUMBER, bounds MDSYS.SDO_DIM_ARRAY)
IS
BEGIN
mdsys.sdo_meta.insert_all_sdo_geom_metadata(schema_name, table_name, column_name, bounds, srid);
END ADDMETADATA;
Which almost certainly isn't supported but the standard way is broken so you have to. You then need to create this in every single new schema along with giving the schema user CREATE TABLE and CREATE SEQUENCE permissions. So to create a schema programmatically and have it all work boils down to the following steps:
CREATE the Schema/User and set the tablespace
GRANT CREATE SEQUENCE to the Schema/User
GRANT CREATE TABLE to the Schema/User
ALTER the quota on the TABLESPACE for the Schema/User
CREATE the stored proc above
CALL the stored proc
CALL create INDEX
Painfully long-winded but works. The whole schema-as-user thing remains a terrible idea, most databases can do all this with one SQL statement.

After adding index global temporary table data will not get fetched

Need some help to identify the reason for the below issue.
I have created a global temporary table as below:
Create global temporary table glo_temp_table
(
row_no NUMBER not null,
resource_id VARCHAR2(40),
company_id VARCHAR2(20),
);
This table’s data gets inserted during the runtime by a function which later used by a another function to fetch data using a cursor. This functionally works fine without any issue. Problem starts when I add an index below (to clear this is not done during the run time.):
CREATE INDEX SS ON glo_temp_table (resource_id);
Now no data will gets fetched by the cursor. Is there any specific reason for this behavior? How can I created a such a index to work properly?
Oracle db veriosn is 12c Release 12.1.0.1.0
This table only has the below constrain only.
alter table glo_temp_table
add constraint glo_temp_table_PK primary key (ROW_NO);

Moving dependencies (PK, FK and indexes) from one table to another within the same database in Oracle

Please tell me how can I move dependencies (such as PK, FK and indexes) from one table to another within the same database in Oracle? The second table is a copy of the first, only created later for partition reasons. Thank you in advance! :)
You could look at using the dictionary views in oracle, specifically the USER_CONSTRAINTS view. Then either construct a SQL statement dynamically or use DBMS_METADATA.get_ddl procedure to get the ddl for the constraint. You could do a REPLACE on the SQL to replace the original table name and constraint name with a new constraint name and the name of the new table.

OOP concepts in oracle 11.g

i have a question related to Object Orienting programming in oracle database(11.g),generally i have studyed how to create object types or how to create table from existing object,but i am stoped on one topic,namely,suppose that we have created following type
create or replace type mono.Item_type as object(
item_id integer,
part REF mono.Part_type,
quantity integer);
where Part_type is already existed object type.
i know that i can create table from this object like this:
create table tablename of Item_type,for instance
create table item_list of Item_type
what what would be different,if instead of this,we use
create or replace type mono.Item_List as table of Item_type;
here inspite of this,that we use type keyword,we are creating table again and what is different between create table tablename of Item_type and
create or replace type mono.Item_List as table of Item_type;?
When you use create table tablename of Item_type, you're creating a table in the DB.
This table is a structure that can be used to store user's data .
When you use create or replace type mono.Item_List as table you're defining a new Datatype (similar to array).
This Datatype can be used as a type of a column in a DB table or as a type of a variable in plsql code.

ORACLE PL/SQL - SCHEDULE CREATE TABLE

I need to create a table every morning based on overnight generated data from a massive table. This will then be accessed by a handful of users form Excel.
My initial approach was to use a materilazed view and when this was rejected (for political reasons) to used Managed XLL but this was rejected for other reasons. I don't want to get messed up with Temporary tables and so really just need to know how to schedule an Oracle Create Table statement as our DBA says it can't be done.
My faith in SO users sasy otherwise though!
I don't see why you have to create a new table every morning and not use an existing one?
This creates your table from PL/SQL. Is this what you want?
CREATE OR REPLACE PROCEDURE make_table AS
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE your_table ( column_1 INT PRIMARY KEY, column_2 VARCHAR2(10) )';
END make_table;
/
EXEC make_table;
Your user needs to have the necessary grants, grants given by role don't apply to compiled PL/SQL code.

Resources