SQL & PL/SQL :: Substitution Variable In Sqlplus

Jul 20, 2011

Here is a simple sqlplus line command with & substitution run time variable.

set verify off;
SQL> SELECT * FROM emp where sal >&SAL;
Enter value for sal:

Now as you see, oracle asks to Enter Value for substitution variable in line just below the SQL>. I wonder if there is one or more line could be left there so to improve the readability. So it should look like:

set verify off;
SQL> SELECT * FROM emp where sal >&SAL;

Enter value for sal:

View 2 Replies


ADVERTISEMENT

SQL & PL/SQL :: Variable Substitution In Using Clause

May 5, 2011

Below is the code, I am trying.

I have all the bind variables in "using_stmt" variable. How can i make this work. Currently I am getting error

ORA-01008: not all variables bound
--------------------------------------
DECLARE
SQL_STMT varchar2(200);
using_stmt varchar2(200);
dept_id number := 50;
dept_name varchar2(14) := 'PERSONNEL';
loc varchar2(13) := 'DALLAS';
rec_count number;
[code]......

View 13 Replies View Related

SQL & PL/SQL :: Substitution Variable With And Without Value Assigned

Jun 14, 2011

I have a table emp with columns [id,name,job_id,dept_id]. now I make a simple select query.

select id,name,job_id,dept_id
from emp
where id = &a
and name = &b
and job_id =&c
and dept_id =&d;

now in this case it will ask the values for all the columns and will according print result.

Now my questions is what will happen if I just pass the value for only id and name not for other two...?

View 35 Replies View Related

SQL & PL/SQL :: Block Using Substitution Variable

Oct 3, 2012

Declare a variable called sal to store the salary of an employee. In the executable part of the program, do the following:

a.Store an employee name in a substitution variable.
b.Store his or her salary in a variable.
c.If the salary is less than 5,000, give the employee a 10% raise and display the message "<Employee Name> salary updated" in the window.
d.If the salary is more Last Name Message than or equal to 3,000, print the employee's salary in the format, "<Employee Name> earns ............. No raise is given."

So the result should ask for the last name

