Setting security context in sql*plus session
Hi,
For a SQL*Plus session under an account that doesn't have execute privileges on fnd_global, is there any way to set the application security context similar to the way fnd_global.apps_initialize does?
For example, as APPS one can do this:
<br>
sqlplus apps/...
SQL> select SYS_CONTEXT('FND','USER_ID' ) as fnd_user_id from dual;
FND_USER_ID
1 row selected.
SQL> execute fnd_global.apps_initialize( ... );
SQL> select SYS_CONTEXT('FND','USER_ID' ) as fnd_user_id from dual;
FND_USER_ID
123456
1 row selected.What I'd like to do is something like this ...
<br>
sqlplus scott/...
SQL> ... call some EBizSuite procedure where I can supply or
be prompted for an EBizSuite user name, password, and responsibility ...
SQL> select SYS_CONTEXT('FND','USER_ID' ) as fnd_user_id from dual;
FND_USER_ID
123456
1 row selected.
Hi
Is there any method to initialize the environment using Java API.
how to call the function fnd_global.apps_initialize
Can you explain the required parameters.
Asheesh
Similar Messages
-
How to block Sql Plus sessions in Oracle 10g
Hi,
I want to block all sql plus sessions in oracle 10g, as we have a application and we need each and every one to use this application not the sql plus session.
Kindly update us as soon as possible. and also thanks in advanced.Understand the concept Karl, but a layered defense seldom works in the IP world. If I manage to get through the firewall, then how can you prevent me access, at IP level, at any other ISO stack layer? If you manage to get through, then your firewall policies could just be too weak :) at least you must have some kind of an IDS infrastructure in place..
what I mean is, you can have infinite number of threats.. and this will be part of your Risk Analysis. Determining all possible threats to the assets, what are being protected and their associated value, and predicting the rate of occurrence.... with all of these you could probably come up with contingency plans and incident response.. And most of all, you should not ignore the fact that people are creative, ingenious, and curious, and they'll prove this to you by testing your security implementations. So you'll have to periodically evaluate your security.. that's why there are audits.. Also, you must balance Security, Performance, Usability, and your Budget.
Yes, you can argue that if the entire firewall goes down (thus no IP defense), then something like DBV (or even denying IPs in sqlnet) can provide some defense. But is that not then a case of too little too late? It's better too little too late, than no protection at all... Imagine if there's no DBV, or if you have not implemented the concept of "Least Privilege"? or if the backups and exports are not encrypted? That would be more devastating.. that's the importance of database security options and features in providing "defense in depth"
I question just what purpose and how effective IP packet security is at higher layers. It can never substitute doing this instead at firewall level. Well, it's not all about network security. All facets must be considered and the inter-relationships should be understand. Like the core information security and access management, physical and personnel security, training them, etc... And all of these are equally important in providing a secure ecosystem
As for security that relies on the client to pass secure data (like executable name or o/s user name)... all this can easily be spoofed. Even if the app and Oracle driver are somehow digitally signed and these signatures can be verified on the server side, we only need to look at Vista to see how secure this really would be. Microsoft attempted to encrypt every single h/w and s/w layer from the physical DVD track to the pixel on the monitor.. and this was defeated. And this was done as o/s kernel level. It is less complex to hack at driver level and even trivial to do it at application level.Security is about risk management. Blocking SQL*Plus does not negate the risk of SQL from the wild being run on a production server. For example, the client is a VB client using ODBC. It is easy to create a proxy that accepts the ODBC connection from the VB client and proxy the OCI packets to the real Oracle server. Now you have a man-in-the-middle than can inspect every single SQL call made to Oracle, and inject any PL/SQL or SQL code it wants.
Security is far beyond writing a login trigger to deny SQL*Plus sessions and calling that a defense. >
Yes I agree with you. That's why there are independent organizations and regulating bodies that provides security best practices, to give us a headstart on comming up of strong security policies.
And one of my favorites is the one provided by IASE (sponsored by Defense Information Systems Agency) where there's lot of content regarding hardening and policies
http://iase.disa.mil/stigs/stig/index.html
http://iase.disa.mil/stigs/checklist/index.html
http://iase.disa.mil/stigs/SRR/index.html
- Karl Arao
http://karlarao.wordpress.com -
SQL Plus session - "schema.package" has been invalidated on making any chng
Hi
I am in the process of testing a stored procedure. Whenever I make changes to the procedure I am executing it from the SQL Plus session. But whenever I make a change to the procedure - i have to close that particular SQL Plus session and open another one. I get the message:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-04061: existing state of has been invalidated
ORA-04061: existing state of package body
"schema.package" has been invalidated
ORA-04065: not executed, altered or dropped package body
Is there a way that I do not have to open a new SQL Plus session everytime I make change to the package?It does not help :(. I get this problem in a SQL+ session only when I make a change in a JDev session. I have to log off the SQL+ session and log back in and it is OK again without re-compling anything. I don't have a problem with two SQL+ session. Isn't that strange?
ben -
How to Strip Extraneous Output from SQL*Plus Session
We are running Oracle Database 11g on Solaris 10, and I am trying to use SQL*Plus to create a temporary .sql file that I can execute in a later step of a Korn shell script. Here is the code:
$ORACLE_HOME/bin/sqlplus / as sysdba <<EOF
--whenever oserror exit failure;
--whenever sqlerror exit sql.sqlcode;
set serveroutput on
set termout off
set trimspool on
set verify off
set heading off
set feedback off
set echo off
spool /usr/oracle/temp/apply_site_security_for_oracle_database_11g.ksh.tmp
declare
Value_DSC varchar2(2000);
CommandLine_DSC varchar2(4000);
begin
select v\$parameter.value into Value_DSC from v\$parameter where lower(name)='diagnostic_dest';
CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
dbms_output.put_line(CommandLine_DSC);
CommandLine_DSC := 'host ls -ld ' || Value_DSC;
dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
dbms_output.put_line(CommandLine_DSC);
end;
spool off;
exit;
EOF
I've tried to turn off everything I don't need, but I am missing something. When I run the script, I get the following in the temporary file:
SQL>
SQL> declare
2 Value_DSC varchar2(2000);
3 CommandLine_DSC varchar2(4000);
4
5 begin
6 select v$parameter.value into Value_DSC from v$parameter where lower(name)='diagnostic_dest';
7
8 CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
9 dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
10 dbms_output.put_line(CommandLine_DSC);
11
12 CommandLine_DSC := 'host ls -ld ' || Value_DSC;
13 dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
14 dbms_output.put_line(CommandLine_DSC);
15 end;
16 /
--Ready to execute: host chmod 751 /s01/app/oracle
host chmod 751 /s01/app/oracle
--Ready to execute: host ls -ld /s01/app/oracle
host ls -ld /s01/app/oracle
SQL>
SQL> spool off;
I am hoping to whittle this down to just the following lines so I can execute them as a script.
--Ready to execute: host chmod 751 /s01/app/oracle
host chmod 751 /s01/app/oracle
--Ready to execute: host ls -ld /s01/app/oracle
host ls -ld /s01/app/oracle
Any ideas?
Edited by: shew01 on Jan 19, 2010 10:51 AMI just found it. Just add "-S" to the sqlplus command. Argh... I hunted for that a while back. Why didn't I remember it??????????
This works:
$ORACLE_HOME/bin/sqlplus -S / as sysdba <<EOF
whenever oserror exit failure;
whenever sqlerror exit sql.sqlcode;
set serveroutput on
set linesize 2000
set pagesize 0
set termout off
set trimspool on
set feedback off
spool /usr/oracle/temp/apply_site_security_for_oracle_database_11g.ksh.tmp
declare
Value_DSC varchar2(2000);
CommandLine_DSC varchar2(4000);
begin
select v\$parameter.value into Value_DSC from v\$parameter where lower(name)='diagnostic_dest';
CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
dbms_output.put_line(CommandLine_DSC);
CommandLine_DSC := 'host ls -ld ' || Value_DSC;
dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
dbms_output.put_line(CommandLine_DSC);
end;
spool off;
exit;
EOF
Edited by: shew01 on Jan 19, 2010 11:02 AM -
Question about setting column width in SQL*Plus using info retrieved w SQL
Good morning,
Is there a way to tell SQL*Plus to set the width of a column to the greatest width of the elements found in the column ? (as opposed to the default which is the width declared in the DDL)
In other words, I'd like to do something functionally equivalent to this:
COL <columname> format a[select max(length(<columnname>)) from <thetablethatcontainscolumname>]
I'm doing the above manually in two steps
1. select max(length(columnname)) from .....
2. col columnname format a[resultofstep1]
Is there a way of doing it in one step ?
Thank you for your help,
John.Hi Munky,
>
you should consider whther you are using the correct tool for the job, SQLplus isn't exactly ideal for doing presentation layer stuff
>
I'm not really doing presentation stuff, I asked because it would be very convenient for everyday stuff. I commonly query the tables that I am going to deal withm just to have a look at the column names and a few values, something like:
select * from EMP where rownum <= 10; -- just to have a look at the table and some values
when the table contains a wide column then the display gets all messed up. It would be nice to have an option or a mechanism to tell SQL*Plus to automatically use the width of the widest value, instead of having to determine the value and then manually set the column.
thank you for your help, it's good to know that I didn't miss some trivial setting in the documentation that would do it ;)
John. -
While using business objects we set the security context as we connect to the database. How would we do that with Crystal Reports?
Crystal doesn't support it in that way. You simply enter the log on info, User Name and Password, and Cr connects. You can use a Universe to set up Security Context and Cr then passes the user info through and the Universe handles what the user can and can not see.
This generalizing because you did not say what DB you are using or what version of Crystal Reports.
Or if you are using the OEM build for Business One...
There is in later versions a Special Field to get/set the CEUser which you can use in the record selection formula.
Don -
What environment variable I will set for the default SQL*plus file directory
Hi there,
I run sql*plus on windows 2000 professional. I want to set a file
directory for sql*plus so that when I write something in a file,
it will be in my default file directory. What environment
variable I will set for that? Thanks in advance.hi , i have already install my oracle 8i personnel edition to my computer , but my sql plus don't seen to work ,
i understand that they username are ( scott ) and password are ( tiger ) but after i type them and press ok there will be a box coming out and it said ( Cannot open registry Software \ORACLE\HOME1\SID_LIST Starting with default sid )
after i click ok there will be another box asking for password , but i what is the password ? it look to me like a internal password , it can't be tiger for this , cos before that i have already type in my username and password , this is the later part , anyone can help? pls reply, thank alot Nigel,
I'm not sure about Oracle8i Personal Edition. The default username/passwords are:
scott/tiger
system/manager
sys/change_on_install as sysdba
You could try the database installation discussion forum for more help. If you find out what the password for this dialog is, please post it to this group for the benefit of others.
Alison -
Cant Start Sql*Plus Session
I just installed Oracle 8.1.6 on Rehhat 6.2 Linux but when I try to start sqlplus after entering username and password, I get the error: ORACLE initialization or shutdown in progress
nullIf you got the SVRMGR> prompt with no errors when you started it you should then enter
connect internal
if it asks for a password try oracle
SHUTDOWN NORMAL
SHUTDOWN IMMEDIATE
will shut down the currently running Database.
and
STARTUP
should get it going. But be sure you have done what you need to set three important system variables.
ORACLE_HOME
ORACLE_SID and
PATH
With out these you won't be able to start sqlplus and svrmgr won't operate. You will see errors in both like
If the SID is wrong you will get that the Service name is incorrectly specified.
If PATH and HOME are incorrect You will get a message that it can't find a message file.
null -
SET NULL not working in SQL*Plus
DB Version: 10.2.0.4
Question1.
Won't SET NULL work with PL/SQL block?
Question2.
Why is <<>> appearing in several lines (one character per line) as shown below? Sorry about the "jive-quote" thing below, got that after i added code tags.
SQL > show lines
linesize 80
SQL > show pages
pagesize 14
SQL > set null <<>>
SQL > select null from dual;
N
<
<
>
>
SQL > set serveroutput on
SQL > declare
2 v_Val VARCHAR2(100) :='COCOJUMBO';
3 BEGIN
4 SELECT null INTO v_val from dual ;
5 DBMS_output.put_line(v_val);
6 EXCEPTION
7 WHEN NO_DATA_FOUND THEN
8 dbms_output.put_line('Exception:'||SQLERRM);
9 END;
10 /
PL/SQL procedure successfully completed.
SQL >user872043 wrote:
DB Version: 10.2.0.4
Question1.
Won't SET NULL work with PL/SQL block?No. SET NULL is a SQL*Plus command, not a PL/SQL command.
Question2.
Why is <<>> appearing in several lines (one character per line) as shown below? Sorry about the "jive-quote" thing below, got that after i added code tags.That's due to default formatting. For example:
SQL> SET NULL <<>>
SQL> SELECT NULL FROM DUAL;
N
<
<
>
>
SQL> COLUMN col FORMAT A4
SQL> SELECT NULL col FROM DUAL;
COL
<<>> -
Checking Module to Prevent SQL Plus usage on Database
I have a question regarding logon triggers checking against SYS_CONTEXT('USERENV', 'MODULE'). I created a logon trigger that looks for SYS_CONTEXT('USERENV', 'MODULE') = 'SQLPLUS.EXE'
and if it matches then it only allows specified users to log in to the database. This code works but I am confused as to why when I check SYS_CONTEXT('USERENV', 'MODULE') after I login in
shows SQL*Plus which clearly does not match my IF statement in my logon trigger.
Second issue. If I rename sqlplus.exe to jeff.exe and run it I am abled to log in to the database as a non DBA user. But the module still shows as SQL*Plus. Why is this?
Database Version: 11.2.0.2 64bit
OS: Windows Server 2003 R2
Client: 11.2.0.1
/*********************Create Trigger******************************/
CREATE OR REPLACE TRIGGER application_check_al
after logon ON database
DECLARE
l_username VARCHAR2(20);
l_module VARCHAR2(20);
BEGIN
l_username := SYS_CONTEXT('USERENV', 'SESSION_USER');
l_module := UPPER(SYS_CONTEXT('USERENV', 'MODULE'));
IF l_module LIKE 'SQLPLUS.EXE' AND
l_username NOT IN ('SYS', 'SYSTEM', 'DVOWNER', 'DVMGR') THEN
raise_application_error(-20001, 'SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS');
END IF;
END application_check_al;
/*********************Run SQLPLUS******************************/
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 12:22:23 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: jeffc@dev
Enter password:
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS
ORA-06512: at line 10
Enter user-name: system@dev
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining, Oracle Database Vault
and Real Application Testing options
system@dev> select sys_context('USERENV','MODULE') from dual;
SYS_CONTEXT('USERENV','MODULE')
SQL*Plus
SQL>jeff81 wrote:
That doesn't make sense. Why am I able to log in when I renamed the exe? And why does the module still show as SQL*Plus?You are right - it does not make sense. The idea that Oracle might perhaps set module to SQLPLUS.EXE on executable start, and then re set from SQLPLUS.EXE to SQL*Plus after connect, or in glogin.sql, to ensure it is consistent across all operating system never crossed my mind.
You might want to refer to Support Note "SQL*Plus Session/Module is Not Showing in V$SESSION" [ID 1312340.1] to see whether anything in there helps. I'm pretty sure http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#i2698573 doesn't help much, though.
I'd certainly be raising it with Support as a potential security challenge, to get that potential hole closed.
Edited by: Hans Forbrich on Mar 7, 2012 2:23 PM
I wonder whether Oracle put that capability in there - if an untained SQLPLUS.EXE, it tells you that it is SQLPLUS.EXE, but if renamed it tells you 'SQL*Plus'? Specuklation, but it is one thing I might do to subtly raise the flag. Best bet - ask Support.
Edited by: Hans Forbrich on Mar 7, 2012 2:29 PM -
SQL*PLUS WINDOW DOESNT GIVE AN ERROR MESSAGE.
HI,
i FOUND OUT THAT IF I HAD AN ERROR IN MY SQL SCRIPT, THE WINDOW WILL DISAPPEAR AND LOST EVERYTHING THAT I HAVE DONE. IT DOESNT GIVE ME AN ERROR MESSAGE. IM HERE IN CHAP05, BUILDING A RELATIONAL SCHEMA OF ORACLE DATABASE 10G EXPRESS EDITION FOR LINUX. WHAT PARAMETER AM I MISSING IN MY SYSTEM? PLS. HELP ME. THANKS.
LENHi,
Most likely you have to adjust WHENEVER SQLERROR and (or) WHENEVER OSERROR settings.
Consider an example below:
C:\> sqlplus /NOLOG
SQL*Plus: Release 9.2.0.6.0 - Production on Wed Nov 1 02:55:29 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn max
Enter password:
Connected.
SQL>
SQL> whenever sqlerror continue
SQL>
SQL> exec raise_application_error(-20000, 'Error')
BEGIN raise_application_error(-20000, 'Error'); END;
ERROR at line 1:
ORA-20000: Error
ORA-06512: at line 1
SQL> whenever sqlerror exit
SQL>
SQL> exec raise_application_error(-20000, 'Error')
BEGIN raise_application_error(-20000, 'Error'); END;
ERROR at line 1:
ORA-20000: Error
ORA-06512: at line 1
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
C:\>As you can see, with WHENEVER SQLERROR set to EXIT, SQL*Plus session terminates as it encounters any program error.
Similarly, for OSERROR setting:
C:\> sqlplus /NOLOG
SQL*Plus: Release 9.2.0.6.0 - Production on Wed Nov 1 02:57:08 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn max
Enter password:
Connected.
SQL>
SQL> start C:\non_existent_file
SP2-0310: unable to open file "C:\non_existent_file.sql"
SQL>
SQL> whenever oserror exit
SQL>
SQL> start C:\non_existent_file
O/S Message: No such file or directory
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
C:\>Hope this helps. -
Maximum length of SQL*Plus Command?
I'm typing a long query into SQL*Plus (Linux, version 9.2.0.1... yes, I know it's ancient).
If I run this query, all works fine:
select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE') then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$')
else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
'UPDATEMYAUDITING_TABLESETTEST_DETAILS='''||GRANTEE||'''WHEREMYAUDIT_REFNO=''A.F
update myauditing_table set test_details='AUDIT_TRAIL is set to: DB' where myaud
it_refno='A.FE';(In other words, is SQL that generates other SQL: if AUDIT_TRAIL is set to something interesting, tell me who has access to the AUD$ table. And it's working fine... the agg_concat function mentioned is simply Tom Kyte's stragg function under another name, as lifted word-for-word from http://www.sqlsnippets.com/en/topic-11591.html)
Now this is what happens if I take out the linebreak after the mention of AUD$, so that the command is submitted as one single line of code:
SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE') then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.The error message indicates that the text has been 'split' at the 'AUDIT_TRAIL is set to...' bit, so that "s set to" is being treated as a new command, which is of course syntactically invalid. There is definitely no other change in text between the two versions, apart from the removal of a carriage return before the "else" statement.
Possibly a coincidence, but the first "s" in "s set to" appears at position 258 in the entire text... close to a possible 255 or 256 character limit, perhaps?
The same problem happens whether I run the command as a script (@mysql.sql) or typed in directly into a client SQL*Plus session. Is there some inherent limit to the length of commands that SQL*Plus can process in this version? My code runs fine on 10g and 11g databases/clients, whether it's on one line or two. Anyone know of a bug in 9i regarding this? And if there's a workaround (other than the obvious one of upgrading, of course!)As mentioned, it's choking at the 258th character, not the 240th. Also, it's a SELECT statement, not a COPY command (one relates to the database, the other is an internal SQL*Plus feature). And someone else also kindly pointed out that SQL*Plus has a command limit length (i.e., database-related commands) of 2500 characters. So I don't think that's the issue.
I can be a bit more specific about this one now, though. I've a sequence of Solaris boxes running 9.2.0.1 up, and the results are that 9.2.0.1 is affected; and it's a problem for 9.2.0.7:
SQL> select * from v$version;
BANNER
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for Solaris: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE') then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.And...
SQL> select * from v$version;
BANNER
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for Solaris: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE') then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.But in 10.2.0.1, the problem disappears.
I am not sure, but it is perhaps related to metalink note 285913.1, since we did get some ORA-00600: internal error code, arguments: [qernsRowP], [1] errors in the alert log with a slightly different version of the above query. Changing the query obviously alters the test, though, so it may be completely unrelated.
Either way, I think it's definitely a version-specific SQL*Plus bug (though it would be nice if any other 9i owners out there could try it and report back!)
Anyway, the workaround is simply to submit the command on two separate lines, wherever possible. And of course... to upgrade. -
Unix Environment variable for connect string in SQL*Plus
I am using some environment variables to connect to a sql*plus session in unix.
they are exported as part of a file which contains the following and gets executed through the .profile.
export db_username=xxx
export db_password=xxx
export db_name=xxx
i have created a file abc.sql which contains the following
connect $db_username/$db_password@$db_name
Now, I have a shell script which uses this file inside it to connect to a sql*plus session and execute some queries.
The contents of the shell script :
API_CONNECT_SQL=abc.sql
sqlplus /nolog << THEEND
WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
WHENEVER OSERROR EXIT FAILURE ROLLBACK
set timing on
@${API_CONNECT_SQL}
---- do something
EXIT
THEEND
Now, the sql*plus session is able to get db_username and db_password, but not the db_name. It says "TNS service name not found".
If I hardcode some database name in place of db_name, it connects properly.
Please let me know the problem and solution as well.
Any help appreciated.
thanks,
Vijayfor me this one works
# =========================================
# begin of script
# =========================================
export db_username=alpha
export db_password=bravo
export db_name=charly
echo "connect $db_username/$db_password@$db_name" > xxx.sql
API_CONNECT_SQL=/cfs/dummy1/0/appl/dummy2/rev_04/zzz/tst/xxx.sql
cat ${API_CONNECT_SQL}
sqlplus /nolog << THEEND
spool xxx
WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
WHENEVER OSERROR EXIT FAILURE ROLLBACK
set echo on
host cat ${API_CONNECT_SQL}
@${API_CONNECT_SQL}
select * from dual;
spool off
EXIT
THEEND
# =========================================
# end of script
# ========================================= -
SQL*Plus report: hide accept value in report
HI all,
I have created an SQL Report of an APEX-Application. The output is stored in a HTML file.
All works fine but one think I want to hide in the HTML report.
I try to describe what the problem is.
I prompt the user to put in the application_id of the apex application:
accept v_application_Id char prompt 'Appliaction-ID:'
In the HTML file the following output is shown:
Report created on:
25-Jun-2013, 10:06:04
alt 8: where application_id = &&v_application_id
neu 8: where application_id = 680
Workspace
WORKSPACE
APPLICATION_ID
APPLICATION_NAME
ALIAS
OWNER
Q0Q0AUFTRAGSVERWALTUNG
680
Q0Q0AUFTRAGSVERWALTUNG
F680317
Q0Q0AUFTRAGSVERWALTUNG_ADMIN
How can I hide the two lines
alt 8: where application_id = &&v_application_id
neu 8: where application_id = 680
from the report?
I have searched this forum and toke a look into the documentation but I have nothing found.
Could anyone please help me?
Oracle 11g R2
This is the SQL script what I run in SQL*Plus.
-- start script
accept v_application_Id char prompt 'Appliaction-ID:'
spool C:\a\APEX.html
set termout off
SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus APEX-Report</title> -
<STYLE TYPE=’TEXT/CSS’><!--BODY {bgcolor: ffffaa background: ffffc6} --></STYLE>"
clear break
clear buffer
clear compute
clear column
clear sql
set feedback off
set serveroutput on
-- Report Header
ttitle left ' ' skip 1
select TO_CHAR(sysdate,'dd-Mon-yyyy, hh24:mm:ss') "Report created on:"
from dual;
-- Workspace
ttitle left col 15 '<font face="Arial" size="+2" color="#0000FF">Workspace</font>' skip 1
set linesize 300
set pagesize 500
set serveroutput on
column workspace format a35
column application_id format 99999999
column application_name format a35
column alias format a35
column owner format a35
select
WORKSPACE,
APPLICATION_ID ,
APPLICATION_NAME,
ALIAS,
OWNER
from apex_applications
where application_id = &&v_application_id;
ttitle off
select
APPLICATION_GROUP,
APPLICATION_GROUP_ID,
HOME_LINK,
PAGE_TEMPLATE,
ERROR_PAGE_TEMPLATE
from apex_applications
where application_id = &&v_application_id;
set termout on
set markup html off head '' body '' entmap off spool off pre off
set feedback on
set linesize 80
set pagesize 50
ttitle off
set termout on
set serveroutput off
spool off
set echo on
-- End Script
best regards
ben
Oracle 11g R2Hi, Ben,
The SQL*Plus command to stop those messages is
SET VERIFY OFF
Put this command anywhere before the first use of a substitution variable, e.g. before the SPOOL command.
Those "OLD" and "NEW" messages will stay suppressed until you either end the SQL*Plus session, or issue a SET VERIFY ON command.
If you use SQL*Plus often, then, when you have a few minutes, look up the SET command in the SQL*Plus manual,
SET System Variable Summary
and read a little about each option. You probably won't remember everything, but you probably will remember what kinds of things can be controlled by the SET command, and have a better idea of where to start looking in the future when you have a different problem. -
GREATER THAN symbol appearing as > ; in SQL*Plus
Version:11.2.0.3
OS : RHEL 5.4
We are a Software vedor firm.We have sent our SQL files to our client to execute. But the codes for various procedures and functions were failing
because, in their SQL*Plus session (in Putty) the LESS THAN character < was appearing as < ; and GREATER THAN character > was appearing as > ;
In the original code which we had sent to them has no problems with > or < characters.
Original code
Cursor feb_cur IS
SELECT user_pwid
FROM carton_hdr_dtl
WHERE MODIFIED_DATE >= D_Last_Run_Date
UNION
SELECT user_pwid
FROM carton_hdr_dtl_bkp
WHERE (modified_date >= D_Last_Run_Date OR
deleted_date >= D_Last_Run_Date); But in the execution log file sent by our client, I can see > ; instead of > character.
54 Cursor feb_cur IS
55 SELECT user_pwid
56 FROM carton_hdr_dtl
57 WHERE MODIFIED_DATE > ;= D_Last_Run_Date
58 UNION
59 SELECT user_pwid
60 FROM carton_hdr_dtl_bkp
61 WHERE (modified_date > ;= D_Last_Run_Date OR
62 deleted_date >= D_Last_Run_Date);What are they doing wrong? They use putty. We use putty too but we don't have any issues.
Edited by: Max on Dec 17, 2012 2:42 AMThank you Blushadow, Nicosa for providing this clue.
I checked with my client. They have put our scripts in Collabnet SVN version control and the implementor DBA will be provided the http URL .
Apparently SVN is accessed using http protocol and yes you are right it is opened through a browser by typing an URL like below
http://10.80.16.214:79839/svn/brcf/DBfiles/2012/WMHReleasel8/hrtb_pkt_wave.sqlFor most of the end users , the GREATER THAN character appears as > without any issues . For some users it appears as > ; . One potential cause is the difference in Internet Explorer version. They are currently looking into this.
THANK YOU BLUSHADOW and NICOSA for shedding light on this.
Hi Nicosa,
A forum formatting question:
How did you manage to get >_; (without the underscore) printed ? When I tried it the forums editor was converting it to > . This is why I placed a space/underscore between t and semi colon. Is there some escape character ?
Maybe you are looking for
-
How to show a JSP Page Multiple Times ??
Dear Experts, Our requirement is like : The client chooses to enter the details of 10 customers in the First Jsp page , by selecting 10 in a dropdown list and clicks the Proceed button in the same JSP. The Second JSP ie. Customer Details Jsp is poppe
-
How can I compose and e-mail?
I have an icon on my desk top that gets me into my mail box. No problem. When I want to compose an e-mail I can't find a way to do so. Help.
-
Hi, my iphone 5 (latest software) has put itself into recovery mode all on it's own today AFTER I took video of my kids and easter egg hunt. Is there a way to back up the phone prior to restoring it?New HDD (old 1 dead so no Bup)
-
I got this message when I tried to verify my disk. What does it mean? What should I do? I'm not able to click the repair button, it's grayed out. Verifying volume "Macintosh HD" Checking HFS Plus volume. Checking Extents Overflow file. Checking Catal
-
IP19- Graphic Scheduling Overview and Simulation# Issue.
Dear All, Good Day, I have run transaction IP19 for a perticular Maintenance plan and I did "Release Call" by clicking relevent icon. Its changend in Green Color ("CALLED ICON") also I saved the same. When i checked related Maintenance plan, it dos