PL/SQL: Check if there is sufficient space in schema before creating table

mlader

I'm using a procedure which creates a table using a heavy query (running ~1 hr). Query is something like 'select * from table', and the columns in the table can change. Oftentimes it turns out that there is no free space in schema to create the table, so I get an exception, the time is spent in vain and I need to do the same calculations once again.

The error I get:

ORA-01536: space quota exceeded for tablespace ORA-06512: at "UPDATE_REPORT", line 37

What I would want to do: - Store query's results in temporary segment in a cursor; - Try to create table using cursor. In case of exception (not enough space), drop a special space-holding table to free table space in schema; - Try to create the table again from cursor.

I tried to solve this using dynamic SQL, but it leads to overcomplications while the problem seems to have a simple solution. And the main problem I faced is that there is no evident way to create a table using cursor.

Is there any simple solution I somehow missed out? Maybe cursor are the wrong way to work this out?

Matthew McPeak

What I would want to do: - Store query's results in temporary segment in a cursor; - Try to create table using cursor. In case of exception (not enough space), drop a special space-holding table to free table space in schema; - Try to create the table again from cursor.

Don't go through the trouble. Just tell Oracle not to die because of space issues.

You can make your session "resumable" so that, rather than giving you an error when you run out of space, Oracle will suspend your session until the problem is corrected (and then continue on automatically).

Assuming you have all the permissions you need (notably, GRANT RESUMABLE TO yourschema), you enable it like this:

alter session enable resumable timeout 1800 name 'your process name, can be anything';

The 1800 number is in seconds, giving your DBA's 30 minutes to fix the problem before your session times out. The "my process" will show up in V$RESUMABLE for use in queries and automated alerts.

Your DBAs can monitor V$RESUMABLE and/or you can create a schema-level database trigger on the AFTER SUSPEND event to fire off an e-mail to them when they need to jump in.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CREATE ANY TABLE not sufficient for creating any table?

From Dev

How to check if a database exists before creating a table?

From Dev

How to check if the table is displayed before calling a function creating the table - JavaScript

From Dev

how to to first check whether the table exist or not before creating it in postgresql?

From Dev

Check the existence of statistic with same columns before creating a statistic on a SQL table

From Dev

mysql - check before creating

From Dev

plsql get table in 'before alter' trigger

From Dev

Check if OU exists before creating it

From Dev

To check table schema change in snowflake

From Dev

Flask-SQLAlchemy creating schema before creating tables

From Dev

How to check if a PaymentMethod is valid or has sufficient funds before attempting to charge a Customer?

From Dev

space before a table ONLY IF the table is printed

From Dev

postgres: schema does not exist when creating a table

From Dev

Creating a table in BigQuery using the PHP api with schema

From Dev

SaveFileDialog check free space before closing window

From Dev

check if space is before and after a string, to remove the string

From Dev

Sqlite check condition on creating table

From Dev

How to check if a folder exists before creating it in laravel?

From Dev

Terraform check if resource exists before creating it

From

How to check if a stored procedure exists before creating it

From Dev

R : Check if R object exists before creating it

From Dev

Check MySql credentials before creating tables

From Dev

Dynamically creating schema.sql before Spring context

From

How to check if a table exists in a given schema

From Dev

T-SQL Check if table exists in schema

From Dev

how to validate employee age that it must me greater than 18 before inserting record(tiried using check constraint while creating table but not work)

From Dev

Check Table Exist Before Create Table On FluentMigrator

From Dev

Rules to be followed before creating a Hive partitioned table

From Mysql

Hibernate trying to alter table before creating it

Related Related

  1. 1

    CREATE ANY TABLE not sufficient for creating any table?

  2. 2

    How to check if a database exists before creating a table?

  3. 3

    How to check if the table is displayed before calling a function creating the table - JavaScript

  4. 4

    how to to first check whether the table exist or not before creating it in postgresql?

  5. 5

    Check the existence of statistic with same columns before creating a statistic on a SQL table

  6. 6

    mysql - check before creating

  7. 7

    plsql get table in 'before alter' trigger

  8. 8

    Check if OU exists before creating it

  9. 9

    To check table schema change in snowflake

  10. 10

    Flask-SQLAlchemy creating schema before creating tables

  11. 11

    How to check if a PaymentMethod is valid or has sufficient funds before attempting to charge a Customer?

  12. 12

    space before a table ONLY IF the table is printed

  13. 13

    postgres: schema does not exist when creating a table

  14. 14

    Creating a table in BigQuery using the PHP api with schema

  15. 15

    SaveFileDialog check free space before closing window

  16. 16

    check if space is before and after a string, to remove the string

  17. 17

    Sqlite check condition on creating table

  18. 18

    How to check if a folder exists before creating it in laravel?

  19. 19

    Terraform check if resource exists before creating it

  20. 20

    How to check if a stored procedure exists before creating it

  21. 21

    R : Check if R object exists before creating it

  22. 22

    Check MySql credentials before creating tables

  23. 23

    Dynamically creating schema.sql before Spring context

  24. 24

    How to check if a table exists in a given schema

  25. 25

    T-SQL Check if table exists in schema

  26. 26

    how to validate employee age that it must me greater than 18 before inserting record(tiried using check constraint while creating table but not work)

  27. 27

    Check Table Exist Before Create Table On FluentMigrator

  28. 28

    Rules to be followed before creating a Hive partitioned table

  29. 29

    Hibernate trying to alter table before creating it

HotTag

Archive