- Himuro and message should show [Himuro's salary updated]
- Greenberg [Greenberg earns 12000. No raise is given.]
- Patel [Patel's salary updated]

Here is my PL/SQL

set serveroutput on

DECLARE
v_emp_sal employees.salary%type;
v_emp_last_name employees.last_name%type;
BEGIN
v_emp_last_name :=initcap('&emplastname');
SELECT salary
INTO v_emp_sal
[code]......

question:
How can I get the apostrophe in the dbms_output.put_line. Attached is the create employees table code.

View 4 Replies View Related

Client Tools :: Inserting Data With Substitution Variable?

May 24, 2012

I want to insert the value with '&'. But this is treated as substitution variable by oracle.So how can it is possible to do like this

INSERT INTO DEPT (DEPTNO, LOC, DNAME)
VALUES (50, '&NEW YORK', 'SALES');

View 3 Replies View Related

Client Tools :: Escape / Quote Ampersand (&) Because No Variable Substitution

Apr 5, 2011

I wish to replace the string "Benutzername&Kontakt" with nothing.

SELECT REPLACE (role_owner, 'Benutzername&Kontakt', '')
FROM JC_NAME_62
WHERE jc_name LIKE 'SAP_R4_BIN5\_%' ESCAPE ''

But my Toad prompts me always to fill in the variable. I don't wish to do that, I wish to escape the &

View 5 Replies View Related

SQL & PL/SQL :: Using $ Substitution In Select Statements?

Oct 11, 2011

Is it possible to have $ substitutions in Select statements ?

For example

Select * from my_table where ID in ${ID_LIST} and DAY >= to_date(${SOME_DATE})
$ID_LIST = (100,200,300)
$SOME_DATE = 10-10-2011 12:12:00

For the ID_LIST is using Prepared statements with ?,?,? the way to go ? Or are there are any Define we can do in SQL plus for this substitions ?

View 2 Replies View Related

SQL & PL/SQL :: How To Use Substitution Variables In FROM Phrase

May 17, 2010

HOW i can use the Substitution Variables in select statement in From phrase

we need execute select statement in different users in run time.

View 15 Replies View Related

Client Tools :: Substitution Variables

Feb 22, 2010

How I go about writing a query that doesn't see the '&' symbol as a substitution character. The problem I have is:

select replace
( fnd_profile.value( 'XXBPO_URL')
, '&DOCID'
, ai_dfv.bpo__document_link
) document_link
from ap_invoices_all ai
, ap_invoices_all_dfv ai_dfv
where 1=1
-- where clause

The problem above is that instead of replacing the characters &DOCID with the required value, it is prompting for input.

View 4 Replies View Related

Application Express :: Substitution String For List Entry

Jul 4, 2012

I have created a list with name Test_List and 5 values in it.

I want to pass the values dynamically when i select the list values (any of the 5 values).

I tried:

For each list setting(List Details --> Static list entries --> Target) i have set the
Request as ?Test_List=#Test_List#
Note: Here Test_List is my list name.

Also i have tried

Request as ?Test_List=&Test_List.

But nothing seems to be working...

View 8 Replies View Related

Application Express :: Is There A Built-in Substitution String For Item With Cursor Focus

Jun 27, 2012

I was wondering if there is a substitution string ( or something else) that could be used to 'return' the name of a Form item that has cursor focus?

View 3 Replies View Related

Sqlplus UI - Not Working?

Apr 22, 2008

I'm having some minor trouble with my sqlplus in Windows. Don't know which feature I accidentally edited by cosole seems to be in debug mode. Everything is ok, except that it print the old and new values of my variables. How can't I restore it to it's original behavior.

View 3 Replies View Related

Rollback In Sqlplus?

Aug 19, 2012

when i enter a sql * plus session an do a rollback; (without performing anything), always a "rollback complete" message appears even if there is nothing to rollback.

View 4 Replies View Related

SQLPlus Input Arguments?

Sep 30, 2003

I'm running a C++ program to call sqlplus to execute some sql scirpts. The program will accept arguments from users at the command line, and execute the script which the name will also be passed in as an argument to the program eg:

./MY_PROG.sh ABC.sql 23
(MY_PROG will call ABC.sql script and pass 23 as an argument to ABC.sql)

it works fine when the argument is passed in correctly, and my ABC.sql scirpt is able to execute correctly, however when the argument is not passed in, the program just hangs there, waiting for an input from the users. This is because "&1" in my script is expecting some value from users.

Because this program will be scheduled to run, and no one will be there to monitor the job, if so happens arguments were missing, the program will wait there for the entire night. Is there any way that I could make the program or the script to exit when there is no input to be found? I can't use timeout as I do not know how long does the script take to finish it operations, I could be updating millions of record from a script.

View 2 Replies View Related

10.2.0.3 SqlPlus DB Connection Slow?

May 16, 2007

We have two database instances on the same server. One was left at 9.2.0.7 and one was upgraded to 10.2.0.3. Connecting externally (sqlplus '/as sysdba') to the 9.2.0.7 database is lightning fast. Connecting externally to the 10.2.0.3 database is very slow, comparatively speakiing. This is on an IBM AIX-5L (64-bit) machine. We are using "tnsnames".

View 10 Replies View Related

Sqlplus Copy Command

Feb 15, 2013

i am trying to copy the data from a remote database which has Oracle 8i thru Sqlplus copy command to the local database which has Oracle 11gR2.

copy from abc/abc@remote
insert emp_new
using
select *
from emp_old
where rownum < 1001;

is it possible to copy the remote database thru sqlplus copy command ?

View 6 Replies View Related

Sqlplus Only Runs As Root?

Jul 18, 2013

I'm having issues with users logging into Oracle. I installed it on Ubuntu 12.04 running Oracle 11.2 XE. If i am root, i can run sqlplus just fine and log in. But when I use a regular user account and run sqlplus, it will just stay blank. No error messages or any feedback. I echo $ORACLE_HOME and echo $ORACLE_SID and they come back exactly as they do under the root account. My path is set up just like root has it.

It almost seems like a permission issue but even when i try sqlplus /nolog it stays blank.

[URL]

View 1 Replies View Related

Can't Run Sqlplus To Oracle On Different User

Aug 3, 2010

I have installed oracle 10g on opensuse. After i logon as normal user and type sqlplus, it was display an error message as below:-

login: nv2am
Password for nv2am:
login: Configuration file does not specify default realm when parsing name nv2am
Last login: Tue Aug 3 16:33:19 from 10.69.20.25
Have a lot of fun...
Directory: /home/nv2am
Tue Aug 3 17:36:23 MYT 2010
nv2am@ARMSDEV:/home/nv2am> sqlplus
-ksh: sqlplus: not found [No such file or directory]
nv2am@ARMSDEV:/home/nv2am> sqlplus "/ as sysdba"
-ksh: sqlplus: not found [No such file or directory]
nv2am@ARMSDEV:/home/nv2am> set ORACLE_SID="ARMSDEV"
nv2am@ARMSDEV:/home/nv2am> svrmgrl
-ksh: svrmgrl: not found [No such file or directory]
nv2am@ARMSDEV:/home/nv2am>

View 1 Replies View Related

Client Tools :: How To Add Value From Sqlplus

May 14, 2013

I want to add a value from sqlplus.

My scenario is like that i want to add the following value

select count(*) x from tab1

i need to connect several database, and each time i need to add with previous one. like that

connect a/a@db1;
select count(*) x from tab1;

then when i connect another db

connect b/b@db2;
select count(*) x from tab1;

x will add with previous one.

View 6 Replies View Related

How To Restrict Sqlplus As Sysdba

Apr 29, 2013

how to restrict sqlplus as sysdba

C:> Set Oracle_sid=Mydb
C:>sqlplus / as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0

I don't want to log in any one as sqlplus / as sysdba.If they can able to login as sqlplus / as sysdba then they can see others schema in the database.Say if i set

SQLNET.AUTHENTICATION_SERVICES=none

no one can log in as sysdba were as later some one changes to

SQLNET.AUTHENTICATION_SERVICES=NTS
After they changes to NTS they can log in and access other user details right ? how to restrict

Oracle version: Oracle 11 g
OS Version :Win 7

View 21 Replies View Related

Database 10.2.0.3 - Cannot Connect To Sqlplus?

Aug 29, 2012

My database in on 10.2.0.3 and facing hang problem when I am connecting to sqlplus.

bash-3.00$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Aug 29 00:54:03 2012

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

ERROR:
ORA-01075: you are currently logged on

As per Metalink note(215858.1) suggested in forums I have followed steps and produced results below.

bash-3.00$ sqlplus -prelim

SQL*Plus: Release 10.2.0.3.0 - Production on Tue Aug 28 23:28:02 2012

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Enter user-name: / as sysdba
SYS on test>oradebug help
SYS on test>oradebug setmypid
Statement processed.
SYS on test>oradebug hanganalyze 12

[code]...

Now I have got struck how to analyze above results.

View 3 Replies View Related

Can't Login Into Sqlplus Even As A Sysdba

Sep 7, 2013

"C:UsersKarthikeyan>sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Sat Sep 7 17:42:37 2013 Copyright (c) 1982, 2013, Oracle.  All rights reserved. ERROR:ORA-12560: TNS:protocol adapter error  Enter user-name:" 

this is the first time i tried to open sql*plus and i didn't create any database connection before....so i don't have any username and password.......

View 20 Replies View Related

Error 6 Initializing SQLPlus?

May 29, 2013

running CENTOS 6 and oracle DB 11.2.0 and when i try to launch sqlplus i get the following error:

Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

problem is, it's telling me to set ORACLE_HOME but I'm not sure where this is to set.

View 17 Replies View Related

SQLPlus - How To Create New Table With Constraint

Mar 25, 2009

I'm trying to create a new table which has a date field (date of birth) and I want to include a constraint which will not allow me to add values if they are over 21 years old. I'm using SQLPlus .

View 3 Replies View Related

Perform SELECT INTO In SQLPlus Script

Apr 11, 2007

I'm trying to perform a SELECT INTO in a SQL*Plus script.the script i'm working towards to, looks something like this;

set term on
set echo off
set serveroutput off
set verify off
ACCEPT ReportName PROMPT 'Please enter a report name; '
PROMPT
PROMPT retrieving current settings for &ReportName:
select STARTDATE, ENDDATE, SUFFIX
into pStart, pEnd, pSuffix
from MyTable
where NAME = '&ReportName';
[code]....

I'm basically trying to perform a select into based in user input and then put the retrieved data back to the console with a prompt. Is this possible within a sql script running on SQL*Plus?

View 3 Replies View Related

Sqlplus Copy Insert / Update

May 3, 2013

I have two identical tables from different DB's and I need to copy a row from db1 and insert into db2 if it does not exist or update it if it does(on the tables pk).

This is what i was trying until i realized replace drops the whole table where i thought it dropped the row and inserted the new.

copy
from db1
to db2
replace table2
using
select *
from table1
where x = blah

View 3 Replies View Related

Program That Uses SQLPlus To Run PLSQL Scripts

Oct 19, 2010

we have a program that uses SQLPlus to run PLSQL scripts - this program then checks the return code of SQLPlus to determine whether the script ran successfully. Our PLSQL scripts often call other PLSQL scripts via "@@OtherScript.sql" - one problem we have is that if (due to an engineering mistake) the OtherScript.sql file is missing, SQLPlus throws an SP2 error stating that the file was not found. However, the return code of SQLPlus does not indicate any problem. I have found, by searching the internet, that I can simply add a line "whenever OS error exit failure" to our script which then allows our program to detect the failure... however, the error message is not as informative:

CODESQL*Plus: Release 11.1.0.7.0 - Production on Tue Oct 19 10:28:45 2010
Copyright (c) 1982, 2008, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[code]....

is it possible to get BOTH types of error messages? With "oserror exit" set it does not tell you which file was not found.. which is useful information. I would like the SQL Plus session to return failure but also print out what file it did not find.

View 4 Replies View Related

SQLPLUS Script Needs To Exit On Completion

Dec 9, 2009

I have a series of sql files that I need to execute via sqlplus. What I do need is to immediately exit the sqlplus instance upon completion of the script. Now, I am not using a batch file, nor a file containing script files where I can add the EXIT command.

I have to effectively run each script from the command line as such:

sqlplus user/pass@server @c: empsomedirsomeScript.sql

Now this works, but once it runs the SQLPlus window is still open. Now I have an event handler (in a c# wrapper) that is supposed to fire once the process terminates...but of course, this even never fires since the sqlplus process doesn't terminate after running the script.

Is there any any any any way to get sqlplus to run this script and then self-exit??

I have no control of the sql script and cannot edit them to include an EXIT command. I need to run them as is.

View 5 Replies View Related

Sqlplus And MS Windows Command Line

Feb 18, 2013

I have some Oracle Databases and sometimes for me is easier to access to the databases with SQLPLUS instead SQLDEVELOPER or TOAD.

But i can't reach to a good configuration of command line prompt to do queries against the database, normaly if it returns a lot o rows and columns it is unreadable.

View 5 Replies View Related

Sqlplus Query Output Into File?

Feb 4, 2004

How can I put an Oracle sqlplus query output into file?

SQL> select myfield from userDB where IMSI like '22803%' and rownum < 11;

I would like to put the output in a file, say '/tmp/mydata.dat'

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved