Procedural Language/Structured Query Language is Oracle Corporation's procedural language extension for SQL. IBM supports PL/SQL for DB2 since version 9.7. Questions about PL/SQL should probably be tagged "oracle" or "db2" as well.

learn more… | top users | synonyms

2
votes
0answers
16 views

Procedure to update tables when the difference of values is less than 10% [on hold]

I use Oracle database. I have 2 tables. Table1 with the following details: Table-1 emp.no | salary 1 | 2000 2 | 3000 3 ...
0
votes
0answers
7 views

ALTER SESSION from a Control File

I am using a Control File to import data from a CSV file into a table, using sqlldr to import the data, where a large number of fields are numeric values with integer and decimal part separated by ...
1
vote
0answers
12 views

Whitespace Trimming on Before Trigger in PL/SQL [closed]

I'm looking to create a simple trigger that trims the whitespace on a piece of data prior to it writing to the table. I'm using PL/SQL with Oracle 11g. I am receiving the following error: ...
0
votes
1answer
38 views

Why is my PL/SQL procedure so slow?

I have this sub-procedure in a fairly large program, and it is taking hundreds of times longer than comparable sub-procedures. Is there any way I could improve efficiency here? None of this ...
0
votes
0answers
23 views

Getting milliseconds elapsed during a stored PL/SQL procedure

I've been using sysdate to time procedures, but a lot of my procedures are very small procedures that get called thousands of times. Is there a way to get milliseconds elapsed instead of seconds? I ...
-1
votes
0answers
29 views

Stored procedure - list of strings as an out variable. How do I do this? [migrated]

I have a pl/sql procedure that will be called from a web application. It needs to return a list of Strings. How would I do this? Oracle Database 11g Release 11.1.0.6.0 - Production PL/SQL Release ...
3
votes
2answers
76 views

Stored procedure using cursors [on hold]

I am attempting to create a procedure using cursors to list the average salary of all employees on a per department basis. I am using three tables, defined as emp (eid, ename, age, salary) works ...
0
votes
0answers
21 views

PL/SQL Triggers [migrated]

I am using these tables: flights (flno, origin, destination, distance, departs, arrives, price) aircraft (aid, aname, crusingrange) employees (eid, ename, salary) certified (eid,aid) and I need ...
0
votes
1answer
21 views

PLSQL - getting real-time updates

I want a PL/SQL procedure to give me progress updates as it runs. However, DBMS_OUTPUT seems only to give me the output when the whole procedure is done. Is there a way to make it give me updates ...
0
votes
0answers
25 views

(Oracle PL/SQL) How to capture multiple error lines in exception section?

begin some SQL...; exception send_SMS('SQL error: '||SQLERRM); end; This sometimes reports: ORA-02063: preceding line from DBLINK_NAME How to capture the preceding error lines in a PL/SQL ...
0
votes
0answers
18 views

Statement ignored - PL/SQL Procedure

create or replace PROCEDURE UNIQUE_MATCH ( PHYSICIANID IN NUMBER , FNAME IN VARCHAR2 , LNAME IN VARCHAR2 , POSTALCODE IN VARCHAR2 , SOURCETABLE IN VARCHAR2 ) AS ALREADY_HAS NUMBER; BEGIN ...
0
votes
3answers
46 views

Will an update in my trigger trigger itself? Oracle PLSQL

Here's my PLSQL trigger: CREATE OR REPLACE TRIGGER ROOT_CHANGING_TRG BEFORE UPDATE OF ROOT_ID,PARENT_PHYS_ID ON UNIQUE_PHYSICIAN FOR EACH ROW DECLARE var_root number := :new.ROOT_ID; var_par number ...
0
votes
0answers
23 views

ORA-00933: SQL command not properly ended from function

I created a function but I keep getting the errors ORA-00933: SQL command not properly ended ORA-06512: at "FCUBSPROD.FN_GSS_UNPROCESSED_TXNS", line 110 ORA-06512: at line 11 when I try to run it. ...
0
votes
0answers
36 views

Update a column in table only if a condition is met for number of values for a field in other table

I am trying to figure out how to achieve the following (This is simplified version that ignores non relevant columns) I have table "Item" with columns item_id business_key I have another table ...
0
votes
1answer
27 views

How to create scheduler for manually refresh Materialized View if the MV get need_compile stallness status

I've a problem to Automatically Refresh Materialized View, if the stallness condition is NEED_COMPILE / STALE / UNUSABLE OR NOT FRESH. I've MV with this PL/SQL : CREATE MATERIALIZED VIEW ...
1
vote
1answer
34 views

How to update table1 field by using other table and function

I have two tables and one function: Table1 contains shop_code,batch_id shop_code| batch_id | regstriy_id 123 | 100 | 12 124 | 100 |13 125 | 100 |12 Table2 contains shop_code,shop_name ...
0
votes
0answers
15 views

Creating objects containing collections of themselves

I'm creating a simple data structure using PL/SQL to help me work with some rows in tables which have dependencies upon each other. In short, I'd like to be able to create a graph using any ...
0
votes
1answer
62 views

PL/SQL recursive lookup with cursor

I basically have a need for recursing through data in my Oracle table so I can find related rows and send them out. It is a single table, a single ANSI SQL query seems not possible due to turin ...
0
votes
1answer
73 views

How to add a column from another table?

I'm starting to using SQL statements in my Oracle database XE (tables and relations made by me) and I'm having a hard time to understand how can I put a column from another table. The example in ...
0
votes
1answer
47 views

How to select data out of an Oracle collection/array?

Due to needing some complex data manipulation and not being able to use PHP, I crafted a procedure (not stored, it's just run when we run the query) in Oracle to manipulate the data and store it in an ...
6
votes
2answers
101 views

What is an Oracle ASSEMBLY?

What is an Oracle ASSEMBLY, in the context of Oracle SQL? It's listed in GV$SQLCOMMAND. Although GV$SQLCOMMAND is not a perfect guide to "real" SQL statements - for example it has UPSERT instead of ...
1
vote
0answers
38 views

SQL - Optimize table population with dynamic queries

I need to optimize the following pl/sql procedure. So, fundamentally my question is: There is a way you can do a bulk insert in a pl/sql that could be more efficient than loop through an associative ...
-2
votes
1answer
47 views

Single-row subquery returns more than one row

I try to run the follwoing query but it gives me 'Single-row subquery returns more than one row' error. BEGIN FOR C2 IN (SELECT S.bom_header, S.sap_cage_cd, ...
1
vote
0answers
90 views

Clarification on usage of Serially Reusable Pragma for Oracle 10g

I need to make packages for Oracle 10g that can be changed while users are still logged in an using an application that makes database calls through PL/SQL. Unfortunately, anytime a package is updated ...
0
votes
2answers
70 views

Duplicate data in a table given table name

For a performance testing application we need to have lot more data in our tables than what we have now. How do I duplicate the data in a table. In the process of duplicating I also need to set new ...
0
votes
0answers
17 views

FACT table loading

I have the below table structure : Ticket# Tckt_type Amount Acct Num 1 abc 10 1001 1 def 20 1002 So, for the same ticket number, there ...
0
votes
0answers
105 views

Reviewing ways to generate monthly tables using PL/SQL automatically

I am attempting to automate a set of tables that my colleagues produce monthly, using PL/SQL. The set of tables contain data about different metrics (e.g. Customer revenue, customer demographic ...
0
votes
0answers
84 views

SELECT from Function that return CURSOR

I would like to select from a function that return a SYS_REFCURSOR Type value. for example : CREATE OR REPLACE FUNCTION my_funtion ( my_param IN VARCHAR2) RETURN SYS_REFCURSOR IS ...
0
votes
0answers
66 views

how to update 'update trigger fired record's column?

I'm new on this task. I tried to update when I/F table insert after trigger. but it wasn't work.. There is my trigger source like.. create trigger T_ATABLE_I after insert on ATABLE for each row ...
0
votes
0answers
49 views

How to cast as type of a table column?

I have multiple views with union like this: select column1, column2 from mytable union select cast(extcol as nvarchar2(15)), cast(extcol2 as nvarchar2(10)) from exttable But later I change the size ...
0
votes
1answer
198 views

Oracle Package in Data Dictionary that can't be dropped

I've encountered a very interesting problem that I can't figure out how to fix. I have a package that I wanted to create on my database with a wrapped body. I mistakenly omitted the word "BODY" from ...
0
votes
1answer
71 views

Alter trigger Oracle

Does alter trigger hang if a table is locked by some DML operation ? What kind of exception does it throw? Resource busy 0054 or some other exception...? I have tried to reproduce this scenario but ...
0
votes
1answer
159 views

Why is there a difference in the character limit for VARCHAR2 in SQL and PL/SQL?

While working with some large scripts I encountered errors related with the 4000 character limit that VARCHAR2 has in SQL but not in PL/SQL. As explained here the VARCHAR2 datatype has a 4000 ...
0
votes
1answer
303 views

How to create script file with PL/SQL?

I have to update several objects in many instances. In order to achieve that I am using DBMS_METADATA to create the DDL statements. So far I have the DDL statements and I save them in a TABLE. I ...
0
votes
1answer
86 views

Rows to columns

I am new to Oracle. I know MySQL. I wrote below query in MySQL: Tables: CREATE TABLE Ass ( asset_id BIGINT(20) NOT NULL, caption VARCHAR(64) DEFAULT NULL, description VARCHAR(4000) DEFAULT ...
0
votes
1answer
557 views

Compare two big tables in PL/SQL

I need to implement comparing 2 tables by set of keys (columns of compared tables). By this comparing i should check equal records (equal = equal by set of defined keys (columns in these input ...
0
votes
0answers
227 views

Oracle - Slow queries without prepending schema name or providing hint

I am logged in as the schema owner in Oracle 11gR2 on Linux. I have 55 million rows in table. select max(col) from table; - takes 300 seconds (index full scan) select max(col) from schema.table; - ...
9
votes
3answers
2k views

Why do we use Group by 1 and Group by 1,2,3 in SQL query?

In SQL queries, we do use Group by clause to apply aggregate functions. But what is the purpose behind using numeric value instead of column name with Group by clause? For example: Group by 1.
0
votes
1answer
33 views

Enumerate Oracle tables in PLSQL

How do you run a query to list all tables, or all tables where tableName like '%abc%'. Just poking around, I tried the following with no success: select * from SYS.TAB$ select * from SYS.OBJ$ ...
1
vote
2answers
437 views

ORA-00942 when trying to select from gv$session inside of procedure

I have been tasked with allowing developers to kill their own sessions in the Development database. I've written a procedure, but for some reason I'm getting PL/SQL: ORA-00942: table or view does not ...
1
vote
1answer
43 views

Rollback in Oracle

I am having a problem in Oracle rollback. In my stored procedure I have multiple insert and update statements. If every thing is fine I am sending success message and also I am tracing success status ...
-1
votes
1answer
30 views

sequence id in oracle

I am using Oracle 11g. I have a senario like: I need to increase auto increment id like below 00000001 00000002 00000003 00000004 For example, my table looks like below id empid name ...
-1
votes
1answer
1k views

Commit and rollback in Oracle stored procedure

In my Oracle stored procedure, I have multiple insert and update statements like below: create or replace PROCEDURE SPTest AS BEGIN insert into emptest(empid,empname,deptno) (1,'ravi',10); ...
1
vote
0answers
32 views

Allowing users access to SQLPLUS and to compile PLSQL [duplicate]

As a DBA - assuming my users are knowledgeable with PLSQL and SQL - why would I not grant my users privileges to compile and run their own PLSQL code. We have an MI database environment where the data ...
0
votes
3answers
84 views

Allowing users to compile / run PLSQL and SQL

As a DBA - assuming my users are knowledgeable with PLSQL and SQL - why would I not grant my users privileges to compile and run their own PLSQL code. We have an MI database environment where the data ...
3
votes
3answers
230 views

How to raise_application_error beyond a when others clause

Background: I've used a few Oracle articles to develop an error package, with some procedures. One of these is Log_And_Return which is called throughout the database. I've simplified it for brevity, ...
2
votes
0answers
36 views

PLSQL using cursors or functions to query repeated data

Is it better to declare a commonly used lookup query as a package function or as a function (either returning rows or values or returning a sysref cursor)? Whats the difference? What are the best ...
0
votes
2answers
89 views

ORA-01410 Error

I am getting ORA-01410 and ORA-06512 for the following block of code in a trigger im firing for deletion of a record in my table. Are the calls correct ? getlong ('xxx', 'YYY', :OLD.ROWID), getlong ...
1
vote
1answer
114 views

Oracle PLSQL code recovery

I cannot connect to my database as admin, even using connect descriptor neither via RMAN. I am getting TNS-12514 error. I consider to install new instance. Questions: 1) Can I restore/recover PLSQL ...
0
votes
0answers
103 views

Oracle SQL Loader - BULK UPDATES

Can SQL loader be used to do bulk updates? I have a table that holds customer information. The table has a primary key and it has 5 columns pertaining to the customer. Now we created three more new ...