Questions tagged [sqlplus]
SQL*Plus is a command-line interface for the Oracle RDBMS product. SQL*Plus questions should probably be also tagged with oracle.
3,411
questions
0
votes
0
answers
21
views
SQL*Plus Spool Duplicates SQL Prompt when TERMOUT is OFF
In SQL*Plus, the spool output shows two SQL prompts, SQL>SQL>, on the same line when termout is off. This is unexpected.
Below are the three scripts used in the example.
driver.sql
set echo on
...
1
vote
0
answers
19
views
SQL*Plus TRIMOUT OFF Prevents Display Output
In SQL*Plus, when I set trimout off the display output disappears. This is unexpected.
Below is an example script that calls dbms_output.put_line once with trimout on and once with trimout off.
set ...
0
votes
2
answers
26
views
I'm trying to update a column of a table by adding some values but it does not get updated
I created a table named emp and wanted to update values of the column ESAL by adding some values to each data but after executing the update query it doesn't get updated.
update emp set ESAL=ESAL+20 ...
0
votes
2
answers
40
views
Return Select Statement as Rows?
I am not sure if I am mis-remembering or if it was a different SQL format, but I am sure I had a way to switch the way the results are displayed in Oracle. I am trying to query a table with multiple ...
0
votes
1
answer
33
views
Bind variable in trigger's body
I'm learning Oracle db and encountered on a problem with using bind variables in triggers body.
Here I created a bind variable with VARIABLE command
sqlplus:
SQL> VARIABLE my_variable number;
SQL&...
1
vote
1
answer
37
views
How to know if oracle GRANT command actually changed anything
Having run a grant command in an Oracle SQL script, is there any way to tell if it actually changed anything. Like an equivalent of SQL%ROWCOUNT or similar?
I am writing an ansible module which will ...
0
votes
1
answer
10
views
dbms_lob.append cannot append a string to a bind variable
Would someone please point out what I am missing here?
Below is a minimal example:
var c clob
exec dbms_lob.append(:c, 'test')
print c
It produces this error:
BEGIN dbms_lob.append(:c, 'test'); END;
...
0
votes
1
answer
33
views
How to use select statement to query only negative value in oracle sql
table_a
billno desc qty amount
10324 orange -1 -1.00
10324 apple 1 3.00
10324 papaya 1 2.00
10431 water melon 1 2.00
10431 kiwi ...
0
votes
0
answers
12
views
Syntax SQL Varaible for spool path
I fail to use a variable as a path for the spool. Currently, I have tried many variations but none actually worked:
variable some_var VARCHAR2(100)
exec :some_var := some_pack.get_name()
PRINT ...
0
votes
0
answers
21
views
How do you get a connection to Oracle database when running the program from the command line?
After launching my program from command line, it returns the following error message when the program is routed to get a connection to retrieve data from a database :
Exception in thread "main&...
0
votes
0
answers
38
views
Oracle database won't connect day after connection worked. I can connect in SQL Plus but not in Oracle SQL Developer
The other day I made an Oracle database and connected to it via Oracle SQL Developer. Now when I go back to SQL Developer and put in my password this error appears. "The Network Adapter could not ...
-2
votes
0
answers
23
views
move mutliple commands of sql queries in shell script to a single line command
i created a Kshell script that has the following block:
MAX_ID=echo " set echo off head off verify off feed off pages 0 lin 100 SELECT MAX(PR_E_I) FROM G_PR_E_M; exit; "| sqlplus -s "${...
1
vote
1
answer
47
views
Need to load XML file to a oracle table
I have a xml file that I need to load to a table.
Below is the xml file content. How can I load this to the table. Please let me know the best option"
<soapenv:Envelope
xmlns:soapenv="...
0
votes
0
answers
48
views
Oracle query throwing exception via python
Below is the query and for which i am facing issue in python. I am using oracledb package.
Query:
SELECT SUM(COUNT) COUNT FROM (
SELECT COUNT(1) COUNT FROM abc WHERE datecol1 >= ((CAST(...
0
votes
0
answers
35
views
Execution of script.sql with MERGE (with INSERT and UPDATE) statement wont work via SQLPlus. But it works in SQL Developer
This is my script.sql file with 1 MERGE row:
MERGE INTO MYTABLE t1 USING (SELECT '123456' RUT_SOCIEDAD, SYSDATE FEC_PROCESO FROM DUAL) t2 ON (t1.RUT_SOCIEDAD = t2.RUT_SOCIEDAD) WHEN MATCHED THEN ...
0
votes
1
answer
55
views
Oracle SQL Assign value to variable outside BEGIN-END?
I have the following structure:
ACCEPT PVAR_FLENME PROMPT 'File Name (No Space)? '
ACCEPT PVAR_FULLROUTE PROMPT 'Full Route: '
SPOOL "&PVAR_FULLROUTE.&PVAR_FLENME.";
... which ...
-1
votes
2
answers
45
views
How to sum total amount without grouping even have duplicated number?
table_a table_b
desc amount ID vcref ID
banana 2.00 101 VC10001 101
apple 3.00 101 VC10001 101
orange 5.00 101 ...
0
votes
2
answers
54
views
SQLPLUS use optional parameters
Currently, I call an SQL File from a CMD file and transfer some parameters during the call. The code below works if I actually pass a value or press enter. However, my CMD/SQL will stop and wait for ...
0
votes
1
answer
42
views
Oracle SQL Developer Create new connection Error message: Test failed: ORA-01017: invalid username/password; logon denied
I'm trying to create a new connection in SQL Developer (following homework's instructions), as requested I have filled in the information, but it keep reporting error message when I tried Test and ...
0
votes
1
answer
24
views
Sqlplus wait until parallel scripts are finished to execute script
I have a batch file which looks like this, executing the scripts in parallel:
start sqlplus user/pwd@tnsid @myscript1.sql &
start sqlplus user/pwd@tnsid @myscript2.sql &
start sqlplus user/pwd@...
0
votes
0
answers
10
views
Sqlplus encode password
I have the below line in a batch file.
more myfile.txt | sqlplus user/password@tnsid
Is there any way to encode the password and still have sqlplus understand it in order not to be readable?
0
votes
0
answers
44
views
Oracle: Change user of current connection
i have the situation that i am connecting to a Oracle Database as SYS User.
We have some 3rd Party applications installed which uses the USER-Variable.
Now i have some special situations where we want ...
0
votes
1
answer
45
views
SQLPlus Connection Issue when using bash script
Trying to connect to ORACLE SQLPLUS using unix shell script. But it is getting failed..
Looks like the script in line 3 is incorrect as I am passing username, password and SID
#!/bin/sh
cd /dev/shrd/...
0
votes
1
answer
53
views
Sqlplus 'insufficient privileges' while trying to grant sysdba to user
I've got a VirtualBox Oracle Linux Image containing an Oracle DB and have used Oracle SQL Developer to connect to that database.
I used the already existing credentials:
user: system
password: oracle
...
0
votes
1
answer
43
views
SQLPLUS 18c unable to connect to database 19c, get invalid password, but CAN connect through SQLDEVELOPER
Using SQLPLUS 18c on windows 10pc, which has Oracle XE 18c
get invalid password response when try to connect to 19c EE on ODA
TNSPING reached the 19c database
Using same account and password from SQL ...
0
votes
1
answer
157
views
Cannot install HR schema for Oracle 21c express
I watched video tutorial at https://www.youtube.com/watch?v=IalqQN09OaA . My Oracle database version
select * from v$version;
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
I ...
-1
votes
2
answers
48
views
Right Parenthesis error 'INT(8)' in SQLPLUS
I'm trying to rectify this error
SQL> CREATE TABLE Reservation_21BAI1750(
2 PNR number(9),
3 Journey_Date Date NULL,
4 No_of_Seats INT(8) ZEROFILL CHECK (No_of_Seats < 50),
5 ...
0
votes
1
answer
46
views
Bash Script How to Make a Temporary SQL(Oracle) Table and Use It Later
I am trying to create and use a temporary private table in Oracle through bash script and need to read information from it and do some processing logic in bash script and then write back into it.
...
-1
votes
1
answer
34
views
there is no scott schema in my oracle 11g [duplicate]
recently download oracle 11g, tried login using scott, turns out scott doesnt exist . I logged in using sys as sysdba and ran 'show pdbs' but it showed 'unknown show option pdbs'.
I looked up online ...
-1
votes
1
answer
42
views
for the below sqlplus query script, how to get DATE & TIME in DD-MMM-YY HH.MM.SS format for one column "evt_eventdate," only
for the below mysqlplus query script, how to get DATE & TIME in DD-MMM-YY HH.MM.SS format for one column "evt_eventdate," only
set echo off
SET SQLFORMAT CSV
SET FEEDBACK OFF
SET ...
0
votes
1
answer
35
views
Having problems with using SQL Loader to sum two fields
Im having trouble calulating two field into one
The Table columns are as follows
Name Null? Type
----------------------------------------- -------- -----------...
-1
votes
1
answer
55
views
Why am I getting this '#########' as output in the fields of a column?
I am using ORACLE SQL* PLUS XE 11g. I made a Vehicles table with:
CREATE TABLE Vehicles (
vehicle_id NUMBER PRIMARY KEY,
v_type VARCHAR2(50) NOT NULL,
v_price DECIMAL(10,2) NOT NULL
);
...
-1
votes
3
answers
124
views
Formatting output in a report on SQL*Plus (after spool to CSV)
I have a question about formatting the output in a report that I get from csv that was spooled from SQL*Plus.
I have Initial table whose data looks like this:
ord_no
ls_prod_division
ls_prod_area
...
0
votes
0
answers
99
views
sql plus connect \ as sysdba ora-12560
After installing Oracle XE, I am struggling trying to connect with SQL Plus.
I want to connect the database with SQL Plus (and also with connectionstring) but it seems that I don't have the right ...
0
votes
1
answer
218
views
Install Oracle instant_client and sqlplus with Homebrew on OSX
I am trying to Homebrew to install Oracle instant_client and sqlplus. Do the instructions discussed here still work:
How to install Oracle Instant Client on a Mac?
I have installed instant client and ...
0
votes
0
answers
21
views
How can I attribute schema's privileges to a role?
Consider this case, in an Oracle database, there are some privileges attributed to an HR schema for example; i have created a role developer_user and i want to attribute HR's privileges to this role....
0
votes
1
answer
44
views
How to troubleshoot ORA-6502 / ORA-6512 errors?
I am running the below query.
declare
i int;
c_limit constant pls_integer default 10000;
TYPE cdr is table of TABLE_0.ENTITY_ID% type;
c_cdrt_tbl cdr;
cursor c_cdr is (select ENTITY_ID from TABLE_0 ...
0
votes
0
answers
187
views
ORA-12541: TNS: no listener
I have a VM in Oracle VM Virtual Box running Windows XP. In this VM, I have install Visual Studio .net 2003 with nhibertante ORM to connect to BBDD Oracle 12.2.
Oracle database is hosts in my physical ...
1
vote
2
answers
21
views
Calculate Months separated (oracle 11G)
Dear Respectful Experts,
We have a table having Column TOTAL_MONTHS e.g. if
As shown below table need to Update using Update Statement.
TOTAL_MONTHS = 15 then Update the Column named "Months<=...
0
votes
1
answer
68
views
Sqlplus print category with subcategories
I have tables set up like this:
INSERT INTO CATEGORY VALUES (1000, 'Type1', 'A', '01-Jan-21', 27.00);
INSERT INTO CATEGORY VALUES (1010, 'Type2', 'A', '01-Jan-21', 30.00);
INSERT INTO CATEGORY VALUES ...
0
votes
1
answer
43
views
How to decode a column using another column?
im new to sql and i have the following problem.
I have this kind of table with employee number, surname, job and a column named 'dir' that shows the employee number of the director of the employee in ...
0
votes
1
answer
43
views
ASPEN SQL Script to compare two tags glossaries
What I want to do is bring up a list of all tags in a table (IP_AIDef and IP_DIDef) that contains "FDL" (fast data logged) in the 'name' along with their corresponding glossaries (...
0
votes
1
answer
30
views
SQL Query alter table auto increment in SQL Plus Oracle 10g
I have this SQL Query and I am trying to modify my column so it has an auto increment Property, But when I execute the query I either have a problem code ORA-00933 SQL command not properly ended
This ...
0
votes
0
answers
38
views
why did my sqlplus keeps on getting disconnected when im putting the scott.sql directory
enter image description here
im trying to figure out how to add scott schema into my oracle db, but when i try it this way by adding the directory in sqlplus it keeps on getting disconnected for some ...
0
votes
1
answer
56
views
pl/sql ,oracle add heading in cursor
how I can add heading for table shown at top , in my code like this pic:
enter image description here
declare
E_Name employ.name%type;
E_Salary employ.salary%type;
CURSOR c_employees is
SELECT ...
0
votes
0
answers
131
views
What is the purpose and how to see result of dbms_stats.gather_table_stats?
I am using Oracle database 21c Express edition in Windows 10 x64. I have table
CREATE TABLE "BICHVAN"."EMPLOYEES"
( "EMPLOYEE_ID" NUMBER(6,0),
"...
1
vote
2
answers
96
views
ORA-31603: object "FKSL6L09UUXICDX66MNPLQ0DI63" of type CONSTRAINT not found in schema "AIBLNGZDB"
I'm trying to get all constraint DDL from ALL_CONSTRAINTS using SQL PLUS. But ORA-31603 arise. Like this constraint there have more constraint where name are same but their Owner are different.
I try ...
0
votes
0
answers
181
views
How to enter connection string when install HR sample schema?
I am using Oracle database 21c express on Windows 10 x64 (localhost - 127.0.0.1 port 1521, sid = XE). I follow guide at https://docs.oracle.com/database/121/COMSC/installation.htm#COMSC109
With ...
0
votes
0
answers
10
views
i created employees as superclass with 4 subclass, added value to employees, with my primary key also able to enter a subclass, is this right?
superclass
CREATE TABLE EMPLOYEE (
EMP_ID CHAR(2),
CONSTRAINT PK_EMP PRIMARY KEY (EMP_ID),
FNAME CHAR(15),
LNAME CHAR(15),
ADDRESS VARCHAR(255)
);
ALTER TABLE EMPLOYEE
ADD EMP_TYPE CHAR(3) NOT NULL;
...
0
votes
0
answers
22
views
How to Solve an Trigger Compilation Error?
How can I solve this trigger compilation error?
SQL> create or replace trigger neg
2 before
3 insert
4 on tran
5 for each row
6
7 declare
8 no number;
9 begin
10 no:=...