Procedural Language/Structured Query Language is Oracle Corporation's procedural language extension for SQL. Questions about PL/SQL should probably be tagged "oracle" as well.
0
votes
0answers
36 views
Oracle PL SQL EXTREMEMLY slow FETCH performance
I have a stored procedure that includes (among many other things) a dynamic query with a LOOP and a FETCH. The fetch has to potential retrieve a large amount of data as one column contains spatial ...
0
votes
0answers
27 views
Passing parameters to a procedure executed by DBMS_SCHEDULER
I have a scheduler program that runs a stored procedure that requires input parameters.
BEGIN
DBMS_SCHEDULER.DROP_PROGRAM
(program_name => 'MYSCHEMA.EXPORT_SCHEMA_STARTING');
END;
...
0
votes
1answer
27 views
I have a trigger that is giving me following error: *
CREATE OR REPLACE TRIGGER "TRANSACTION"
before
update of totalunitsbought on SIPHOLDER referencing new AS NEW old AS OLD
for each row
begin
declare
mportfolioname varchar2(20);
...
1
vote
1answer
32 views
Testing AFTER INSERT Trigger
I have the following table:
CREATE TABLE Train(
Train_No integer PRIMARY KEY,
Loco_No integer REFERENCES Locomotive(Loco_No),
Back_Loco_No float REFERENCES Locomotive(Loco_No),
...
0
votes
1answer
19 views
Migration of SQL Server to Oracle Database
In Sql server, My Procedure will create temporary tables where column names are dynamically comes from every user, then inserts the data into the temporary tables and i use the data further based on ...
0
votes
1answer
39 views
Combine multiple queries into single query
I am trying to run the following query:
SELECT Freight.Freight_No,
Freight.Available,
Locomotive.Loco_No,
Locomotive.Available,
Driver.Driver_No,
Driver.Name,
...
0
votes
1answer
27 views
Is the data fetched by an explicit cursor immutable in PL/SQL?
This seems like an obvious question, but Googling has so far failed me...
Say I have a view which delineates updates that I need to apply and, to this end, I have an SP that opens the view as a ...
0
votes
1answer
25 views
Dynamic where condition in a stored procedure
I am using Oracle 11g. I am trying to get the table data with this procedure:
CREATE OR REPLACE PROCEDURE test(p_table IN varchar2)
IS
v_sqltxt varchar2(4000);
BEGIN
v_sqltxt:='select count(*) from ...
3
votes
0answers
27 views
PLSQL : DBMS Jobs - parallelization?
I am looping over a cursor and executing a stored procedure; how do I parallelize this process through dbms.jobs?
for rec in select column from table1
loop
execute stored_procedure( rec.column );
end ...
0
votes
0answers
21 views
Error PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
i've problem here. i wanna create a Stored procedure like below, but i encountered error PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records.
create or ...
0
votes
1answer
44 views
Oracle's UTL_FILE
I am learning Oracle pl/sql by myself.
I need to create a procedure that exports a table to a csv file. For that I am thinking of UTL_FILE.Is there any good book or a site to get me started? I did ...
2
votes
0answers
114 views
Transform XPath map into XML document using relational data
Background
Most modern databases have XML functions that can be used to extract data in an XML format. I want to avoid the task of manually calling XML functions to extract the data.
This problem ...
1
vote
1answer
18 views
double date conversion when adding partition
I want to create a procedure that adds new partition in a table partitioned by time. For this purpose I use following commands:
s_until := to_char(sysdate+1,' SYYYY-MM-DD HH24:MI:SS');
...
2
votes
1answer
114 views
Reset every Oracle sequence to the MAX value of its target table PK?
I finally got around to migrating from MySQL to Oracle and was pleasantly surprised just how well of a job the SQLDeveloper Migration tool did. It even took my AUTOINCREMENT fields and created ...
0
votes
1answer
50 views
PL/SQL for Updating 1 Column in Table A Where PK = a row in table B
Using an oracle DB, 11g r2, I need to write a pl/sql which updates one column in table A where the PK exists in table B, with commits ever ~50,00 rows.
3200000 rows are involved in the update, and ...
0
votes
1answer
50 views
Invalid rowid error
I'm trying to see, how UPDATE Lock helps to minimize error while dml (delete/update) operations.
declare
cursor update_lock is select empno from emp where deptno=&no for update of sal;
num ...
0
votes
2answers
63 views
PLSQL: BEFORE INSERT Trigger
I am attempting to write my first trigger statement. I am trying to create a trigger that performs a SELECT to get my MAX_TOW_WEIGHT for a LOCO_CLASS, then compare that weight to the TRAIN_WEIGHT. If ...
2
votes
2answers
180 views
Why can't we write ddl statement directly into the PL/SQL block
Why can't we write ddl statements directly in PL/SQL block, for example when i write
CREATE OR REPLACE PROCEDURE test IS
BEGIN
truncate table table_name; // error
END test;
/
But,
CREATE OR ...
2
votes
2answers
77 views
DB2 UPDATE TRIGGER
I am trying to create a trigger in a DB2 database that runs on the update of a column in one table, and then fills in another table with certain values.
For example, there is a power unit table with ...
1
vote
1answer
84 views
need to use PLSQL to insert distinct rows
I need to take some data from Table A, use some logic, and then insert one or more rows into Table B. I have a PLSQL block that brings in data from Table A with a cursor, performs all the logic ...
2
votes
1answer
230 views
how to create and insert into a table in an anonymous block
I have PL/SQL anonymous block that creates a table (using execute immediate) and then inserts data into the table.
When the block compiles, it gives me an ORA-00942: table or view does not exist ...
0
votes
0answers
48 views
Designing ERD1 and ERD2 with crows foot [closed]
What would be the perfect ERD1 & ERD2 for the following case study? And what are the attributes of the entities?
Five Aside Football Independent League (FAFIL)
The Five Aside Football ...
1
vote
2answers
110 views
Oracle insert max from two date
I want to create an insert statement in a PL/SQL Script that inserts the larger of two different values. Conceptually, what I want to do is something like
Insert into MYTABLE (DATE_INSERT)
VALUE ...
0
votes
0answers
174 views
12154 error when using PL/SQL Developer
I have installed a few versions of Oracle on my machine. I have tried 64 bit and 32 bit versions. I have installed 11G. I need Oracle 10G 32 bit.
Using the following guide I removed all versions of ...
2
votes
1answer
83 views
Oracle Packages, Procedures and Functions Not Respecting Roles
When you create a package, sproc or function in one schema (say, SCHEMA1) that accesses objects in another schema (SCHEMA2), even when SCHEMA1 has appropriate permissions to the respective SCHEMA2 ...
6
votes
1answer
218 views
Package state not re-intialized on raise_application_error
When a package has state and the header is changed, the first call gets an error stack something like this:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of ...
3
votes
2answers
80 views
Is there a bug with PL/Scope in combination with associative arrays?
I believe I stumbled upon a bug with PL/Scope in combination with associative arrays, but perhaps I overlook something.
I have the following package
create or replace package tq84_pkg_c as
...
3
votes
1answer
368 views
halt on error in a sqlplus script
I am deploying pl/sql code using several sql files that are called with @@file.
If a package got a compilation error the script continues to the end.
Is there a way to stop on every compilation ...
2
votes
1answer
172 views
How to check parameter value existence in a procedure?
The following is a procedure that uses 2 parameters: customer_code and pay_amount. The procedure works as expected, however when I enter wrong cus_code I get this error instead of my custom checking:
...
2
votes
1answer
164 views
How to speed up a query with a lot of subqueries
I have a query which uses a series of functions to return the status of each document for a loan.
SELECT loan_number,
borrower_name,
get_application_status(loan_number, ...
1
vote
1answer
155 views
DB stored procedures: how do they help increase security in web systems?
The usage of Oracle PL/SQL procedures for controlling data access is often emphasized in PL/SQL books and other sources as being more secure approach. I'v seen several systems where all business logic ...
1
vote
2answers
258 views
How to isolate general Oracle 10g issues through SQL
Background:
I've been working on a performance analysis on a system with major performance issues on a Oracle 10g server. Much of the SQL is badly written, or at least not written with performance in ...
0
votes
1answer
229 views
Massive update to Clob fields oracle 10g
I need to remove a string of characters from 2000+ clobs fields in oracle 10g. How would I do this in PL/SQL?
For example, in table t1 there is a clob field called VBase that needs to have the ...
2
votes
2answers
1k views
How to store single result in variable and reuse it in a query (Oracle)?
I have a query like
SELECT id FROM xyz WHERE ...;
which has a more or less complex WHERE clause and returns exactly one row with one column (ID). I need this ID for several later queries in a ...
0
votes
1answer
277 views
Find ID columns with null value in oracle database
I need a way to iterate through all tables in tablespace "T_ECOS" and find all ID with null value in oracle database
Any suggestion?
2
votes
1answer
75 views
PLSQL Package - Catching Errors in procedure (Oracle)
I have a problem with my package (and procedure) not catching exceptions.
I have the below code:
CREATE OR REPLACE PACKAGE process_orders
IS
PROCEDURE add_order (
order_num NUMBER,
...
3
votes
3answers
561 views
Using the same sequence twice in a PL/SQL statement
I wrote the snippet of PL/SQL today:
declare
first_id number;
second_id number;
begin
insert into table (sort_nr, text_id, unit_id) values(...,
table_seq.nextval, table_seq.nextval) returning ...
5
votes
3answers
1k views
Why use explicit cursors instead of regular loops?
I've been writing basic web apps for a year (for an Oracle db), and since the functions are pretty simple, most of us stick with regular FOR loops to get our data:
for i in (select * from STUDENTS) ...
2
votes
0answers
261 views
Where can I find a syntax reference for Oracle SQL Developer's “Generate DB Doc” function?
Oracle SQL Developer (I'm using v3.2) has a feature called "DB Doc", which generates documentation for database objects. I mostly want to use it to generate documentation for my stored procedures, ...
0
votes
3answers
253 views
ORA-01562: failed to extend rollback segment number 11
I´m trying to execute this query into a SP
DELETE FROM table SC
WHERE SC.evaluationMonth= 'Some month';
COMMIT;
But for this month there are something like 10 million records. So I get the ...
0
votes
1answer
473 views
Oracle: Output not shown even if SERVEROUTPUT variable set to ON
I was wondering why the output is not being shown even if I set the SERVEROUPUT variable to ON.
I have the following annonymous block code:
DECLARE
v_rec_count number:=0;
BEGIN
for rec in ...
1
vote
0answers
237 views
How can one reliably update a LOB column with data from another LOB column in Oracle?
I have tried:
UPDATE "SCHEMA".TABLE SET LOB_COLUMN = (SELECT LOB_COLUMN FROM "SCHEMA".TABLE)
I have tried:
CREATE OR REPLACE PROCEDURE COPY_LOB_DATA IS
OLD_BLOB BLOB;
NEW_BLOB BLOB;
...
0
votes
1answer
584 views
Split CLOB into multiple VARCHAR2
I currently am working with some data that is being stored as a CLOB between 4000 and 6000 characters. I would like to perform the TRANSLATE function on it but I learned that it's not possible with a ...
6
votes
3answers
259 views
How can I ensure that only one copy of a procedure is running in Oracle?
We have the need to ensure that only one copy of a particular procedure is running in Oracle. If it is already running and a user tries to open another, then it should error.
Whats the best method ...
4
votes
2answers
1k views
How do I use the IF…ELSE condition in a WHERE clause?
I'm attempting to use the IF...ELSE construct in my WHERE clause to selectively apply conditions to my SELECT.
Should this work?
CREATE OR REPLACE package body If_Else_Pack IS
PROCEDURE Moving
...
3
votes
1answer
556 views
How far should bind variables go in Oracle?
I am currently examining all database users's SQL code in our department for not using bind variables. We do experience an ORA-04031 error within a constant period of time.
Now, I have a quite firm ...
3
votes
2answers
295 views
FORALL on Nested Collections
Suppose I have the following two tables in my Oracle database:
create table a (num number);
create table b (val varchar2(30);
and in my PL/SQL program I have declared a nested collection as ...
5
votes
1answer
81 views
Retrieve Indices of Associative Array as Collection
In PL/SQL, suppose I have some associative array defined as follows:
declare
type a_arr_t is table of PLS_INTEGER index by PLS_INTEGER;
a_arr a_arr_t;
I then, sparsely, populate the ...
2
votes
2answers
678 views
Dynamic access to record column in plpgsql function
How can I address a column from a record in a plpgsql function dynamically?
In the following snippet I have access to a variable entity.colname that contains the column that should be checked in the ...
0
votes
1answer
1k views
Why does dbms_scheduler max_run_duration not raise event JOB_OVER_MAX_DUR?
Starting from this question and this example I've tried to create an event based dbms_scheduler job, which waits for event JOB_OVER_MAX_DUR raised from jobs, which exceeded their max_run_duration.
...