How to view full script in sql*plus
Hi,
i am having a user who want to view the script for trigger by querying user_triggers in SQL*PLUS. i just remembered that there is some DBMS_ package for doing this. can anyone please provide that package name.
thanks in advance
Were you thinking of DBMS_METADATA?
Have a look at this: http://blogs.ittoolbox.com/database/solutions/archives/ddl-generationoracles-answer-to-save-you-time-and-money-7590
Similar Messages
-
How to run multiple scripts in sql*plus?
I would like to run 2 scripts in sql*plus, how do I do this? I tried the following, but it won't run.
create table student_new
AS
select *
from student
insert into student_new
(last_name, first_name
values
(Crop, Jenny)
The above are the two scripts I want to run, what am I doing wrong.
ThanksDo you have a solution to run multiple scripts continuosly, one after the other as one script.
Say I have file1.sql file2.sql, file3.sql.
I want to create a script run.sql, where this will run file1.sql,file2.sql,file3.sql one after other without any one running one after the other like follows:
run.sql should have
begin
@file1.sql
@file2.sql
@file3.sql
dbms_output.put_line(select sysdate from dual);
end;
If I run run.sql all the three scripts should be executed successfully and then display the current time . All these files have update statements(50,000 updates each file).
Very urgetn. Can some one hlpe, please.
Thanks in advance. -
How to retreive this file in SQL*Plus
If I upload files which name is KOREAN, name of files is invisible.
I dont't know cause of this problem.
How is keeping korean name of file from breaking?
Also, answer how to retreive this file in SQL*Plus
Thanks
silverbellTo access ifs data from SQL, you need to (officially) setup a 'user view'. Refer to the Java API documentation on how to do this. Once you have created the user view, then you may access this view using any SQL tool.
-
How to view alerlog contents using SQL?
How to view alertlog contents using SQL?
Hi,
Why don't you use the OEM Database Console ?? Now, in order to view the contents of the alert log file using a SELECT statement, you need to create a external table:
create or replace
directory background_dump_dest_dir
as '<your_oracle_home>/bdump';
CREATE table alert_log_external
(line varchar2(4000) )
ORGANIZATION EXTERNAL
(TYPE oracle_loader
DEFAULT DIRECTORY background_dump_dest_dir
ACCESS PARAMETERS (
RECORDS DELIMITED BY newline
nobadfile
nologfile
nodiscardfile
FIELDS TERMINATED BY '#$~=ui$X'
MISSING FIELD VALUES ARE NULL
(line)
LOCATION ('alert_<sid_of your_database>.log') )
REJECT LIMIT UNLIMITED;Cheers -
How to Generate Trace Files in SQL*Plus
Hi Friends ,
How to Generate Trace Files in SQL*Plus ?
i have no idea
thanks
rajWhat trace files would you like to generate?
Are we talking SQL trace files?
ALTER SESSION SET sql_trace = TRUE;This will be generated in the user_dump_dest on the server.
show parameter dump -
How to find session information in sql plus
Can someone please tell me how to find session information in sql plus? I specifically want to know my privileges for the current session. Thanks in advance.
SELECT * FROM session_privs;
SELECT * FROM session_roles; -
How to invoke multiple sessions of sql*plus thru pl/sql program
Hi
How to invoke multiple sessions of sql*plus thru pl/sql program.
ThanksHow to invoke sql*plus in a procedure?????
I have to invoke more pl/sql sessions?????No you don't "have to".
Look at what you are trying to do.
You have a program running inside the PL/SQL engine. This is running nicely inside the Oracle database and is perfectly capable of issuing other SQL statements, PL/SQL programs etc. inside it's nice cosy Oracle environment.
You are asking for this PL/SQL to shell out to the operating system, run an external application, for which it will have to supply a username and password (are you planning on hard coding those into your PL/SQL?), and then that external application is supposed to run more SQL or PL/SQL against the database.
a) Why hold all this code external to the database when it can quite happily reside on the database itself and be executed through jobs or whatever.
b) Consider what would happen if someone were to replace the external application with their own program of the same file name... they'd be able to capture the username and password for connecting to the database, therefore a major security flaw.
The whole idea of doing what you want through external calls to SQL*Plus is ridiculous. -
Accept input from Shell script in sql*plus
Hey! Guys..
i need the following info.
I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
thanks..
Harsh.prompt for input, pass to another shell
# contract_status_prompt.sh
read udate?"Enter week-ending date in format dd-mmm-yyyy: "
contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
echo `date`
# End contract_status_prompt.sh
Read the variable passed and use in SQLPlus:
# contract_status_update.sh
echo "Running contract_status.sh"
echo "create records for contract_status"
echo `date`
echo " "
echo " date used is "; print $1
echo " "
sqlplus <<exit
@$FDWSQL/sqlparms
set time on
prompt *** Set contract_status_period ***
update contract_status_period
set period_date = '$1';
commit;
exit
etc. -
How to control logic flow in SQL Plus script
Hi
I have the requirement below:
Before I start running an SQL script, I need to ensure that I am connecting as a particular user. If I am not that user, then the script should show a msg "Error - Invalid User - Log in as <<username>>"
Let's say i am executing a script A.sql.
SQL > @<path>a.sql
But before this script is executed -- i shall check for the user:
block begins...
select user into var1 from dual
if upper(var1) != 'ABCUSER' then
-- display the error message and stop execution of this script
else
@<path>a.sql (*it executes what i want :) )
end if;
block ends...
How do I write this code using an SQL script ? Pls suggesHi,
As Centinul said, SQL*Plus is poorly equipped to deal with problems like this. If possible, try to do what you want outside of SQL*Plus.
If you really have to do it in SQL*Plus, here are two ideas:
(1) run a script conditionally
(2) deliberately raise an error
(1) Using SQL*Plus substitution variables, you can decide which of several scripts to run as a sub-script, based on the results of some query.
For example, if a.sql is the script that only user ABCUSER is allowed to run, then write two other very short scripts:
(a) warning.sql, such as the following:
-- warning.sql
PROMPT You are not authorized to do this.
QUIT(b) step_1.sql, which decides whether a.sql or warning.sql should be run, and does it:
-- step_1.sql - Decide whether a.sql or warning.sql is to be run next, and do it.
-- (a) decide:
COLUMN script_name_col NEW_VALUE script_name
SELECT CASE
WHEN USER = 'ABCUSER'
THEN 'a.sql'
ELSE 'warning.sql'
END AS script_name_col
FROM dual;
-- do:
@&script_nameYou may want to use @@, or specify a complete path name.
(2) Deliberately raise an error, either in a separate script or in a.sql itself, like this:
WHENEVER SQLERROR EXIT
SELECT CASE
WHEN USER = 'ABCUSER'
THEN NULL
ELSE TO_NUMBER ('This will raise ORA-01722')
END AS "Welcome!"
FROM dual;
WHENEVER SQLERROR NONE
-- continue with the original a.sql -
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 -
Tracking the order of execution of sql scripts in SQL*Plus
In our production environment we sometimes have to run some .sql scripts in a particular order. Since the order of execution is important , i have created another .sql file caller caller.sql(shown at the bottom) which will call all the scripts in the right order.
i thought of putting a exec DBMS_LOCK.SLEEP (5); after the end of every execution of the script so that i can see the
'Ending script1'message .
The spooling within the caller script(execute_stack.log) has become meaningless because each script has a spool <filename.log> and spool off within it. These spool logs (for every script) is important for tracking purposes as each script belongs to a different development team and i have to send them the spooled log file after the execution.
I don't want to see the entire scripts running by in my screen. Since these scripts have their own spooling, i can later check the logs if the scripts where executed properly.
So i need two things.
1.I just need to see the following and nothing else in the screen.
Ending script1
Ending script2
Ending script3
.2. I need to log the order of execution. ie. the execute_stack.log should look like the above.Since there is a spool off within each script, this wouldn't be possible.Right?
Ending script1
Ending script2
Ending script3
.The caller.sql script which calls all the scripts in the right order
alter session set nls_date_format = 'DD-MON-YYYY hh24:MI:SS';
set serveroutput on
set echo on;
set feedback on;
spool execute_stack.log
@script1.sql
exec dbms_output.put_line ('Ending script1');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script2.sql
exec dbms_output.put_line ('Ending script2');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script3.sql
exec dbms_output.put_line ('Ending script3');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script4.sql
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec dbms_output.put_line ('Ending script3');
commit;
spool off;Is this a professional way of tracking the execution of .sql scripts?Pete_Sg1 wrote:
Is this a professional way of tracking the execution of .sql scripts?No. There is very little professional about using .sql scripts on a production system - when stored procedures are safer, more robust, easier managed and controlled and secure.. and where a log table can be used to properly log the runtimes (and other stats) of each processing step.
Let's just take a look at the number of moving parts you need to schedule and run a .sql script. A cron job needs to be configured with the proper environment setting. It needs to run a shell script. That shell script needs to load SQL*Plus. SQL*Plus needs to connect to the database (starting a dedicated server process most likely). SQL*Plus then needs to read a .sql file, parse these commands and either execute these locally (SQL*Plus commands) or remotely (PL/SQL and SQL commands).
How can this be considered professional when the very same can be achieved with a
- stored procedure
- using DBMS_JOB to schedule the procedure for execution
There are so many things that can go wrong with the first method. And so few things that could go wrong with the last one. No contest as to which method is not only better, but also professional.
PS. See that you use Windows to run these scripts. It is even worse as it introduces another hardware and software layer making the scenario even more insecure & unsafe with more moving parts that can go wrong or simply fail. -
After running sql scripts in SQL plus, where are the results(tables) stored
Hi ,
I am using oracleDb10g . i have used SQL plus to create a database. I have run 2 sql scripts and constructed the tables , but i dont know where the data is stored and how to make the data into a database, so that i can use it for connection through some UI.
for example: schema.sql, data.sql script files.
SQL> start schema.sql
SQL> start data.sql
The tables are created.
Now how can i group those table into a database and name it.(i mean i can create a database using SQL plus, but how to dump the tables into the database created). Because i want to use this database name for connecting to MS SQL, so i need the name.
Thanks
babu.when you are in Rome, sing with the romans !
Oracle is different from SQL Server.
Time to read some basic books.
--> http://tahiti.oracle.com -
How to get Arabic dates in SQL*Plus?
I want to do a very simple thing.
I want to type in Arabic and Display dates in Arabic.
Instead i get ????? ??????? ????? ??????? ? ? ???????, ????? for this?
Why is this?
I then changed my Windows XP "Regional and Language Options" all to Arabic. Now, I get AR (Arabic) in my language selection bar at the bottom of the Desktop. When I choose AR I can type Arabic in Notepad. ُ
Even HERE I can type in Arabic: فغحث غخعق ةثسسشلث اثقث
But in Sql*PLus I get ????? ??????? ????? ??????? ? ? ???????, ?????
If I choose AR in SQL Plus and type in Arabic I get garbage characters?
How to get Arabic in Sql*Plus?
SQL> SHOW USER
USER is "ARABDTEST"
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
SQL> SELECT * FROM nls_session_parameters;
PARAMETER VALUE
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
17 rows selected.
SQL> ALTER SESSION set NLS_DATE_LANGUAGE = 'ARABIC';
Session altered.
SQL> SELECT TO_CHAR(SYSDATE, 'RRRR/MM/DD YEAR MONTH DAY MON DY AM PM DL') FROM dual;
TO_CHAR(SYSDATE,'RRRR/MM/DDYEARMONTHDAYMONDYAMPMDL')
2013/04/08 TWENTY THIRTEEN ????? ??????? ????? ??????? ? ? ???????, ????? 08, 2013
SQL> ALTER SESSION set NLS_DATE_LANGUAGE = 'AMERICAN';
Session altered.
SQL> SELECT TO_CHAR(SYSDATE, 'RRRR/MM/DD YEAR MONTH DAY MON DY AM PM DL') FROM dual;
TO_CHAR(SYSDATE,'RRRR/MM/DDYEARMONTHDAYMONDYAMPMDL')
2013/04/08 TWENTY THIRTEEN APRIL MONDAY APR MON PM PM Monday, April 08, 2013
SQL> SELECT * FROM nls_database_parameters;
PARAMETER VALUE
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET WE8MSWIN1252
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 11.1.0.6.0
20 rows selected.I am not sure SQL*Plus in character mode can display Arabic characters on Windows. OTN NLS_LANG FAQ http://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html#_Toc105389288 says:
>
if you are testing with "special" characters please DO use the GUI and not the "DOS box" sqlplus.exe !
>
SQL*Plus GUI is not available with 11G: you should use SQL Developer. -
"ORA-1722 Invalid number" error while runing a SQL script in SQL*Plus
Hello,
I created a SQL script that is intended to populate tables with
baseline data. When I run the script in the SQL*Plus program
that comes with the Oracle 8.1.6 (client), I receive an "ORA-
1722 Invalid number".
The error always occurs when SQL*Plus tries to execute the
following SQL statement:
insert into components(db_ind,module_id,ext_compid,active) values
('cm',modules_seq.currval,1046682,'y');
The datatypes for the columns on the components table are as
follows:
db_ind varchar2(2);
module_id number;
ext_compid number;
active varchar2(1);
It seems that for some reason Oracle is having trouble
recognizing 1046682 as a number.
I also tried the following INSERT statements to see if that
would work:
insert into components(db_ind,module_id,ext_compid,active) values
('cm',modules_seq.currval,to_number('1046682'),'y');
insert into components(db_ind,module_id,ext_compid,active) values
('cm',modules_seq.currval,'1046682','y');
but I still receive the same error message
Is there some NLS setting(s) I need to modify so that Oracle
does not give me this error? Does anyone know the answer to
this problem?
Your help is greatly appreciated.
Oscar
(NOTE: I also receive this same error when trying run the
script in SQL Navigator and Toad programs)Please see the following docs.
R12: JBO-27122 Error Message Clicking On Supplier Accounting Link With Unexpected Error [ID 1218903.1]
Supplier Management Accounting Link Gives Unexpected Error and JBO-27122 at SELECT * FROM (select pvsa.ADDRESS_STYLE [ID 1340655.1]
Adding Accounting Information or Operating Unit Information fails with APP-FND-1564: ORACLE error 1722 in FDFGVD [ID 364265.1]
Thanks,
Hussein -
Interactive script in SQL*PLUS
Hi,
I am a student and we need to write a script to be executed in SQL*PLUS.
Script has to execute an insert statement but all values need to be provided during runtime and in the end there should be a question if you wan't to save data. When yes then commit when no then rollback.
Below is my code. Problem is that program asks for variables' values after beginning then it displays all dbms_output.put_line and then continue with pl/sql.
I want to for examle:
- display message 'provide date'
- covvert string date to date type
- when error then exit, when ok then continue
- provide other variables in the same way
- ask for saving.
My code:
SET SERVEROUTPUT ON
set verify off
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
declare
do_save varchar2(240) ;
v_ename varchar2(50);
v_job varchar2(50);
v_sal number;
v_hiredate date;
v_tmp varchar(50);
begin
DBMS_OUTPUT.put_line('Provide name:');
v_tmp := '&val_ename';
v_ename := v_tmp;
DBMS_OUTPUT.put_line('Provide salary:');
v_tmp := '&val_sal';
begin
v_sal := cast(v_tmp as number);
exception when others then
DBMS_OUTPUT.put_line('Incorrect salary format.');
end;
DBMS_OUTPUT.put_line('Provide data:');
v_tmp := '&val_hiredate';
begin
v_hiredate := to_date(v_tmp);
exception when others then
DBMS_OUTPUT.put_line('Incorrect date format.');
end;
INSERT INTO EMP(ENAME, SAL, HIREDATE)
VALUES (v_ename, v_sal, v_hiredate);
DBMS_OUTPUT.put_line('Do you want to save? [Y/N]');
do_save := '&val_save';
do_save := upper(ltrim(substr(nvl(do_save, 'N'), 1,1)));
IF do_save = 'Y' THEN
commit;
DBMS_OUTPUT.put_line('Data saved.');
ELSE
rollback;
DBMS_OUTPUT.put_line('Data rejected.');
END IF;
end;
/user10613699 wrote:
it is not solving my problem,...Why not? Did you test and also check the documentation link?
SQL> accept DO_SAVE prompt 'Do you want to save (Y/N)? ';
Do you want to save (Y/N)? Y
SQL> begin
2 if '&do_save' in ('Y','y') then
3 commit;
4 else
5 rollback;
6 end if;
7 end;
8 /
old 2: if '&do_save' in ('Y','y') then
new 2: if 'Y' in ('Y','y') then
PL/SQL procedure successfully completed.
SQL> Edited by: Sven W. on Nov 17, 2008 4:53 PM
Maybe you are looking for
-
please help me figure out why I cannot get my music library to load
-
Looking for a Bubble game i had on another mobile. Cant find so far
The concept of this bubble game was to match as many as possible to gain points and to have as many of the same colour all connected in some way gave massive points when deleted. This game was on my O2 XDA Trion & also had been on a similar model tha
-
SCRIPTED INSTALL of Windows XP on a Mac - possible?
Hi everyone. I've been tasked with getting our standard Windows build onto our new lab Macintosh's (for dual booting between Windows and Mac OS). Normally we would reload from a floppy image which connects over the network to the folder containing th
-
Can somebody please check this kernel panic
I'm running Mavericks. Thanks UUID: 68A58EDF-AFCB-E588-472C-AB1283196649 Sat Feb 28 22:29:58 2015 panic(cpu 1 caller 0xffffff801a7e384b): "new_vnode(0xffffff8036774780): free vnode still referenced"@/SourceCache/xnu/xnu-2422.115.10/bsd/vfs/vfs_
-
Outlook 2010 client - One of the user's sent items email shows as from address as invalid address
Hi, One of the user in exchange 2010 - outlook 2010 environment, in sent items email from address shows as invalid address after sent emails to recipients. Recipients are successfully received the emails. however, why the invalid address appearing in