Error in substr(sys_context('userenv','ip_address'),1,20)
Hi GURUS,
I m new to oracle here i created a table in oracle 10g(10.1.0.2.0) named
create table iv_master(
iv_code varchar2(6) not null,
iv_name varchar2(50) not null,
created_at varchar2(15) default substr(sys_context('userenv','ip_address'),1,20),
created_on date default sysdate,
created_by varchar2(5) not null,
modified_at varchar2(15) default substr(sys_context('userenv','ip_address'),1,20),
modified_on date default sysdate,
modified_by varchar2(5) not null,
constraint iv_master_pk primary key(iv_code))
Now i want to remove this 'default' keyword in created_at & modified_at fields
i tried alter table command but it is not working.tell me the way to remove this default keyword and also in created_on ,modified_on..(without dropping the table)
i tried the following statement,
create table test (ipaddr varchar2(20) SUBSTR(SYS_CONTEXT('USERENV','IP_ADDRESS')1,20));
but i m getting.this following error
ERROR at line 1:
ORA-00922: missing or invalid option
pls tell me where i m wrong...and also tell me the query to do it...
Advance thanks for all...
Hi,
bharathit wrote:
Hi GURUS,
I m new to oracle here i created a table in oracle 10g(10.1.0.2.0) named
create table iv_master(
iv_code varchar2(6) not null,
iv_name varchar2(50) not null,
created_at varchar2(15) default substr(sys_context('userenv','ip_address'),1,20),
created_on date default sysdate,
created_by varchar2(5) not null,
modified_at varchar2(15) default substr(sys_context('userenv','ip_address'),1,20),
modified_on date default sysdate,
modified_by varchar2(5) not null,
constraint iv_master_pk primary key(iv_code))
Now i want to remove this 'default' keyword in created_at & modified_at fieldsYou can't have the default functionality without the "DEFAULT" keyword.
Are you saying that you no longer want a default value? That's the same as saying DEFAULT NULL, and you can change the table like this:
ALTER TABLE iv_master
MODIFY ( created_at DEFAULT NULL
, modified_at DEFAULT NULL
);Edited by: Frank Kulash on Feb 17, 2010 12:59 PM
Changed ALTER TABLE example to modify both columns.
Similar Messages
-
SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM dual;
I am using the following query
SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM DUAL:
and the retuned row is blank.
Any Idea why?SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM dual
will return the IP address of the client of the current session. If the current session is connected to a local database (i.e. not using SQL*NET), then this query appears to return NULL.
SELECT SYS_CONTEXT ('userenv', 'host') FROM dual
will return the host name from which the client is connected, even if the client is connected locally.
If the host name is not sufficient, then I'm not sure what your other options are (perhaps writing a java stored procedure which returns the IP address of the database server? always connecting via SQL*Net?) -
hi master
sir i use this command for user ip address
SELECT sys_context('userenv', 'host'), sys_context('userenv', 'ip_address') FROM dual;
BUT
form6i give me this error
Error 201 at line 26, column 12
Identifier SYS_CONTEXT must be declared
please give me idea how i get ip_address in form
thankthank for your reply
sir my need is
i check user computer name if that computer in table then i update the user feeding ouer wise i insert that computer name as new and give the feeding form access to user
you see my code
SELECT sys_context('userenv','host'), sys_context('userenv', 'ip_address') INTO HOSTNAME,IPADD FROM dual;
SELECT COUNT(*) INTO USERCOUNT FRoM forclosingyear WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
IF USERCOUNT>0 THEN
update forclosingyear SET YEARID=:SYID,datefrom=:ysdate,dateto=:yedate WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
ELSIF USERCOUNT=0 THEN
INSERT INTO forclosingyear (YEARID,datefrom,dateto,HOSTNAME,IPADD) VALUES (:SYID,:ysdate,:yedate,HOSTNAME,IPADD);
END IF;
this is my need
please give me idea how i get termenal name or user computer name
thank
aamir -
Parameter in SYS_CONTEXT('USERENV'
Hi,
is there any parameter in SYS_CONTEXT('USERENV' that shows the name or IP adresse of database server ( machine on which DB is running) ?
many thanks.
I know the followings but non lets know (but if I'm wrong).
SYS_CONTEXT('USERENV','TERMINAL') terminal,
SYS_CONTEXT('USERENV','LANGUAGE') language,
SYS_CONTEXT('USERENV','SESSIONID') sessionid,
SYS_CONTEXT('USERENV','INSTANCE') instance,
SYS_CONTEXT('USERENV','ENTRYID') entryid,
SYS_CONTEXT('USERENV','ISDBA') isdba,
SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,
SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,
SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
SYS_CONTEXT('USERENV','CURRENT_USER') current_user,
SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,
SYS_CONTEXT('USERENV','SESSION_USER') session_user,
SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,
SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,
SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,
SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,
SYS_CONTEXT('USERENV','DB_NAME') db_name,
SYS_CONTEXT('USERENV','HOST') host,
SYS_CONTEXT('USERENV','OS_USER') os_user,
SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,
SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,
SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol,
SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,
SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,
SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE')
authentication_type,
SYS_CONTEXT('USERENV','AUTHENTICATION_DATA')
authentication_data,
SYS_CONTEXT('USERENV','CURRENT_SQL') current_sql,
SYS_CONTEXT('USERENV','CLIENT_IDENTIFIER') client_identifier,
SYS_CONTEXT('USERENV','GLOBAL_CONTEXT_MEMORY')We have 10g and 9i DBs. We should be able to know to which machine user is connected.
Thank you.
On 9i I tested :
SQL> select SYS_CONTEXT('USERENV','hostname') from dual;
select SYS_CONTEXT('USERENV','hostname') from dual
ERREUR à la ligne 1 :
ORA-02003: invalid USERENV parameter -
Function sys_context('USERENV','CLIENT_IDENTIFIER') Returns ANONYMOUS
our application codes has custom fine grain access control that looks for certain id's such as the userid and machine identifier. some of the codes rely on this sys_context('USERENV','CLIENT_IDENTIFIER') function to compare it's return result to some custom account reference table. one of the server machine that we recently use for testing purpose of new version for Oracle Reports is returning this ANONYMOUS result when the sys_context('USERENV','CLIENT_IDENTIFIER') is queried. this cause issue to our application.
normally, the sys_context('USERENV','CLIENT_IDENTIFIER') returns a null value when it can't recognize of find. how do i resolved it on the server to return the correct result? is there any config file that i should look into? please advise.
our test server machine is running on a Microsoft Windows XP [Version 5.1.2600].
thanks,
warrenSYS_CONTEXT('userenv','LANG') returns the Oracle short language name/abbreviation, this id may or may not correspond to the ISO language code.
Table A-1 http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14225/applocaledata.htm#g679875" in the Globalization Support guide lists all the Oracle language abbreviations.
To obtain the ISO code, you can try calling the UTL_I18N.MAP_LOCALE_TO_ISO function( ), which is available in 10g.
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_i18n.htm#sthref14725 -
Hi ,
I am using below query in my procedure. Can it possible below query give NULL. If yes then which Case...?
SELECT SYS_CONTEXT('USERENV','OS_USER')
FROM DUAL
Thanks lot..
Edited by: user8568838 on Mar 1, 2011 2:05 AM
Edited by: user8568838 on Mar 1, 2011 2:27 AMBluShadow wrote:
smon wrote:
Please apologize and remove the word 'Urgent'.lol, lighten up!It's not about lightening up, it's about people coming here and being rude by assuming everyone should drop what they're doing to help them "urgently". You would consider it rude if you were busy talking to people in a room and someone came in demanding your urgent attention without consideration for what you're doing.
I've now edited the subject line to remove the "urgent" from it.That isn't the intention, to get everyone to drop what they're doing. Marking it as urgent just means the clocks ticking at his end, he isn't haughtily making demands of me, you or anyone else.
The meeting room analogy doesn't work, as the poster isn't barging in and disturbing us from whatever else we're doing. He's passively posting on a forum, and we're actively looking for his, or anyone elses posts, to read and reply to. If I'm busy doing something else, then the poster with the urgent problem isn't disturbing me, because I'm not on the forum. -
Not matching the SYS_CONTEXT('USERENV', 'LANG') with oracle fod schema data
I have imported the fod schema into oracle XE. I observed that the data available for following languages:
SQL> select distinct language from category_translations;
LANGUAGE
EN
EL
FR
DE
JA
But, when I check the value for the LANG in oracle XE, it is returning as 'US'.
SQL> select SYS_CONTEXT('USERENV','LANG') FROM DUAL;
SYS_CONTEXT('USERENV','LANG')
US
Becasue of this, I am not getting data when I run VOs from JDeveloper. Even I am not able to see data from FOD schema views.
Please suggest what changes I need to do for getting data.Try this,it will work
alter session set nls_language = 'GREEK'
If the above query is used,it will set the current session's language code to 'GL' which is valid in the language filed of category_translations.
I did not find any nls_language value to get the 'EN' code.
You can get the valid language values from the below query:
select * from V$NLS_VALID_VALUES where parameter='LANGUAGE'
Thanks,
Mohan -
Hi,
I have the below code for one of the fields placed in different xml tags and I need to limit the number of characters on REPORTING_NAME to 20. Do I need to limit in the first expression or the 2nd.
I tried using substring(./REPORTING_NAME,1,20) within the already existing concat() function but it throws an error while checking the preview. I tried adding xdoxslt before substring but didn't work. Also, I tried doing the same in the 2nd TAG but still the same. Can anyone help?
TAG 1:
<?for-each-group:AC_EARNINGS;xdoxslt:ifelse(substring(./JURISDICTION_CODE,1,2)='05',concat(./REPORTING_NAME,ORIGINAL_DATE_EARNED,RATE_MUL),concat(REPORTING_NAME,RATE_MUL)) ?><?sort:PROCESSING_PRIORITY;'ascending';data-type='number'?><?sort:ELEMENT_TYPE_ID;'ascending';data-type='number'?><?sort:ORIGINAL_DATE_EARNED;'ascending'?>
TAG 2:
<? if: position() <=19?><?if: sum(current-group()/CURRENT_HOURS[./text()!=''] )!= 0 or sum(current-group()/CURRENT_AMOUNT[./text()!='']) != 0 or sum(current-group()/YTD_AMOUNT[./text()!='']) != 0?><?current-group()/REPORTING_NAME?>
Thanks!i misunderstood
what is and where is errors ????
in
substring(./REPORTING_NAME,1,20) or
>
TAG 1:
<?for-each-group:AC_EARNINGS;xdoxslt:ifelse(substring(./JURISDICTION_CODE,1,2)='05',concat(./REPORTING_NAME,ORIGINAL_DATE_EARNED,RATE_MUL),concat(REPORTING_NAME,RATE_MUL)) ?><?sort:PROCESSING_PRIORITY;'ascending';data-type='number'?><?sort:ELEMENT_TYPE_ID;'ascending';data-type='number'?><?sort:ORIGINAL_DATE_EARNED;'ascending'?>
>
or
>
TAG 2:
<? if: position() <=19?><?if: sum(current-group()/CURRENT_HOURS[./text()!=''] )!= 0 or sum(current-group()/CURRENT_AMOUNT[./text()!='']) != 0 or sum(current-group()/YTD_AMOUNT[./text()!='']) != 0?><?current-group()/REPORTING_NAME?>
>
plz see example of using substring and format_date
Re: Date format in Excel report output
post sample xml for test -
I have a table called "*TEST_CLOB*" which contains three fields.......id,filename and txt_file......
from which "txt_file" field contains a file in CLOB datatype with the following data in each line
*243890##28-3-2011#185#RKP#02#TYPE B, R.K. PURAM, Block/Sector : XII, 904, DELHI#Shri. S. K. NAGI#Asstt. Director of Estates##*
I write the following code to read this field into another table ... and error is coming.....
insert into sample_int (F1,F2,F3,F4,F5,F6,F7,F8,F9,F10 )
*( select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10*
from
with t as
select cast(dbms_lob.substr(txt_file,dbms_lob.getlength(txt_file),1) as varchar(4000)) txt_file
from test_clob
select dbms_lob.substr
*(t.txt_file, dbms_lob.instr(t.txt_file, '#', 1,1)-1, 1) as F1*
*,substr(t.txt_file, instr(t.txt_file, '#')+1, (instr(t.txt_file, '#',1, 2) - instr(t.txt_file, '#'))-1 ) as F2*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 2)+1, (instr(t.txt_file, '#',1, 3) - instr(t.txt_file, '#',1, 2))-1 ) as F3*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 3)+1, (instr(t.txt_file, '#',1, 4) - instr(t.txt_file, '#',1, 3))-1 ) as F4*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 4)+1, (instr(t.txt_file, '#',1, 5) - instr(t.txt_file, '#',1, 4))-1 ) as F5*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 5)+1, (instr(t.txt_file, '#',1, 6) - instr(t.txt_file, '#',1, 5))-1 ) as F6*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 6)+1, (instr(t.txt_file, '#',1, 7) - instr(t.txt_file, '#',1, 6))-1 ) as F7*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 7)+1, (instr(t.txt_file, '#',1, 8) - instr(t.txt_file, '#',1, 7))-1 ) as F8*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 8)+1, (instr(t.txt_file, '#',1, 9) - instr(t.txt_file, '#',1, 8))-1 ) as F9*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 9)+1, (length(t.txt_file) - instr(t.txt_file, '#',1, 10))-1 ) as F10*
from test_clob t
Error at Command Line:1 Column:12
Error report:
SQL Error: ORA-32035: unreferenced query name defined in WITH clause
32035. 00000 - "unreferenced query name defined in WITH clause"
*Cause: There is at least one WITH clause query name that is not
referenced in any place.
*Action: remove the unreferenced query name and retry
How can we remove this above error........what's wrong with this code.???I almost done all the things.... But now the new problem is here.............
this is the actual pl/sql code, which I have written and the error is coming in this code.....
insert into sample1_int (F1,F2,F3,F4,F5,F6,F7,F8,F9,F10 )
*( select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10*
from
with t as
select cast(dbms_lob.substr(txt_file,dbms_lob.getlength(txt_file),1) as varchar(4000)) txt_file
from test_clob
select dbms_lob.substr
*(t.txt_file, dbms_lob.instr(t.txt_file, '#', 1,1)-1, 1) as F1*
*,substr(t.txt_file, instr(t.txt_file, '#')+1, (instr(t.txt_file, '#',1, 2) - instr(t.txt_file, '#'))-1 ) as F2*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 2)+1, (instr(t.txt_file, '#',1, 3) - instr(t.txt_file, '#',1, 2))-1 ) as F3*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 3)+1, (instr(t.txt_file, '#',1, 4) - instr(t.txt_file, '#',1, 3))-1 ) as F4*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 4)+1, (instr(t.txt_file, '#',1, 5) - instr(t.txt_file, '#',1, 4))-1 ) as F5*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 5)+1, (instr(t.txt_file, '#',1, 6) - instr(t.txt_file, '#',1, 5))-1 ) as F6*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 6)+1, (instr(t.txt_file, '#',1, 7) - instr(t.txt_file, '#',1, 6))-1 ) as F7*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 7)+1, (instr(t.txt_file, '#',1, 8) - instr(t.txt_file, '#',1, 7))-1 ) as F8*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 8)+1, (instr(t.txt_file, '#',1, 9) - instr(t.txt_file, '#',1, 8))-1 ) as F9*
*,substr(t.txt_file, instr(t.txt_file, '#',1, 9)+1, (length(t.txt_file) - instr(t.txt_file, '#',1, 10))-1 ) as F10*
from t
Error report:
SQL Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 1
*06502. 00000 - "PL/SQL: numeric or value error%s"*
**Cause:*
**Action:* -
SQlldr Error while uploading "excel" or "csv" file.
Hello to community,
We are using Oracle AS(application Server) 10g as a "web Server" & "database Server"
The Database Server is having an NFS Partition,which has mounted onto "Web Server"
So, if any client tried to upload any excel OR csv file , the Web Server will redirect that file data onto "database" server" through NFS partition.
By clicking "upload" button from client end, they are getting a strange error. By checking "ias_console" log file, I have found below latest logs,which belongs to the error. Kindly let me know where is the problem coming from.
The Database Server Shared NFS partition name is "web_upload" & we have same "web_upload" partition on the "web server". The command of mounting NFS partition is given below.
On AIX web Server :- mount <ip address>:/file_data/web_upload/ /web_upload/
SYNTAX :- <ip add of db server>/mount point "web server mount point"
The error is as given below.
09/06/09 15:27:47 NumIdle: 2
09 Jun 2009 15:27:47,764 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ private Connection getDBConnection() ] Exited
09 Jun 2009 15:27:47,764 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ private Connection getDBConnection() ] Exited
09 Jun 2009 15:27:47,766 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ private void initialize() ] After getDBConnection called,
connection object is: org.apache.commons.dbcp.PoolableConnection@1048a893
09 Jun 2009 15:27:47,767 [DEBUG] - [ com.vat.website.service.ExcelUploadService ] [ public boolean insertFileDetails(ExcelDataBean databean,String
strFname) ] strUniqueKey:select web_uploaded_file_history_seq.nextval from dual
09 Jun 2009 15:27:47,767 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ public ResultSet executeQuery(String strQuery) ] Entered
09 Jun 2009 15:27:47,773 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ public ResultSet executeQuery(String strQuery) ] Exited
09 Jun 2009 15:27:47,774 [DEBUG] - [ com.vat.website.service.ExcelUploadService ] [ public boolean insertFileDetails(ExcelDataBean databean,String
strFname) ] insertQuery:INSERT INTO WEB_UPLOADED_FILE_HISTORY(WUF_SERIAL_NUMBER,WUF_DEALER_ID,WUF_PERIOD_FROM,WUF_PERIOD_TO,WUF_FILE_PATH,WUF_FORM_NO,WUF_SERVER_IP,WUF_UPLOAD_YN,WUF_CREATED_DATE,WUF_CREATED_BY,WUF_ORIGINAL_REVISED,WUF_SHEETS_NUMBER,wuf_reco
d_key)VALUES('2658271','T00100001000306',to_date('01/01/2009','dd/mm/yyyy'),to_date('31/01/2009','dd/mm/yyyy'),'/web_upload/090609/VAT
Returns/000000/0000000000/Form201/0000000000_0T201BO0109_009062009152747.csv',replace(decode('T201B','T201M', 'T201','T201B'),'T','VAT-Form'),(select
RPAD(sys_context('USERENV','IP_ADDRESS'),15,' ') AS client_ipaddress from dual),'Y',SYSDATE,'WEB','O','0','3317063')
09 Jun 2009 15:27:47,791 [DEBUG] - [ com.vat.website.service.DatabaseService ] [ public void closeDBConnection() ] Entered
09 Jun 2009 15:27:47,791 [DEBUG] - finalDate:01-JAN-2009
09 Jun 2009 15:27:47,792 [DEBUG] - finalDate:31-JAN-2009
09 Jun 2009 15:27:47,806 [DEBUG] - [ com.vat.website.utils.PropertyCache ] [ static Object getValue(String propertyName, String propertyFileName)
] Entered
09 Jun 2009 15:27:47,806 [DEBUG] - [ com.vat.website.utils.PropertyCache ] [ static Object getValue(String propertyName, String propertyFileName)
] Entered
09 Jun 2009 15:27:47,806 [DEBUG] - [ com.vat.website.utils.PropertyCache ] [ static Object getValue(String propertyName, String propertyFileName)
] Entered
09 Jun 2009 15:27:47,806 [DEBUG] - [ com.vat.website.action.UploadAction ] [ public ActionForward submit(ActionMapping mapping, ActionForm
form,HttpServletRequest request, HttpServletResponse response) ] Executing: sqlldr parfile=parafile.par silent=feedback direct=Y at location:
/web_upload/090609/VAT Returns/000000/0000000000/Form201/SQLLdr
It seems that this problem is due to "Sqlldr" then how to troubleshoot this problem?
Waiting for your favorable response,
Advanced Thanks,
Nishith Vyas.Flat File was in error.
-
i m using sys_context in sql plus for queries regarding operating system information.
now i would like to use sys_context in form as select into but oracle says error
ERROR 201 at line 7
identifier 'SYS_CONTEXT' must be declare
can anyone help me.
asif aliI don't know what you mean by "terminal name". If you want to get the user's IP address, you can create a stored function (or create a package, and include the function there), that returns the USERENV sys_context variable. Here is how you create a function on the database:Create or replace Function IP_Address return varchar2 is begin
Return sys_context('USERENV','IP_ADDRESS');
End;
/Now, you can use the function from a SQL select, another procedure, or a form. Here are several examples:
In SQL:Select IP_Address from dual;In a form:Message('IP Address='||IP_Address); -
Pls906 compiler error for on_logon trigger
Hello,
I wrote a PL/SQL program for on_logon trigger. But it has compiler error(no message file, ora-06540 error and pls906 error). The program is as follow:
DECLARE un VARCHAR2(80);
pw VARCHAR2(80);
cn VARCHAR2(80);
BEGIN
/* ** Bring up the logon screen */
Logon_Screen;
/*** Get the username, password and connect string. */
un=Get_application_property(username);
pw=Get_application_property(password);
cn=get_application_property(connect_string);
/*** Log the user onto the database */
IF cn IS NOT NULL THEN
LOGON(un,pw| |'@'| |cn);
ELSE
LOGON(un,pw);
END IF;
END;
Any help is appreciated
nullI tried following
================================================================
SQL> create or replace trigger after_logon_audit
2 AFTER LOGON ON DATABASE
3 WHEN (USER not in ('SYS','SYSTEM')
4 BEGIN
5 INSERT INTO LOGON_AUDIT
6 (log_time,log_user,LOG_IPADDR,LOG_TERMINAL,LOG_MACHINE,LOG_SESSIONID,LOG_OSUSER)
7 ( select SYSDATE, USER, SYS_CONTEXT('USERENV','IP_ADDRESS'), SYS_CONTEXT('USERENV','TERMINAL'),
8 a.machine, SYS_CONTEXT('USERENV','SESSIONID'), a.OSUSER
9 from V$SESSION a, dual
10 where
11 SYS_CONTEXT('USERENV','SESSIONID') = a.AUDSID
12 and SYS_CONTEXT('USERENV','SESSION_USERID') = USER#);
13 COMMIT;
14 RAISE_APPLICATION_ERROR(-20002,'The DB is unavailable');
15 END;
16
17 /
===============================================================
but got the following error message.
========================
AFTER LOGON ON DATABASE
ERROR at line 2:
ORA-04072: invalid trigger type
========================
Problem still persists. :( -
Hi Everyone,
I would like to create an error package say PKG_ERROR that has a procedure say LOG_ERROR. The LOG_ERROR procedure will basically logs the following in a table
ERROR_ID
-> SEQ_ERROR_ID.NEXTVAL
CREATED_DATE
-> SYSDATE
HOST_NAME
-> SELECT sys_context('USERENV', 'HOST') FROM dual;
IP_ADDRESS
-> SELECT sys_context('USERENV', 'IP_ADDRESS') FROM dual;
OS_USER
-> SELECT sys_context('USERENV', 'OS_USER') FROM dual;
SESSION_USER
-> SELECT sys_context('USERENV', 'SESSION_USER') FROM dual;
SCHEMA_NAME
-> SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;
ERROR_CODE
-> SQLCODE
ERROR_MESSAGE
-> SQLERRM
ERROR_STACK
-> DBMS_UTILITY.FORMAT_ERROR_STACK
CALL_STACK
-> DBMS_UTILITY.FORMAT_CALL_STACK
SQL_STATEMENT
-> ????
My problem now is how to get the SQL_STATEMENT that caused the error.
I'll be using the PKG_ERROR.LOG_ERROR procedure as follows:
PROCEDURE SP_TEST
IS
v_NUMBER NUMBER;
BEGIN
SELECT 1 / 0
INTO v_NUMBER
FROM DUAL;
EXCEPTION
WHEN OTHERS THEN
PKG_ERROR.LOG_ERROR(param_1, param_N);
END PROCEDURE SP_TEST;
I tried numerous codes and place them on the PKG_ERROR.LOG_ERROR procedure but to no avail:
#1
-- did not return the ERROR'd SQL Statement
SELECT q.sql_text
INTO captured_sql
FROM gv$sql q, gv$sql_cursor c, gv$session s
WHERE s.audsid = USERENV('sessionid')
AND s.prev_sql_addr = q.address
AND q.address = c.parent_handle;
#2
-- Only works in Database Error Trigger (I would like a solution via Package)
DECLARE
l_text ora_name_list_t;
l_n number;
BEGIN
dbms_output.put_line( '--------------------' );
dbms_output.put_line('statment causing error: ' );
l_n := ora_sql_txt( l_text );
FOR i in 1 .. nvl(l_text.count,0)
LOOP
dbms_output.put_line(l_text(i) );
END LOOP;
dbms_output.put_line( 'error text: ' );
FOR i IN 1 .. ora_server_error_depth
LOOP
dbms_output.put_line(ora_server_error_msg(i) );
END LOOP;
dbms_output.put_line( '--------------------' );
END;
#3
-- as per PSOUG it is returns the first 4K bytes of the current SQL that triggered the fine-grained auditing event. (I'm not using FGA)
SELECT sys_context('USERENV', 'CURRENT_SQL') FROM dual;
Is it possible??
Thanks,
Henry Wu<My problem now is how to get the SQL_STATEMENT that caused the error.>
We use a location variable that indicates where in a program the error occurred, something like
variable v_location_c VARCHAR2(10);
v_location_c := '1000000000';
UPDATE ...
EXCEPTION
WHEN OTHERS THEN
log_error('program_name',user,v_location_c, ...) -
Issue in SYS_CONTEXT function
Dear Friends,
I have an issue in SYS_CONTEXT function. If I run the SYS_CONTEXT function SQL query in SQL PLUS and SQL Developer Tool, the values are showing differently in both the tools.
CASE 1: In SQL Developer Tool,
SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') from dual;
SYS_CONTEXT('USERENV','IP_ADDRESS')
10.1.118.101
SQL> SELECT SYS_CONTEXT('USERENV','OS_USER') from dual;
SYS_CONTEXT('USERENV','OS_USER')
Administrator
CASE 2: In SQL * PLUS Tool,
SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') from dual;
SYS_CONTEXT('USERENV','IP_ADDRESS')
192.168.12.164
SQL> SELECT SYS_CONTEXT('USERENV','OS_USER') from dual;
SYS_CONTEXT('USERENV','OS_USER')
Oracle
Important Details
OS Login User: Administrator
DB Connect User: Oracle
Server IP Address: 192.168.12.164
System IP Address: 10.1.118.101
SQL> select * from v$version;
BANNER
Oracle Database 10g Release 10.2.0.1.0 - 64bit Production
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
I am using the same queries in both the tools, but the output is coming differently, Can you help me to solve the issue.
ThanksIP_ADDRESS
IP address of the machine from which the client is connected. If the client and server are on the same machine and the connection uses IPv6 addressing, then ::1 is returned. -
SYS_CONTEXT not returning results
Hi - noobie question,sorry in advance.
I'm studying for the OCA and I've come across a function called SYS_CONTEXT
[http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions184.htm#SQLRF06117]
I'm trying to retrieve my own IP address by using SYS_CONTEXT('USERENV', 'IP_ADDRESS'). SQL*Plus is accepting it but returning nothing and I don't know why. I've tried a few arguments (e.g. SYS_CONTEXT('USERENV', 'AUTHENTICATION_DATA') but still nothing is returned. Always using USERENV as I believe this is the built-in namespace in Oracle.
any advice helpful at this point.
PS I'm connected to OracleXE as SYSTEM1006948 wrote:
Hi - noobie question,sorry in advance.
I'm studying for the OCA and I've come across a function called SYS_CONTEXT
[http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions184.htm#SQLRF06117]
I'm trying to retrieve my own IP address by using SYS_CONTEXT('USERENV', 'IP_ADDRESS'). SQL*Plus is accepting it but returning nothing and I don't know why. I've tried a few arguments (e.g. SYS_CONTEXT('USERENV', 'AUTHENTICATION_DATA') but still nothing is returned. Always using USERENV as I believe this is the built-in namespace in Oracle.
any advice helpful at this point.
PS I'm connected to OracleXE as SYSTEMDon't connect as sys or system (there's a very small number of cases in which you need to do that).
Those accounts are "special" and shouldn't be used for day to day operations like what you are trying to do. Playing in those accounts will cause you no shortage of headaches.
Cheers,
Maybe you are looking for
-
Illegal access error at runtime
Hi, I am getting an illegal access error while trying to call a method. - Class1 tries to call method on Class2. - Method has package visibility - Both classes are in same package. - Class1 is being invoked by a class in a Web Application which is in
-
ITunes won't recognize my iPhone 4, wants me to restore to factory settings?
I'm running iTunes 10.4 with an iPhone 4 OS 4.2.1. I tried to sync my iPhone but got this message: "iTunes cannot read the contents of the iPhone. Go to the Summary tab and click Restore to restore to factory settings." This is not a jailbroken phone
-
Different connection pool for a report
Hi experts, For one my reports using 'CLOBS' like explained (http://oraclebizint.wordpress.com/2007/11/12/oracle-bi-ee-101332-working-with-clob-fields/) I need to disable parallel processing because it's not supported. NO_PARALLEL and NO_INDEX_PARALL
-
I cannot write text on certain jpg images. Any help is appreciated. CS4-64bit, CS4-32bit, and Elements behaves same. I tried on Windows-7(64bit) and Windows-XP, but the symptom is same. After opening the captioned jpg image, I click "Text Tool", th
-
Passing Values back from Custom Tag
I'm using custom tags, and I'm trying to pass back values to the JSP page from a tag which is iterating over values it gets from an Array. But for some reason I can't access the values. Here is the Tag: public class MemberHelper extends TagSupport im