sqlplus

How do I set LINESIZE and PAGESIZE with a substitution variable?

懵懂的女人 提交于 2019-12-24 00:54:59
问题 I am trying to use a PL/SQL script in SQL*Plus to set the linesize and pagesize based on a developer input on whether a report should print in landscape or portrait orientation. If it is landscape, I want linesize 132 and pagesize 60. If it is portrait, I want 88 and 80 respectively. I am trying to use substitution variables to do so like this: DEFINE PRINT_ORIENTATION 'PORTRAIT' COLUMN LINESIZE_VALUE NOPRINT new_value LINE COLUMN PAGESIZE_VALUE NOPRINT new_value PAGE SELECT DECODE('&PRINT

WHENEVER SQLERROR never works

旧时模样 提交于 2019-12-24 00:26:25
问题 I don't know what can be a reason and I spent already hours on the Web trying to figure out what's wrong in my case. I've checked official documentation and some thought from Tom Kyte on this and surely topic on stackoverflow about it. I use following code: .. < <(sqlplus -s /nolog <<EOF set errorlogging on WHENEVER OSERROR EXIT FAILURE WHENEVER SQLERROR EXIT FAILURE connect ${use}/${pwd}@${database} @$SCRIPTS_PATH/script.sql EOF ) echo Exited with $? I've emulated different failure scenarios

Running loop in script in sql plus

房东的猫 提交于 2019-12-24 00:22:58
问题 I am running a script in sql plus, I have a for loop in my script: BEGIN FOR count IN 1..100 LOOP INSERT INTO CompanyShare VALUES (count, 1, 250); END LOOP; END; BEGIN FOR count IN 101..200 LOOP INSERT INTO CompanyShare VALUES (count, 2, 50); END LOOP; END; When I run the script this error came up: ORA-06550: line 6, column 1: PLS-00103: Encountered the symbol "BEGIN" Where am I going wrong? 回答1: Try to add / after end; as below: BEGIN FOR count IN 1..100 LOOP INSERT INTO CompanyShare VALUES

Help with SQLPLUS please? How to make SQLPLUS startup with DEFINE `OFF` initially?

女生的网名这么多〃 提交于 2019-12-23 21:01:45
问题 I have a batch script that invokes PLSQL with connection details, which works fine but I still have to explicitly SET DEFINE OFF when I connect. I would like to enhance my simple batch script to pass the SET DEFINE OFF command to SQLPLUS so that once I am connected, I will no longer have to issue that command manually. echo set define off | sqlplus user/pwd@tnsname This does not work. I am logged in, and logged out again immediately (output follows): SQL*Plus: Release 10.2.0.3.0 - Production

Generating SQL*Plus script using SQL*Plus

柔情痞子 提交于 2019-12-23 19:53:20
问题 I want to generate a whole lot of SQL*Plus scripts by querying the data dictionary, but I'm hitting some problems and suspect I'm missing something obvious. For example, when I execute the following in SQL*Plus I get ORA-01756: quoted string not properly terminated : SQL> SPOOL myscript.sql SQL> SELECT q'[SPOOL log 2 SELECT COUNT(*) FROM DUAL; ERROR: ORA-01756: quoted string not properly terminated I tried using the line continuation character to avoid this error, but it puts the continuation

ORA-02298 Parent Keys Not Found?

戏子无情 提交于 2019-12-23 18:02:28
问题 I've been stuck on this for ages as every time I try it - it comes up with the following error: Cannot Validate - parent keys not found. Here's the code (http://i.imgur.com/6JBzTiM.jpg): I can create the Primary Key in the Employees table and assign it to EmployeeId. But when trying to add that as a foreign key in the WorkPackages table (using the code below) ALTER TABLE WORKPACKAGES ADD FOREIGN KEY (EMPLOYEEID) REFERENCES EMPLOYEES (EMPLOYEEID); it keeps on coming up with the validation

Oracle: How to detect client process termination like it works for sqlplus?

我们两清 提交于 2019-12-23 15:40:18
问题 I have the following problem in my application which connects to an Oracle 10g database: When my client crashes, or the process is terminated via task manager, or the client loses connection for a while, the appropriate entry in the v$session view remains. Now when I connect to the database with sqlplus, and i kill sqlplus.exe through the task manager, the session entry gets deleted almost instantly. Latter behaviour would be preferred for my application for various reasons. What does sqlplus

Oracle procedure works only when set serveroutput on;

痴心易碎 提交于 2019-12-23 12:08:09
问题 Strange behavior trying to insert a record with a stored procedure. Only works with set serveroutput on : Thanks. SQL*Plus: Release 11.2.0.1.0 Production on Tue May 31 22:48:25 2016 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> exec abc_utils.abc_init(p

Show the structure of the table in SQL

强颜欢笑 提交于 2019-12-23 07:37:10
问题 Can someone explain things a little better to me? How do I show the structure of a table? I run the select * from table ; and of course it displays all that's in the table. But, I am being asked to show the structure of the table. What does that mean, and what is the command? Here's my table below. SQL> select * from dept; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> 回答1: To list columns and data

Number data type showing up as # in SQL Plus

淺唱寂寞╮ 提交于 2019-12-22 05:13:28
问题 Number data type showing up as # instead of the numbers in SQL Plus. Please refer to the H_RATE for the issue prevously it was showing up correctly and I have searched the internet and stackoverflow for a simliar issue or answer but none have the same. Could you help in fixing it so it shows the number instead of #? 回答1: # is displayed if the value can't fit in the column; from the SQL*Plus documentation: If a value cannot fit in the column, SQL*Plus displays pound signs (#) instead of the