SQL*Plus improvement suggestion - Filtered History Recall
Hello,
In various command line interpreters I've used, typing the first few characters of a command one wishes to recall, causes the history buffer to only cycle thru the entries that start with the characters typed.
It would be really convenient to see this feature, that is standard in many command line interpreters, be implemented in SQL*Plus.
For example, typing "sele" would cycle through lines that start with "sele" (such as select) and no other lines.
Thank you.
John.
Hello Jgarry,
>
I hate, hate, hate that, ...
>
You are probably thinking that I was talking about those annoying hints that get in your way as you type. I despise those things too. I'm not talking about that.
This is what I'm talking about.... say that you have typed a large number of commands in SQL*Plus since you started the session... the history buffer looks like this (abbreviated):
select empno, .....
insert into ....
create table ....
select deptno ...
drop table .... currently in SQL*Plus, if you press the up/down arrow, it will cycle thru the history showing the next/previous command in the history buffer...
what I'm suggesting is...
type the letter i then press the up arrow and SQL*Plus would cycle thru the commands that start with i in the history buffer (instead of mindlessly starting at the most recent command).. in the example above.. it would immediately place the "insert into ... " at the command line ready to be reexecuted, it there were multiple statements that start with i in the history buffer, it would only cycle thru those and ignore the others.
currently SQL*Plus ignores anything typed at the command line when the up/down arrow is pressed, it simply overwrites it with whatever is the first command in the histroy buffer. This behavior makes it inconvenient to recall a command that was issued many commands ago. (not to mention that when you're used having the feature and then having SQL*Plus overwrite the partial command is highly annoying)
Hopefully this makes the feature I am asking for a little clearer. It's worth noting that most command line based utilities have this filter feature, SQL*Plus is a rare exception.
John.
Edited by: 440bx - 11gR2 on Aug 11, 2010 4:51 PM - reworded last line for clarity
Similar Messages
-
A question about the impact of SQL*PLUS SERVEROUTPUT option on v$sql
Hello everybody,
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>
OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64I would like to ask a question about the SQL*Plus SET SERVEROUTPUT ON/OFF option and its impact on queries on views such as v$sql and v$session. Here is the problem
Actually I define three variables in SQL*Plus in order to store sid, serial# and prev_sql_id columns from v$session in order to be able to use them later, several times in different other queries, while I'm still working in the current session.
So, here is how I proceed
SET SERVEROUTPUT ON; -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
SET SQLBLANKLINES ON;
VARIABLE mysid NUMBER
VARIABLE myserial# NUMBER;
VARIABLE saved_sql_id VARCHAR2(13);
-- So first I store sid and serial# for the current session
BEGIN
SELECT sid, serial# INTO :mysid, :myserial#
FROM v$session
WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
END;
PL/SQL procedure successfully completed.
-- Just check to see the result
SQL> SELECT :mysid, :myserial# FROM DUAL;
:MYSID :MYSERIAL#
129 1067
SQL> Now, let's say that I want to run the following query as the last SQL statement run within my current session
SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;According to Oracle® Database Reference 11g Release 2 (11.2) description for v$session
http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
the column prev_sql_id includes the sql_id of the last sql statement executed for the given sid and serial# which in the case of my example, it will be the above mentioned SELECT query on the employees table. As a result, right after the SELECT statement on the employees table I run the following
BEGIN
SELECT prev_sql_id INTO :saved_sql_id
FROM v$session
WHERE sid = :mysid AND serial# = :myserial#;
END;
PL/SQL procedure successfully completed.
SQL> SELECT :saved_sql_id FROM DUAL;
:SAVED_SQL_ID
9babjv8yq8ru3
SQL> Having the value of sql_id, I'm supposed to find all information about cursor(s) for my SELECT statement and also its sql_text value in v$sql. Yet here is what I get when I query v$sql upon the stored sql_id
SELECT child_number, sql_id, sql_text
FROM v$sql
WHERE sql_id = :saved_sql_id;
CHILD_NUMBER SQL_ID SQL_TEXT
0 9babjv8yq8ru3 BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;Therefore instead of
SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;for the value of sql_text I get the following value
BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);Which is not of course what I was expecting to find in v$sql for the given sql_id.
After a bit googling I found the following thread on the OTN forum where it had been suggested (well I think maybe not exactly for the same problem) to turn off SERVEROUTPUT.
Problem with dbms_xplan.display_cursor
This was precisely what I did
SET SERVEROUTPUT OFFafter that I repeated the whole procedure and this time everything worked pretty well as expected. I checked SQL*Plus documentation for SERVEROUTPUT
and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
Could anyone kindly make some clarification?
thanks in advance,
Regards,
Dariyoosh>
and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
Hi Dariyoosh,
SET SERVEROUTPUT ON has the effect of executing dbms_output.get_lines after each and every statement. Not only related to system view.
Here below what Tom Kyte is explaining in this page:
Now, sqlplus sees this functionality and says "hey, would not it be nice for me to dump this buffer to screen for the user?". So, they added the SQLPlus command "set serveroutput on" which does two things
1) it tells SQLPLUS you would like it <b>to execute dbms_output.get_lines after each and every statement</b>. You would like it to do this network rounding after each call. You would like this extra overhead to take place (think of an install script with hundreds/thousands of statements to be executed -- perhaps, just perhaps you don't want this extra call after every call)
2) SQLPLUS automatically calls the dbms_output API "enable" to turn on the buffering that happens in the package.Regards.
Al -
Hi
We have a big problem, We can't create internal orders, when I run the CREATE INTERNAL ORDER, it finish with ERROR:
Concurrent Manager encountered an error while running SQL*Plus for your concurrent request 134980682.
Review your concurrent request log and/or report output file for more detailed information.
this is the log:
+---------------------------------------------------------------------------+
Purchasing: Version : 12.0.0
Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
POCISO module: Create Internal Orders
+---------------------------------------------------------------------------+
Current system time is 26-JUL-2013 09:21:09
+---------------------------------------------------------------------------+
+-----------------------------
| Starting concurrent program execution...
+-----------------------------
+---------------------------------------------------------------------------+
Start of log messages from FND_FILE
+---------------------------------------------------------------------------+
Begin create internal sales order
Updating Req Headers
14 Reqs selected for processing
Top of Fetch Loop
Source Operating Unit: 82
Selecting Currency Code
Currency Code : MXP
Selecting Order Type
Order Type ID:1001
Selecting Price List from Order Type
Deliver To Location Id: 196
Inserting Header : 3908784
Getting the customer id
Getting the customer id: 15334
Unhandled Exception : ORA-01403: no data found
+---------------------------------------------------------------------------+
End of log messages from FND_FILE
+---------------------------------------------------------------------------+
Concurrent Manager encountered an error while running SQL*Plus for your concurrent request 134980682.
Review your concurrent request log and/or report output file for more detailed information.
+---------------------------------------------------------------------------+
Executing request completion options...
Output file size:
78
Output is not being printed because:
The print option has been disabled for this report.
Finished executing request completion options.
+---------------------------------------------------------------------------+
Concurrent request completed
Current system time is 26-JUL-2013 09:21:14
+---------------------------------------------------------------------------+
Some suggestion for resolve it??
Thanks & Regards.In the document 294932.1 Section 4 there are no pre-installation patches or update for OS RedHat LinuxAS4.
When I type echo $LD_ASSUME_KERNEL it doesn't display any value so do I need to set the LD_Assume_Kernal value manually.
If yes, please let me know the path and command to set the kernel value.
Thanks
Amith -
Oracle 9.0.1 SQL*Plus and PL/SQL
Having just upgraded from Oracle 8.0.1 to the above, can anyone suggest a good book for learning the above languages as I believe there is quite a lot of difference in the codes, which also contains some good exercises for trying them out.
Phil.I would take a look at this for PL/SQL:
Oracle PL/SQL Programming, 3rd Edition
If you want to learn SQL, you can try this book, which some people I know have liked: Mastering Oracle SQL
For the extra features of SQL*Plus, the Oracle manual is very complete and should be sufficient. -
SQL*Plus Raises: ORA-3113 End of file on communication channel
I have a Win2000 machine running Oracle client 8i, connecting to an HP-UX server running 9i RAC, with an unknown collection of switches/firewalls in between. Using SQL*Plus I can successfully connect and run queries. However, if I leave the session idle for some time, approximately 15 minutes (though this varies), the next query I execute hangs for a few seconds, then returns with ORA-3113.
I have enabled client-side tracing (ADMIN level). The following extract shows the point at which an error first occurs:
nsprecv: reading from transport...
nttrd: entry
ntt2err: entry
ntt2err: soc 660 error - operation=5, ntresnt[0]=517, ntresnt[1]=54, ntresnt[2]=0
ntt2err: exit
nttrd: exit
nsprecv: transport read error
nserror: nsres: id=0, op=68, ns=12547, ns2=12560; nt[0]=517, nt[1]=54, nt[2]=0; ora[0]=0, ora[1]=0, ora[2]=0
nsdo: nsctxrnk=0
nioqrc: wanted 1 got 0, type 0
nioqper: error from nioqrc
nioqper: nr err code: 0
nioqper: ns main err code: 12547
nioqper: ns (2) err code: 12560
nioqper: nt main err code: 517
nioqper: nt (2) err code: 54
nioqper: nt OS err code: 0
nioqer: entry
nioqce: entry
nioqce: exit
nioqer: exit
nioqrc: exit
nioqbr: entry
nioqbr: state = normal (0)
nioqsm: entry
nsdo: cid=0, opcode=67, bl=1, what=17, uflgs=0x100, cflgs=0x3
nsdo: rank=64, nsctxrnk=0
nsdo: nsctx: state=1, flg=0x420d, mvd=0
nsdo: nsctxrnk=0
nioqsm: send-break: failed to send break...
nioqper: error from send-marker
nioqper: nr err code: 0
nioqper: ns main err code: 12583
nioqper: ns (2) err code: 0
nioqper: nt main err code: 0
nioqper: nt (2) err code: 0
nioqper: nt OS err code: 0
nioqsm: exit
A google search returned one page that suggests the culprit here is the line:
ntt2err: soc 660 error - operation=5, ntresnt[0]=517, ntresnt[1]=54, ntresnt[2]=0
This apparently indicates that the network timed out, a sign of a busy network.
Can anyone:
a) Confirm this or otherwise;
b) Suggest how I may go about proving this to a corporate network operations team;
Cheers, Si.I think the reason can be timeout on one of the firewalls. Network administrators
quite often configure following setting:
"Disconnect idle connection after 15 minutes" - I facedd this problem several
times.
Best Regards
Krystian Zieja / mob -
How to detect client OS from SQL*Plus script
Sometimes in a SQL*Plus script I need to execute OS commands e.g.
host rm tempfile.bufHowever of course Windows has no "rm" command by default, so I have to edit the script to use
host del tempfile.bufNow if I could define &DELETE (for example, "cat"/"type" is another) as a substitution variable, I could just use
host &DELETE tempfile.bufMaybe I need more coffee but all I could come up with was something like this:
def rm=rm
def cat=cat
spool sqlplus_windows_defs.cmd
prompt echo def rm=del
prompt echo def cat=type
spool off
host .\sqlplus_windows_defs > sqlplus_windows_defs.sql
@sqlplus_windows_defs.sql
host &rm sqlplus_windows_defs.cmd
host &rm sqlplus_windows_defs.sqlthe idea being that you first define the variables for nix ("rm" and "cat"), then attempt to create and execute a Windows command file containing DOS versions ("dele" and "type"), which does not run under nix. Unfortunately the OS failure message (".sqlplus_windows_defs: not found" in Unix) appears on the screen despite SET TERM OFF, so I'm back where I started.
I know there are various ways to get the server OS, and you can get the SQL*Plus version with &_SQLPLUS_RELEASE and so on, but I can't see a way to determine the client OS. Any suggestions?Thanks guys. This seems to work in Windows XP - will try on Unix when I get a chance:
col DELETE_COMMAND new_value DELETE_COMMAND
col LIST_COMMAND new_value LIST_COMMAND
def list_command = TYPE
def delete_command = DEL
SELECT DECODE(os,'MSWIN','TYPE','cat') AS list_command
, DECODE(os,'MSWIN','DEL','rm') AS delete_command
FROM ( SELECT CASE WHEN UPPER(program) LIKE '%.EXE' THEN 'MSWIN' END AS os
FROM v$session
WHERE audsid = SYS_CONTEXT('userenv','sessionid') );
host &LIST_COMMAND xplan_errors.lst
host &DELETE_COMMAND xplan_errors.lstIf the user doesn't have access to v$session it will just default to the Windows commands.
http://www.williamrobertson.net/code/xplan.sql -
Launching SQL*Plus from JDeveloper on a Mac?
I am trying to get SQL*Plus to launch from the Tools menu in JDeveloper.
Has anyone gotten this to work?ah, "a feature to recommend" ... sorry Deepak,
Oracle replied with "Suggestion Rejected" and the motivation "... As passing an unencrypted behavior (the old behavior) is not secure and a violation of company policy, it will not be re-implemented. ...".
see related thread
"launch SQL*Plus is a violation of company policy"
launch SQL*Plus is a violation of company policy
greetings
Jan Vervecken -
Unable to connect to an instance using EM but connecting fine with SQL*Plus
Good morning,
I followed these steps (from the 2 Day DBA document):
1. I created a template (including database) from an instance named "orcl" using DBCA, before proceeding to create the template, DBCA informed me that the instance would be shutdown, I told it to proceed.
2. The template was created successfully.
3. I am now unable to log into the orcl instance using EM, yet I can log into that instance without any problems using SQL*Plus.
The Question: Why am I not able to connect to the instance using EM ? and what do I need to do to correct this problem ?
Thank you very much for your help,
John.
PS: in case it may be helpful, the listener, tnsnames and Sqlnet files follow:
# listener.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = E:\Oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\Oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
ADR_BASE_LISTENER = E:\Oracle
# tnsnames.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
DBCA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbca.localsite.com)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE2DAY1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.localsite.com)
# sqlnet.ora Network Configuration File: E:\Oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)Hi Chinar,
What you suggested solved the problem.
I am grateful for your help but, please, the next time you suggest a process that takes over an hour to complete, let me know beforehand.
thank you for your help, I do appreciate it.
John.
PS: here are the result of the process:
0 07:57 [Oracle] [17G] [608M] E:\Temp>emca -deconfig dbcontrol db -repos drop
STARTED EMCA at Aug 15, 2010 7:58:21 AM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: orcl
Listener port number: 1521
Password for SYS user:
Password for SYS user: abc123
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: y
Aug 15, 2010 7:59:37 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at E:\Oracle\cfgtoollogs\emca\orcl\emca_201
0_08_15_07_58_21.log.
Aug 15, 2010 7:59:38 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be p
erformed.
Aug 15, 2010 7:59:38 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Aug 15, 2010 8:06:59 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Aug 15, 2010 8:07:17 AM
0 08:09 [Oracle] [17G] [355M] E:\Temp>emca -config dbcontrol db -repos create
STARTED EMCA at Aug 15, 2010 8:09:23 AM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: orcl
Listener port number: 1521
Listener ORACLE_HOME [ E:\Oracle\product\11.2.0\dbhome_1 ]:
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Password for SYSMAN user: Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
You have specified the following settings
Database ORACLE_HOME ................ E:\Oracle\product\11.2.0\dbhome_1
Local hostname ................ 192.168.3.134
Listener ORACLE_HOME ................ E:\Oracle\product\11.2.0\dbhome_1
Listener port number ................ 1521
Database SID ................ orcl
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............
Do you wish to continue? [yes(Y)/no(N)]: y
Aug 15, 2010 8:10:51 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at E:\Oracle\cfgtoollogs\emca\orcl\emca_201
0_08_15_08_09_23.log.
Aug 15, 2010 8:11:10 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Aug 15, 2010 8:43:41 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Aug 15, 2010 8:44:09 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepos
itory
INFO: Uploading configuration data to EM repository (this may take a while) ...
Aug 15, 2010 8:47:39 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Aug 15, 2010 8:48:31 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareL
ib
INFO: Software library configured successfully.
Aug 15, 2010 8:48:31 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibra
ry
INFO: Deploying Provisioning archives ...
Aug 15, 2010 8:53:19 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibra
ry
INFO: Provisioning archives deployed successfully.
Aug 15, 2010 8:53:34 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Aug 15, 2010 8:54:22 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Aug 15, 2010 8:54:38 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Aug 15, 2010 9:12:50 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Aug 15, 2010 9:13:09 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://192.168.3.134:5501/em <<<<
<<<<<<<
Aug 15, 2010 9:14:22 AM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************ WARNING ************************
Management Repository has been placed in secure mode wherein Enterprise Manager
data will be encrypted. The encryption key has been placed in the file: E:/Orac
le/product/11.2.0/dbhome_1/192.168.3.134_orcl/sysman/config/emkey.ora. Please
ensure this file is backed up as the encrypted data will become unusable if this
file is lost.
Enterprise Manager configuration completed successfully
FINISHED EMCA at Aug 15, 2010 9:14:22 AM
0 09:14 [Oracle] [17G] [603M] E:\Temp> -
Where its not possible to use a variable (&&var) in SQL*PLUS ?
SQL*Plus Command Reference - DEFINE
Whenever you run a stored query or script, SQL*Plus substitutes the value of variable for each substitution variable referencing variable (in the form &variable or &&variable)
The question is which are the limits of this. Can eg even be between a 'STR&&varING' passed as parameter to some function? Or as parameter I can pass only a single variable and there isnt such auto-casting level ?
I have created DBCA Scripts to batch create a DB. So I want inside these scripts to replace the DBNAME with a variable. So I can create different DBS with these prescriptions from an API tool.
E.g here there are 6 different scenarios where I might need to pass the variable. I dont know
1. On which of the bellow scenarios I can inject the &&var
2. On which I cant and thus have to create a 2nd VAR to inject the 1st one
3. Which dont accept variables at all - but only static text
@D:\app\admin\DBNAMEY\scripts\CreateDB.sql
spool D:\app\admin\DBNAMEY\scripts\CreateDB.log append
startup nomount pfile="D:\app\admin\DBNAMEY\scripts\init.ora";
CREATE DATABASE "DBNAMEY"
DATAFILE 'D:\app\oradata\DBNAMEY\system01.dbf' SIZE ...
GROUP 2 ('D:\app\oradata\DBNAMEY\redo02.log') SIZE 51200K,
I may not start testing the scripts 6 times fearing corrupting my Workstation on half executed scripts.GoodfireGeorge wrote:
SQL*Plus Command Reference - DEFINE
Whenever you run a stored query or script, SQL*Plus substitutes the value of variable for each substitution variable referencing variable (in the form &variable or &&variable)
The question is which are the limits of this. Can eg even be between a 'STR&&varING' passed as parameter to some function? Or as parameter I can pass only a single variable and there isnt such auto-casting level ?
I have created DBCA Scripts to batch create a DB. So I want inside these scripts to replace the DBNAME with a variable. So I can create different DBS with these prescriptions from an API tool.
E.g here there are 6 different scenarios where I might need to pass the variable. I dont know
1. On which of the bellow scenarios I can inject the &&var
2. On which I cant and thus have to create a 2nd VAR to inject the 1st one
3. Which dont accept variables at all - but only static text
@D:\app\admin\DBNAMEY\scripts\CreateDB.sql
spool D:\app\admin\DBNAMEY\scripts\CreateDB.log append
startup nomount pfile="D:\app\admin\DBNAMEY\scripts\init.ora";
CREATE DATABASE "DBNAMEY"
DATAFILE 'D:\app\oradata\DBNAMEY\system01.dbf' SIZE ...
GROUP 2 ('D:\app\oradata\DBNAMEY\redo02.log') SIZE 51200K,
I may not start testing the scripts 6 times fearing corrupting my Workstation on half executed scripts.
If you can't test because you are afraid the test might fail, you need to address that issue first. No one on the web is going to give you iron-clad assurance that some code you write is going to work exactly as you expect.
Your script is trying to create a database? What's the worst thing that can happen if it doesn't work? Do you know how to manually dis-mantle whatever your script does? If not, you need to learn. The knowledge you will gain from that exercise will go a long way to improving your understanding of how these things interrelate. -
HI,I came to know that direct exit from SQL Plus without Oracle shutdown causes future issues of ORA-0600 kind of errors. Is it true? If yes could u pls suggest me how to shutdown from user "SYSTEM/manager". Bcoz with this am warned that I dont have previleges.
Hello,
HI,I came to know that direct exit from SQL Plus without Oracle shutdown causes future issues of ORA-0600 kind of errors. Is it true?The ORA-00600 is an internal error it can be caused for instance by a Bug, a corruption, ... , and if someday you experience this kind of error, you should open a Service Request to My Oracle Support.
However, I've never heard that exiting sqlplus could cause this kind of error. Where did you get such information ?
how to shutdown from user "SYSTEM/manager". To shutdown the database you should be connected with the User SYS (as SYSDBA). You may use the following statement:
sqlplus /nolog
connect / as sysdba
shutdown immediate;
exitHope this help.
Best regards,
Jean-Valentin -
How to append timestamp to log file in SQL*Plus ?
Version: 11.2.0.3
Platform : RHEL 5.8 (But I am looking for platform independant solution)
I want to append the timestamp to spooled log file name in SQL*Plus.
The spooled log filename should look like
WMS_APP_23-March-2013.logI tried the following 3 methods found in the google. But none of them worked !
I tried this
col sysdt noprint new_value sysdt_var
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt_var.Logas suggested in
http://power2build.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
and this
spool filename with timestamp
col sysdt noprint new_value sysdt
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt..Logas suggested in
http://powerbuildev.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
and this
column tm new_value file_time noprint
select to_char(sysdate, 'YYYYMMDD') tm from dual ;
prompt &file_time
spool logfile_id&file_time..logas suggested in
Creating a spool file with date/time appended to file name
None of the above worked in RHEL or MS DOS. Any workaround ?I have tested your suggestions. But I still couldn't append the date to the logfile in RHEL or MS DOS SQL*Plus
Here are the attempts I've made. I am posting how the logfile looked like after every test.
#Attempt1 with two dots (&sysdate..log )
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog.&sysdate..log
select 'hello' from dual;
spool off;Log File Name -- > testlog.&sysdate..log
#Attempt2 with single dot (&sysdate.log)
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog.&sysdate.log
select 'hello' from dual;
spool off;Log File Name ---> testlog.&sysdate.log
#Attempt3. Replacing first dot with Hyphen (testlog- ) to check if the first dot was causing the issue
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SYSDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog-&sysdate.log
select 'hello' from dual;
spool off;Log Filename: testlog-&sysdate.log
#Attempt4: replacing SYSDATE with SDATE
set echo on
set feedback on
set define off
set pages 999
column dcol new_value SDATE noprint
select to_char(sysdate,'YYYYMMDD') dcol from dual;
spool testlog1.&SDATE..log
select 'hello' from dual;
spool off;Log File Name -- > testlog1.&SDATE..log -
Using Bind variables in SQL PLUS Report
using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
error: Bind Variable "ENDING_DATE" not declared
Report Date and Time:
26-OCT-2010 15:44:13
List of Unapproved Adjustments
Bind Variable 'ENDING_DATE" not declared
Please see below the code for the sql plus report:
define p_org_id = '&1'
define p_fy_begin_date = '&2'
define p_start_date = '&3'
define p_end_date = '&4'
define p_conversion = '&5'
declare
variable begin_date date;
exec :begin_date := p_start_date;
variable ending_date date;
exec :ending_date := p_end_date;
/* Begin
:begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
:ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
End; */
set newpage none
set termout off
set pagesize 55
set linesize 180
set heading on
set feedback off
set wrap off
set space 1
set heading on
begin
dbms_application_info.set_client_info('&p_org_id');
end;
prompt
prompt Report Date and Time:
prompt ----------------------
select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
from dual ;
prompt
prompt List of Unapproved Adjustments
prompt -------------------------------
select b.trx_number,
a.adjustment_number,
f.user_name created_by
from apps.ar_adjustments a,
apps.ra_customer_trx b,
apps.fnd_user f
where a.customer_trx_id = b.customer_trx_id
and a.status <> 'A'
and a.created_by = f.user_id
and a.creation_date between :begin_date
and :ending_date
-- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
-- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
order by
b.trx_number ;Hi
Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
vishnu
null -
Set Column width in query (not using SQL*Plus)
How can I Set Column width in query
I understand you can set column width using
column col1 FORMAT A5
select col1 from table1;But this only works in SQL*Plus
I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
I am using a 'SQL window' in PL/SQL Developer IDE
and when I use this syntax it says:
ORA-00900: Invalid SQL statement
Any suggestions are appreciated...
thanks,
M.Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
e.g.
SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM -
I've just installed Oracle 9i to Windows 2000 server. When I use SQL*Plus, it asked for a username and password. But when I installed Oracle 9i, it never asked me to create user. Then I tried logging in using windows 2000 username and it still did not worked. Is there any default username (like 'root' maybe). Thanks.
There was a dialog displayed during installation that gave you the default logins. They are:
scott/tiger
system/manager
sys/change_on_install
Your Windows login has nothing to do with your Oracle9i login, with the exception of the ORA_DBA group, but that's a whole other discussion that I won't go into here.
I suggest you get reading some Oracle documetation at http://tahiti.oracle.com.
Alison -
SQL * PLUS WORKSHEET wrapping
I am using the SQL*Plus: Release 8.1.6.0.0 and the query gives us a wrapping results which is so hard to read and takes awhile to execute.
The default value for SQL*Plus LINESIZE is 80 and for PAGESIZE is 25. If the row of records select increases 80 then the records start wrapping. The suggestions are
1>. either limit the columns selected. i.e. instead of using SELECT * from TABLE use
SELECT col_a, col_b ... from TABLE
2>. increase the linesize by using the following
SET LINESIZE 300 ;
The valid values for linesize are 0 through 32767.
However, if you increase the linesize to a very high value, then you will need to do horizontal scroll to see all the columns.
Maybe you are looking for
-
-23045 AuthNameErr in Mac Manger for OS9 after upgrading to 10.4
Hello all. We have recently upgraded our G4 based Xserve from 10.3 to 10.4 Server. In the process because of several network changes done over this holiday season I also had to change the IP address of this server from 10.0.16.45 to 10.1.12.230. At t
-
Hard drive died--need help booting
Hi all, I recently replaced my internal HD with a 320 and life was grand until last night, when I noticed the dreaded clicks, etc coming from my HD. I figured I better back up, but no luck, the thing refuses to cooperate. When I restart, I eventually
-
Stuckup in search help FM!!
hi experts.... I have a simple report, where i need to populate search help. the below is the coding wat i have used, but fetching a error. pls help me out, Thnx alot . if u want to see the entire coding too i will send... Regards Rachel. seLECTION-S
-
Allocation Base report.
Dear Team, I have to fect a report based on Internal order/cost center/Cost sheet wise. The required logic will be like below: the report should show the Pool, Target, and Total amount% Through which will come to know the total all balances have bee
-
Forum account problem..
Hi to all! many time i have created in this forum new account.. i can work on this forum at same time when i had creatd.. but when i logout or closing the site or forum and tr to next time login it is not identify me as previously user.. i have to cr