Questions tagged [plsql]

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.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

first row and last row fields value from where data changed [closed]

Assume I have a table like this: I'm trying the have a output like following picture How best to achieve this?
1
vote
1answer
42 views

PL/SQL Script Line with Only a Dot…What is the purpose/function of the dot?

I have inherited a pl/sql script from a previous dba that worked at my company. It is used to "clean up" failed distributed transactions. The script is easy enough to understand, except for one line ...
-1
votes
0answers
21 views

Hierarchical Query with join [closed]

This the current Hierarchical Query: SELECT object_id BULK COLLECT INTO object_ids FROM objects WHERE ROWNUM <= batch_size START WITH object_id IN (SELECT object_id ...
0
votes
1answer
47 views

i got below error when complie this code [closed]

ORA-20000: ORU-10027: buffer overflow, limit of 10000 bytes ORA-06512: at "SYS.DBMS_OUTPUT", line 32 ORA-06512: at "SYS.DBMS_OUTPUT", line 97 ORA-06512: at "SYS.DBMS_OUTPUT", line 112 ORA-06512: ...
0
votes
1answer
24 views

How to get the SQL_ID that is blocking another SQL?

Well, I'm personalizing a useful script that I found and I need put in this script what is the sql_id of the SQL that is blocking another SQL. Here is my script, if you try this, You never will get ...
0
votes
1answer
40 views

How do I create a simple SELECT statement as a stored procedure in PL/SQL? - Regardless of the best practises around Stored Procs

Was wondering how to create a simple select statement to return all records within a table in PL/SQL such as CREATE OR REPLACE PROCEDURE getStudents AS C1 SYS_REFCURSOR; BEGIN OPEN C1 FOR SELECT * ...
0
votes
0answers
49 views

SQL query tune to replace UNION - Oracle

SELECT FN_ENQDATA_STRING (col1) FROM tab1 WHERE tab1.col2 = tab2.col2 AND tab1.col3 = ? I also have tab2 which has same columns as tab1 and i need to call function for that too. What I can do is ( ...
0
votes
2answers
35 views

PL/SQL - Drop User inside BeginEnd block

I have some experience with SQL Server but now I'm starting to work with PL SQL and I'm facing some problems because the difference between the two technologies. I have some scripts to drop my ...
0
votes
0answers
27 views

Import Schema dump into multiple schemas

I have a production schema and for upgrade they have decided to use 3 schema instead of one. For deploying this into production I have to take dump of schema A and import into 3 different schema with ...
0
votes
4answers
73 views

Alternative to Triggers

I am working on an oracle database and want to record the exact time of any transaction happening on a specific table in the schema. Using triggers on that table is out of question as the client do ...
0
votes
0answers
34 views

Case inside case in oracle query

Can anyone help me? I want to use query using CASE WHEN with logic where time less than 03:00 PM on Monday until Friday will get value start from tomorrow 03:00 PM until today 03:00 PM SELECT ...
0
votes
1answer
28 views

Toad for Oracle: Procedures, Packages, Job, and DBMS_SCHEDULER

If I have about 10 queries which contain subqueries, would it be a best practice to contain all of them in one procedure? This script creates a small fraction of the data required for a report. DROP ...
0
votes
1answer
65 views

Automating SQL scripts in Toad for Oracle (13.1)

I'm not a DBA, so bear with me. I've scheduled tasks through Toad's automation designer, but this uses Windows task scheduler. It's using Oracle 12c. All I'm doing is updating (creating/dropping) ...
1
vote
0answers
29 views

Missing CALLs on identifiers_all using PL/SCOPE

Posted this on StackOverflow, but maybe this is the right place for it: I'm trying to use the view all_identifiers from PL/SCOPE to find out calls to procedures and functions but it's not showing all ...
0
votes
1answer
28 views

Receiving error : ORA-01747 While trying to calculate COUNT(*) of a specific table

Hope you're doing well. I have two tables and as I far as I know for this scenario there is no need for their structures. When I run this query : SELECT COUNT(T.*) AS X FROM table1 T INNER JOIN ...
0
votes
0answers
56 views

How to insert from one table to another from trigger

So i have an after insert trigger to insert some data into a temp table, and i want to add to the end of the trigger the ability to insert the rows from the temp table back to the original table. This ...
0
votes
0answers
33 views

sequelize query to get different columns in for different row depending on a column value

I have a following schema module.exports = (sequelize, DataTypes) => { const Photo = sequelize.define( "Photo", { photoURL: { type: DataTypes.STRING, allowNull: ...
1
vote
2answers
129 views

Suppress some output from PL/SQL script in Toad for Oracle

Question: In PL/SQL for Oracle running in Toad, can I suppress script output except for certain lines I want to see? e.g. I don't want create table, insert record, drop table. I do want my own ...
0
votes
1answer
21 views

update records that are there in .csv file which will be given as input [closed]

I have .csv file with list of Ids, using those IDs in file- giving them as input, I need to update the record in table, I have around 4000 Ids so 4000 update statements are not possible, need a ...
0
votes
1answer
35 views

Copy package in Production DB to Test DB with dependencies?

This is my first question here, so please let me know if this isn't the right place to ask. I'm a new programmer, fresh out of school. Primarily I develop in Python/C#, with a dash of SQL when needed....
0
votes
1answer
29 views

How to put result of SQL into bind variable

I'm trying to put the result of the query into a bind variable like this, but doesn't work: var teste number; exec :teste := (select trunc(avg(e.salary),2) from hr.employees e); How I make it to ...
0
votes
0answers
26 views

How to refresh the URI type data : insert into temptable values (SYS.URIFACTORY.getURI('URL'));

How to refresh the URI type data and reload to table , whenever the website url got refresh. My complete code: Created table with URI TYPE create table vignesh3(url URIType) loaded data ...
0
votes
0answers
41 views

Oracle Model Clause and For Iteration Constraints

I have a multidimensional model which I am trying to apply a FOR iteration against. However, I need to add a constraint to one of the dimensions in the FOR iteration (e.g. stop the MODEL from ...
2
votes
2answers
143 views

How to use “regular expression” to separate specific strings in Oracle

I have a string '(1:30,2:4,52:0,8:1)', and I need to use a regular expression to have this output: field1 field2 level 1 30 1 2 4 2 52 0 3 8 1 ...
0
votes
0answers
46 views

How to capture 'Deleted' and 'Updated' record after Merge in PL/SQL.TSQL 'Output' equivalent in PL/SQL

hope you're doing well. imagine I have a source and destination table like: Source(Column1 int , column2 varchar2(50)) Destination (Column1 int , column2 varchar2(50)) I want to merge these two ...
0
votes
1answer
29 views

Executing an oracle variable string as I do in SQL Server

In SQL Server I can do something like: DECLARE @VAR VARCHAR(100); SELECT @VAR = SELECT * FROM SYS.DATABASES EXECUTE(@VAR) How can I execute a string that I've created inside a variable in Oracle? ...
-1
votes
1answer
480 views

Facing error 'No data found ' while trying to write a query using 'Cursor' PL/SQL in oracle

Hope you're doing well. I'm new to oracle PL/SQL and I'm trying to write a query just with the aim of practicing 'Cursor's . I have three tables with below structures : Student:(Student_id , ...
0
votes
2answers
59 views

Procedure to find a specific EXPRESSION in all tables in a specific schema in ORACLE

Hope you're doing well. Since I'm new to Oracle database and PL/SQL it's a bit difficult for me to understand complicated queries and now I'm trying to figure out what this procedure exactly does.I ...
0
votes
1answer
746 views

How to pass table name and column name dynamically in Cursor

I would like to delete millions of records from lots many tables. In the below code, i'm trying to select a table with some filter condition and trying to delete using its row id. In the below, for ...
0
votes
1answer
31 views

How to get my result from Procedure

How can i get my out parameters from my procedure. My stl_mbc_cdr table has over 100 records and i cant see my results. declare call_charge VARCHAR(10); MSG_OUT VARCHAR(50); BEGIN FOR ...
0
votes
1answer
75 views

Facing Error 'Missing expression' while trying to create a After insert trigger in PL/SQL

Hi everyone hope you're doing well. AS you might know by now I'm new to PL/SQL and I'm trying to write a trigger as you can see below : CREATE OR REPLACE TRIGGER T_Insert AFTER INSERT ON tag ...
1
vote
0answers
104 views

Start dbms_services on standby database

I'm developing a trigger which starts and stops services when the pdb is open. The point is that my trigger doesn't stop the service if I execute the ALTER PLUGGABLE DATABASE ALL SAVE STATE; with ...
1
vote
1answer
90 views

Facing error while trying to create a function using 'ACCESSIBLE BY' clause in PL/SQL

Hi everyone hope you're doing well I'm new to oracle PL/SQL and I'm trying to write a function using 'ACCESSIBLE BY' clause but I receive errors . this is my function create or replace function ...
1
vote
2answers
164 views

After Inserting , Update / Insert into another table in pl/sql trigger

I am working on PL/SQL trigger i have two table TAG Table SR.NO ID TAG BRAND_ID ------ ---- ----- ---------- 1 10 ABC 99 MY_TAGS Table SR_NO TAG COUNT ...
1
vote
1answer
179 views

Facing error while trying to run dynamic pl/sql

Hope you're doing well I'm new to PL/SQL and I'm trying to write a dynamic PL/SQL. What I've written so far is : declare sql_stmt varchar2(100); v_student_id number := 1; v_new_stname ...
0
votes
1answer
146 views

Facing error 'invalid SQL statement' while working with cursor variables in PL/SQL

Hi everyone hope you're doing well. I'm new to PL/SQL and I'm trying to learn 'cursor variable' . I have made and example for myself and everything looks correct and I have no idea why it does not ...
0
votes
2answers
41 views

Split the results of a query into parts

I got this question in an exam, the teacher asked us to raise the employers' salaries using the following rules using a cursor: An extra 4% for the first quarter with the highest salary. An extra 6% ...
1
vote
0answers
44 views

Cannot get the new table's FK-constraints in an AFTER ALTER trigger

I'm trying to create a trigger for AFTER ALTER event on schema's tables which would work with the new FK-constraints, here's my test code: CREATE OR REPLACE TRIGGER Test_Trigger AFTER ALTER ON SCHEMA ...
4
votes
2answers
842 views

PL/SQL function to receive a number and return its binary format

I'm trying to write a function to receive a number and return its binary format. This is what I've developed so far and it's ok for inputs : 4,8,16 but it does not return correct binary format for ...
0
votes
2answers
59 views

Facing error while executing function inside the package in PL/SQL

Hi everyone hope you're doing well. I'm new to oracle and I'm reading about the concept of 'Package' and 'Package body'. I have a function as you can see below CREATE OR REPLACE Function ...
0
votes
0answers
39 views

How to execute pl/pgsql do block in a bash script? [duplicate]

I want to migrate my databases to a new server, and some of them contain views, which I don't want to migrate. So I wrote a bash script that roughly looks like this # Some commands to migrate the ...
2
votes
1answer
57 views

How can i select columns from two tables using REF

I'm new to Oracle's PL/SQL i'm using 11g. I have 2 Type Objects each one of them with has a table and third table where i keep references of this 2 objects, how can i retrieve values from objects ...
0
votes
1answer
30 views

Insert iterated values from one table to another in OracleDB

I'm pretty new in Oracle universe and I need help. I have to iterate through Users Table and insert these 3 specific rows into Task_Group Table. The hard thing to do is to check if these rows even ...
0
votes
1answer
69 views

Disable Oracle substitution parsing

I need to update a string (VARCHAR2) value in an Oracle database which contains Javascript code. The update script contains the following string: c===l&&p(a,b) which when executed from "...
1
vote
1answer
38 views

Can someone help me with this PL/SQL block?

Write a PL/SQL block to display the details of five employees who are getting the highest salary (table name is Employee) Is this how you do it?? DECLARE Cursor C is select * from Employee ORDER BY ...
0
votes
0answers
203 views

Extract table data in a BLOB field

I am trying to extract data from tables in a delimiter separated value format. To extract data i am concatenating all the columns of the table with each other and then converting the concatenated ...
0
votes
2answers
448 views

“Fire” a trigger to populate columns that are NOT NULL?

Working out of my SQL book at the moment. The question is, Create a trigger based upon the ENROLLMENT table. The trigger should “fire” before an INSERT statement. The trigger will populate all the ...
2
votes
1answer
90 views

If then else case PL/SQL if text is in list

I have a column that will return something like this: 01 05 Z7, Z4, 01 09,08 I then have two static lists: list a = [01, 02, 03, 04] list b = [Z7, Z2, 05] and our case statement returns one of the ...
3
votes
4answers
849 views

I don't know how to fix ORA-04091 mutating trigger error

I'm learning Oracle SQL, but when dealing with triggers I'm finding an error, that prevents me from updating values in that table. The error is: error ORA-04091: table USUARIO.LINEAS is mutating, ...
0
votes
1answer
1k views

Not all variables bound ORA-01008: not all variables bound error

I am using Oracle SQL developer. I am running a query on employees table which is by default, having columns like first_name, last_name, employee_id, email, phone_no, hire_date, job_id, salary, ...