Dual OU s in DN string

Hi all,
I have a problem with distinguished name dn string. By the way, I am new to dn string.
under active dir win2008 I have 2 organizational units. such as, ou=I.T. and ou=darknight
I.T. - has user1 -- it has dots after I and T
darknight - has user2
Both of OU s are under darknight.com as organizational units. When I type for distinguished name in apex ldap auth., I can write only one of them in order to successfully authenticate for appropriate user names.
cn=%LDAP_USER%,ou=I.T.,dc=darknight,dc=com
or
cn=%LDAP_USER%,ou=darknight,dc=darknight,dc=com
In case of both OU s as below:
cn=%LDAP_USER%,ou=darknight,ou=I.T.,dc=darknight,dc=com
it does not work giving "invalid credentials" error for any user. So, how can I make dual ou in dn string? or what is the solution for dual organizational units?
Thanks in advance.
Edited by: Zair S. on Jun 8, 2012 5:13 AM

I've been thinking about this issue since your original post.. I was wondering if it'd be possible to use macro ACIs to implement this...
For example, you could create an objectClass called "publicOU" and assign it to your OUs you want to be public. Then, you could use an ACI like this (heavily borrowed from the DS 6.2 documentation):
aci: (targetattr="*")
(targetfilter=(objectClass=publicOU))(version 3.0;
acl "Allow Public OUs to be visible"; allow (read,search) userdn=
"ldap:///anyone";)
There may be more elegant ways to do this, but I think it would work...

Similar Messages

  • How to search the location of the single quote using instr func in a string

    I have a string '345634','234'(all 4 single quotes are part of the string) and I want to find the location of the 3rd single quote using the instr function , could sum1 quickly please help me out.
    Regards
    Rahul
    Edited by: Rahul Kalra on Aug 26, 2010 8:58 AM

    Carlovski wrote:
    You really do learn something new every day!
    It really is quite ugly syntax though.Not really. You can use whatever character you want to indicate the start and end of the string, but if you use any of the brackets "[", "(" or "{" you should terminate using the opposing bracket "]", ")" or "}" respectively. It also looks a bit more ugly with data like that, but if you are entering regular text then it looks ok...
    e.g.
    SQL> select q'[This is my string with fred's quotes in it]' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL> select q'(This is my string with fred's quotes in it)' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL> select q'{This is my string with fred's quotes in it}' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL> select q'.This is my string with fred's quotes in it.' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL> select q'#This is my string with fred's quotes in it#' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL> select q'`This is my string with fred's quotes in it`' as mystring from dual;
    MYSTRING
    This is my string with fred's quotes in it
    SQL>Well... almost any character...
    SQL> select q'¼This is my string with fred's quotes in it¼' as mystring from dual;
    ERROR:
    ORA-01756: quoted string not properly terminated

  • ORA-01756: quoted string not properly terminated (using (q) operator

    Hi
    I tried this example but giving the error
    select q'( it's done )' from dualbut the following is working
    select q'( it''s done )' from dualIf i need to use it''s done then what is the use of (q) operator
    Thanks..
    Edited by: josh1612 on May 10, 2010 11:09 PM

    What is your database version ? Q-quote operator introduced in Oracle 10g and see the example, you might be facing this error.
    This is in SQL *PLUS V 9.2.0.1.0
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> select q'( it's done )' from dual;
    ERROR:
    ORA-01756: quoted string not properly terminated
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 11 12:58:12 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    SQL> conn hr/hr
    Connected.
    SQL> select q'( it's done )' from dual;
    Q'(IT'SDONE
    it's doneEdited by: Saubhik on May 11, 2010 12:28 AM

  • SQL String formatting - help

    I have a simple sql statement that works (in my case, returns 28 rows).
    select columna,
    columnb
    from table
    where columnb in ('Value1','Value2')
    Next, I can do something like:
    select ''''||replace('Value1,Value2',',',''',''')||'''' from dual and it returns a string:
    (''''||REPLACE('VALUE1,VALUE2',',',''',''')||'''')
    'Value1','Value2'
    What I would like to do, is combine the two statements because the "in" statement will depend on a comma separated value list that the user will supply (which is why I'm trying to format it as an "in" statement would be formatted)
    I've tried:
    select columna,
    columnb
    from table
    where columnb in (select ''''||replace('Value1,Value2',',',''',''')||'''' from dual);
    This SQL statement returns 0 rows instead of my 28 that I think I should get. What am I doing wrong?

    You may want to use Dynamic SQL, since the "in" list needs to be built each time:
    SQL> var cr refcursor
    SQL>
    SQL> declare
    2 v_first_char varchar2(100);
    3 v_qry varchar2(1000);
    4 begin
    5 v_first_char := ''''||replace('&first_char',',',''',''')||'''';
    6 v_qry := 'select empno,ename from emp where substr(ename,1,1) in ('||v_first_char||')';
    7 open :cr for v_qry;
    8 end;
    9 /
    Enter value for first_char: A
    PL/SQL procedure successfully completed.
    SQL> print cr
    EMPNO ENAME
    7499 ALLEN
    7876 ADAMS
    SQL>
    SQL> /
    Enter value for first_char: A,J
    PL/SQL procedure successfully completed.
    SQL> print cr
    EMPNO ENAME
    7499 ALLEN
    7566 JONES
    7876 ADAMS
    7900 JAMES
    SQL>
    SQL>

  • SQL Query to get match string from table

    Hi Experts,
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production         
    PL/SQL Release 11.1.0.7.0 - Production                                         
    CORE     11.1.0.7.0     Production                                                     
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production                        
    NLSRTL Version 11.1.0.7.0 - Production                                         
    5 rows selected.
    WITH T AS
    SELECT 'JOHN' FIRSTNAME,'PLAYER' LASTNAME FROM DUAL UNION ALL
    SELECT 'MICHEAL','SMITH' LASTNAME FROM DUAL UNION ALL
    SELECT 'SCOTT','MANAGER' LASTNAME FROM DUAL UNION ALL
    SELECT 'FIRST NAME','LAST NAME' LASTNAME FROM DUAL
    )SELECT * FROM T;
    Input String to my Query will be "JOHN NAME SMITH"
    I need to match the input string to provide result based on Firstname OR Lastname from table.
    How can i acheive this?
    Thanks,

    what the problem in constructing??
    you can use something like this....
    declare
    vStrng varchar2(100) := 'JOHN NAME SMITH';
    v_temp varchar2(1000):= 'SELECT  DISTINCT  firstname,lastname FROM employees,
      (SELECT regexp_substr('''||vStrng||''',''[[:alpha:]]+'',1,level) parsedstr
         FROM dual
        CONNECT BY level<=LENGTH(regexp_replace('''||vStrng||''',''[[:alpha:]]'',''''))+1
      ) WHERE instr(firstname,parsedstr)>0 OR instr(lastname,parsedstr)      >0';
    vSQL varchar2(1000):= 'SELECT ENAME,EMPNO,DEPT.DEPTNO FROM EMP,DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO AND (firstname,lastname) in ('||v_temp||')';
    begin
    --rest of your code....
    end;edit: In the same way...you can use any of the above mentioned solutions..
    Ravi Kumar
    Edited by: ravikumar.sv on Apr 6, 2010 4:12 PM

  • Generate Insert Statement Script to Extract Data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that is running for over 15 years.Every now and then we need to extract data from this table@ ORacle 7i to be imported back to Oracle 10G.
    My thoughts are to create a script of Insert statements in oracle 7 and that to be deployed back to Oracle 10G.
    I found this scripts in Google and not sure how exactly this works.Any explanation on thsi scripts , would be greatly appreciated.I find this scripst may help to generate a set of insert statements from that table to the latest table at 10G.
    <pre>
    -- Step 1: Create this procedure:
    create or replace Function ExtractData(v_table_name varchar2) return varchar2 As
    b_found boolean:=false;
    v_tempa varchar2(8000);
    v_tempb varchar2(8000);
    v_tempc varchar2(255);
    begin
    for tab_rec in (select table_name from user_tables where table_name=upper(v_table_name))
    loop
    b_found:=true;
    v_tempa:='select ''insert into '||tab_rec.table_name||' (';
    for col_rec in (select * from user_tab_columns
    where
    table_name=tab_rec.table_name
    order by
    column_id)
    loop
    if col_rec.column_id=1 then
    v_tempa:=v_tempa||'''||chr(10)||''';
    else
    v_tempa:=v_tempa||',''||chr(10)||''';
    v_tempb:=v_tempb||',''||chr(10)||''';
    end if;
    v_tempa:=v_tempa||col_rec.column_name;
    if instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc:='''''''''||'||col_rec.column_name||'||''''''''';
    elsif instr(col_rec.data_type,'DATE') > 0 then
    v_tempc:='''to_date(''''''||to_char('||col_rec.column_name||',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
    else
    v_tempc:=col_rec.column_name;
    end if;
    v_tempb:=v_tempb||'''||decode('||col_rec.column_name||',Null,''Null'','||v_tempc||')||''';
    end loop;
    v_tempa:=v_tempa||') values ('||v_tempb||');'' from '||tab_rec.table_name||';';
    end loop;
    if Not b_found then
    v_tempa:='-- Table '||v_table_name||' not found';
    else
    v_tempa:=v_tempa||chr(10)||'select ''-- commit;'' from dual;';
    end if;
    return v_tempa;
    end;
    show errors
    -- STEP 2: Run the following code to extract the data.
    set head off
    set pages 0
    set trims on
    set lines 2000
    set feed off
    set echo off
    var retline varchar2(4000)
    spool c:\t1.sql
    select 'set echo off' from dual;
    select 'spool c:\recreatedata.sql' from dual;
    select 'select ''-- This data was extracted on ''||to_char(sysdate,''mm/dd/yyyy hh24:mi'') from dual;' from dual;
    -- Repeat the following two lines as many times as tables you want to extract
    exec :retline:=ExtractData('dept');
    print :retline;
    exec :retline:=ExtractData('emp');
    print :retline;
    select 'spool off' from dual;
    spool off
    @c:\t1
    -- STEP3: Run the spooled output c:\recreatedata.sql to recreate data.
    Source:http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml
    </pre>

    Thanks Justin.
    I get what you are saying,i really wanted to see the output of the codes, because the furtherst i could get from that code is
    SELECT EXTRACTDATA('MYTABLE') FROM MYTABLE;
    and it generated this:
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    I was expecting a string of
    insert into mytable values (19/1/2009,1,1);
    insert into mytable values (19/10/2008,5,10);
    Thanks for the explanation .

  • Calling a PL/SQL web service from a procedure

    Does someone can help me , I have to call a PL//SQL web service_ but it's on a https server. It uses Oracle Wallet.
    I want to know the step ( and/or the code) to be able to do so
    Here's what I have :
    I want to call that :
    http://207.253.66.69/frsq_dev/FRSQ_NIP_EXISTS?pNOM_NAISS=Bouchard&pPRENOM=Disane&pNOM_MERE=Thibault&pSEXE=F&pDATE_NAISS_YYYY=1960&pDATE_NAISS_MM=04&pDATE_NAISS_DD=24
    It's suppose to return me a string.
    I have the code to do it without the https part (easy!), but I want to have the way to do it https! :
    vURL := 'http://207.253.66.69/frsq_dev/FRSQ_NIP_EXISTS?pNOM_NAISS=' || pNOM_NAISS || '&pPRENOM=' || pPRENOM || '&pNOM_MERE=' || pNOM_MERE || '&pSEXE=' || pSEXE || '&pDATE_NAISS_YYYY=' || pAn_naissance
    || '&pDATE_NAISS_MM=' || pMois_naissance || '&pDATE_NAISS_DD=' || pJour_naissance;
    vURL := utl_url.escape(vURL);
    select UTL_HTTP.REQUEST(vURL) into resultat from dual;
    -- Result should have the string I want
    Thanks
    Jp
    Edited by: Jpmill on Jul 15, 2009 9:40 AM

    Oracle Link
    http://www.oracle.com/technology/products/jdev/howtos/10g/WS_DBCallout/DBCalloutWS_HowTo.htm
    HTH
    SS

  • Getting javax.mail.AuthenticationFailedException: EOF on socket. Need Help

    I am trying to get hotmail emails and store in Oracle 10g database.
    When I am executing receivemail procedure from Oracle 10g database. I am getting following error.
    connect to ESIMSCO_UTIL_OWNER
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<My email address>@hotmail.com', '<My email password>');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I did following steps, but still I am getting this error. Can somebady help me to solve this problem.
    connect sys/<password>@esimsco as sysdba
    connect to sys
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 30 16:02:04 2012
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> begin
    1 dbms_java.grant_permission( 'ESIMSCO_UTIL_OWNER', 'SYS:java.util.PropertyPermission', '*', 'read,write' );
    2 commit;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.net.SocketPermission',
    5 permission_name => '*',
    6 permission_action => 'connect,resolve'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.util.PropertyPermission',
    5 permission_name => '*',
    6 permission_action => 'read,write'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>
    Then I connect ESIMSCO_UTIL_OWNER.
    connect to ESIMSCO_UTIL_OWNER
    Create 2 tables.
    create table attachment(
    at_file varchar2(500),
    at_mimetype varchar2(500),
    at_attachment blob
    create table email (
    em_incident integer,
    em_from varchar2(1000),
    em_subject varchar2(1000),
    em_body nclob
    Then Create java source named receivemail.
    create or replace and compile java source named receivemail as
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import sqlj.runtime.*;
    import oracle.sql.BLOB;
    public class ReceiveMail
    static void getAttachments(Message message, int incidentNo)
    throws MessagingException, IOException, SQLException {
    //String attachments = "";
    Object content = message.getContent();
    if (content instanceof Multipart)
    // -- Multi part message which may contain attachment
    Multipart multipart = (Multipart)message.getContent();
    // -- Loop through all parts of the message
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i);
    String disposition = part.getDisposition();
    if ((disposition != null) &&(disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {
    //-- This part is a file attachment
    String fileName = incidentNo+"_"+part.getFileName().replace(' ','_');
    System.out.println("FILE: " + fileName);
    String contentType = part.getContentType();
    String mimeType = contentType.substring(0,contentType.indexOf(";"));
    System.out.println("FILETYPE: " + mimeType);
    InputStream is = part.getInputStream();
    // -- To work with a BLOB column you have to insert a record
    // -- with an emptly BLOB first.
    #sql { insert into attachment(at_file, at_mimetype, at_attachment)
    values (:fileName, :mimeType, empty_blob()) };
    // -- Retrieve the BLOB
    BLOB attachment = null;
    #sql { select at_attachment into :attachment
    from attachment where at_file = :fileName };
    // -- Fill the BLOB
    OutputStream os = attachment.getBinaryOutputStream();
    int j;
    while ((j = is.read()) != -1) {
    os.write(j);
    is.close();
    os.close();
    // -- Set the BLOB by updating the record
    #sql { update attachment set at_attachment = :attachment
    where at_file = :fileName };
    static String getPlainTextBody(Message message)
    throws MessagingException, IOException
    Object content = message.getContent();
    if (message.isMimeType("text/plain")) {
    // -- Message has plain text body only
    System.out.println("SIMPLE TEXT");
    return (String) content;
    } else if (message.isMimeType("multipart/*")) {
    // -- Message is multipart. Loop through the message parts to retrieve
    // -- the body.
    Multipart mp = (Multipart) message.getContent();
    int numParts = mp.getCount();
    System.out.println("MULTIPART: "+numParts);
    for (int i = 0; i < numParts; ++i) {
    System.out.println("PART: "+mp.getBodyPart(i).getContentType());
    if (mp.getBodyPart(i).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mp.getBodyPart(i).getContent();
    } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
    // -- Body is also multipart (both plain text and html).
    // -- Loop through the body parts to retrieve plain text part.
    MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
    int numBodyParts = mmp.getCount();
    System.out.println("MULTIBODYPART: "+numBodyParts);
    for (int j = 0; j < numBodyParts; ++j) {
    System.out.println("BODYPART: "+mmp.getBodyPart(j).getContentType());
    if (mmp.getBodyPart(j).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mmp.getBodyPart(j).getContent();
    return "";
    } else {
    System.out.println("UNKNOWN: "+message.getContentType());
    return "";
    static void saveMessage(Message message)
    throws MessagingException, IOException, SQLException
    //String body = "";
    int incidentNo;
    // -- Get a new incident number
    #sql { select seq_incident.nextval into :incidentNo from dual };
    // -- Get the header information
    String from = ((InternetAddress)message.getFrom()[0]).getAddress();
    System.out.println("FROM: "+ from);
    String subject = message.getSubject();
    System.out.println("SUBJECT: "+subject);
    // -- Retrieve the plain text body
    String body = getPlainTextBody(message);
    // -- Store the message in the email table
    #sql { insert into email (em_incident, em_from, em_subject, em_body)
    values (:incidentNo, :from, :subject, :body) };
    // -- Retrieve the attachments
    getAttachments(message, incidentNo);
    #sql { commit };
    // -- Mark message for deletion
    // message.setFlag(Flags.Flag.DELETED, true);
    public static String Receive(String POP3Server, String usr, String pwd)
    Store store = null;
    Folder folder = null;
    try
    // -- Get hold of the default session --
    Properties props = System.getProperties();
    props.put("mail.pop3.connectiontimeout", "60000");
    Session session = Session.getDefaultInstance(props, null);
    // -- Get hold of a POP3 message store, and connect to it --
    store = session.getStore("pop3");
    store.connect(POP3Server,995, usr, pwd);
    System.out.println("Connected");
    // -- Try to get hold of the default folder --
    folder = store.getDefaultFolder();
    if (folder == null) throw new Exception("No default folder");
    // -- ...and its INBOX --
    folder = folder.getFolder("INBOX");
    if (folder == null) throw new Exception("No POP3 INBOX");
    // -- Open the folder for read_write (to be able to delete message) --
    folder.open(Folder.READ_WRITE);
    // -- Get the message wrappers and process them --
    Message[] msgs = folder.getMessages();
    for (int msgNum = 0; msgNum < msgs.length; msgNum++){
    saveMessage(msgs[msgNum]);
    System.out.println("No more messages");
    return ("SUCCESS");
    catch (Exception ex){
    ex.printStackTrace();
    return ex.toString();
    finally{
    // -- Close down nicely --
    try{
    // close(true), to expunge deleted messages
    if (folder!=null) folder.close(true);
    if (store!=null) store.close();
    catch (Exception ex){
    //ex.printStackTrace();
    return ex.toString();
    Then create function receivemail.
    create or replace function receivemail(pop3_server in string,
    pop3_usr in string,
    pop3_pwd in string)
    return varchar2
    is language java name
    'ReceiveMail.Receive(java.lang.String,
    java.lang.String,
    java.lang.String) return String';
    And then trying to execute function receivemail, but I am getting following error.
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<Hotmail email address>@hotmail.com', 'Hotmail password');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......
    Edited by: Amol Karyakarte on 31-May-2012 7:27 AM

    Hello,
    I don't think this is the right forum, as this question seems to have nothing to do with the Oracle Forms tool.
    You'd better ask it in the database forum.
    Francois

  • Help to solve javax.mail.AuthenticationFailedException: EOF on socket

    I am trying to get hotmail emails and store in Oracle 10g database.
    When I am executing receivemail procedure from Oracle 10g database. I am getting following error.
    connect to ESIMSCO_UTIL_OWNER
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<My email address>@hotmail.com', '<My email password>');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I did following steps, but still I am getting this error. Can somebady help me to solve this problem.
    connect sys/<password>@esimsco as sysdba
    connect to sys
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 30 16:02:04 2012
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> begin
    1 dbms_java.grant_permission( 'ESIMSCO_UTIL_OWNER', 'SYS:java.util.PropertyPermission', '*', 'read,write' );
    2 commit;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.net.SocketPermission',
    5 permission_name => '*',
    6 permission_action => 'connect,resolve'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.util.PropertyPermission',
    5 permission_name => '*',
    6 permission_action => 'read,write'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>
    Then I connect ESIMSCO_UTIL_OWNER.
    connect to ESIMSCO_UTIL_OWNER
    Create 2 tables.
    create table attachment(
    at_file varchar2(500),
    at_mimetype varchar2(500),
    at_attachment blob
    create table email (
    em_incident integer,
    em_from varchar2(1000),
    em_subject varchar2(1000),
    em_body nclob
    Then Create java source named receivemail.
    create or replace and compile java source named receivemail as
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import sqlj.runtime.*;
    import oracle.sql.BLOB;
    public class ReceiveMail
    static void getAttachments(Message message, int incidentNo)
    throws MessagingException, IOException, SQLException {
    //String attachments = "";
    Object content = message.getContent();
    if (content instanceof Multipart)
    // -- Multi part message which may contain attachment
    Multipart multipart = (Multipart)message.getContent();
    // -- Loop through all parts of the message
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i);
    String disposition = part.getDisposition();
    if ((disposition != null) &&(disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {
    //-- This part is a file attachment
    String fileName = incidentNo+"_"+part.getFileName().replace(' ','_');
    System.out.println("FILE: " + fileName);
    String contentType = part.getContentType();
    String mimeType = contentType.substring(0,contentType.indexOf(";"));
    System.out.println("FILETYPE: " + mimeType);
    InputStream is = part.getInputStream();
    // -- To work with a BLOB column you have to insert a record
    // -- with an emptly BLOB first.
    #sql { insert into attachment(at_file, at_mimetype, at_attachment)
    values (:fileName, :mimeType, empty_blob()) };
    // -- Retrieve the BLOB
    BLOB attachment = null;
    #sql { select at_attachment into :attachment
    from attachment where at_file = :fileName };
    // -- Fill the BLOB
    OutputStream os = attachment.getBinaryOutputStream();
    int j;
    while ((j = is.read()) != -1) {
    os.write(j);
    is.close();
    os.close();
    // -- Set the BLOB by updating the record
    #sql { update attachment set at_attachment = :attachment
    where at_file = :fileName };
    static String getPlainTextBody(Message message)
    throws MessagingException, IOException
    Object content = message.getContent();
    if (message.isMimeType("text/plain")) {
    // -- Message has plain text body only
    System.out.println("SIMPLE TEXT");
    return (String) content;
    } else if (message.isMimeType("multipart/*")) {
    // -- Message is multipart. Loop through the message parts to retrieve
    // -- the body.
    Multipart mp = (Multipart) message.getContent();
    int numParts = mp.getCount();
    System.out.println("MULTIPART: "+numParts);
    for (int i = 0; i < numParts; ++i) {
    System.out.println("PART: "+mp.getBodyPart(i).getContentType());
    if (mp.getBodyPart(i).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mp.getBodyPart(i).getContent();
    } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
    // -- Body is also multipart (both plain text and html).
    // -- Loop through the body parts to retrieve plain text part.
    MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
    int numBodyParts = mmp.getCount();
    System.out.println("MULTIBODYPART: "+numBodyParts);
    for (int j = 0; j < numBodyParts; ++j) {
    System.out.println("BODYPART: "+mmp.getBodyPart(j).getContentType());
    if (mmp.getBodyPart(j).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mmp.getBodyPart(j).getContent();
    return "";
    } else {
    System.out.println("UNKNOWN: "+message.getContentType());
    return "";
    static void saveMessage(Message message)
    throws MessagingException, IOException, SQLException
    //String body = "";
    int incidentNo;
    // -- Get a new incident number
    #sql { select seq_incident.nextval into :incidentNo from dual };
    // -- Get the header information
    String from = ((InternetAddress)message.getFrom()[0]).getAddress();
    System.out.println("FROM: "+ from);
    String subject = message.getSubject();
    System.out.println("SUBJECT: "+subject);
    // -- Retrieve the plain text body
    String body = getPlainTextBody(message);
    // -- Store the message in the email table
    #sql { insert into email (em_incident, em_from, em_subject, em_body)
    values (:incidentNo, :from, :subject, :body) };
    // -- Retrieve the attachments
    getAttachments(message, incidentNo);
    #sql { commit };
    // -- Mark message for deletion
    // message.setFlag(Flags.Flag.DELETED, true);
    public static String Receive(String POP3Server, String usr, String pwd)
    Store store = null;
    Folder folder = null;
    try
    // -- Get hold of the default session --
    Properties props = System.getProperties();
    props.put("mail.pop3.connectiontimeout", "60000");
    Session session = Session.getDefaultInstance(props, null);
    // -- Get hold of a POP3 message store, and connect to it --
    store = session.getStore("pop3");
    store.connect(POP3Server,995, usr, pwd);
    System.out.println("Connected");
    // -- Try to get hold of the default folder --
    folder = store.getDefaultFolder();
    if (folder == null) throw new Exception("No default folder");
    // -- ...and its INBOX --
    folder = folder.getFolder("INBOX");
    if (folder == null) throw new Exception("No POP3 INBOX");
    // -- Open the folder for read_write (to be able to delete message) --
    folder.open(Folder.READ_WRITE);
    // -- Get the message wrappers and process them --
    Message[] msgs = folder.getMessages();
    for (int msgNum = 0; msgNum < msgs.length; msgNum++){
    saveMessage(msgs[msgNum]);
    System.out.println("No more messages");
    return ("SUCCESS");
    catch (Exception ex){
    ex.printStackTrace();
    return ex.toString();
    finally{
    // -- Close down nicely --
    try{
    // close(true), to expunge deleted messages
    if (folder!=null) folder.close(true);
    if (store!=null) store.close();
    catch (Exception ex){
    //ex.printStackTrace();
    return ex.toString();
    Then create function receivemail.
    create or replace function receivemail(pop3_server in string,
    pop3_usr in string,
    pop3_pwd in string)
    return varchar2
    is language java name
    'ReceiveMail.Receive(java.lang.String,
    java.lang.String,
    java.lang.String) return String';
    And then trying to execute function receivemail, but I am getting following error.
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<Hotmail email address>@hotmail.com', 'Hotmail password');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......

    Amol Karyakarte wrote:
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......since you asked for it:
    http://lmgtfy.com/?q=javax.mail.AuthenticationFailedException
    First hit
    Session session = Session.getDefaultInstance(props, null);Is null correct?
    Regards

  • Pivot Query on Oracle 10g

    Table Structure
    GRP_NR Values
    1 A
    1 B
    2 A
    2 B
    2 C
    3 A
    3 B
    3 C
    N A
    N B
    N C
    I would like to convert the above structure into the following. I prefer to have it as sql query, but open to plsql solution too.
    1 2 3 ..................... N
    A A A ..................... A
    B B B ..................... B
    . C C ..................... C
    I am finding it quite a challenge to do it. especially to make it dynamic.
    I will appreciate your help.

    With model clause.
    Regards salim.
    select GRP_NR, substr( string, 2 ) as string
    from t
    model
    return updated rows
    partition by ( GRP_NR )
    dimension by ( row_number() over (partition by GRP_NR ORDER BY val asc) as position )
    measures ( cast( val as varchar2(1000) ) as string )
    rules
    upsert
    iterate(1000 )
    until ( presentv(string[iteration_number+2],1,0) = 0 )
    ( string[0] = string[0] || ',' || string[iteration_number+1] )
    order by GRP_NR ;
    SQL> with t as (
      2  select 1 GRP_NR, 'A' val from dual union all
      3  select 1 ,'B' val from dual union all
      4  select 2 ,'A' val from dual union all
      5  select 2 ,'B' val from dual union all
      6  select 2 ,'C' val from dual union all
      7  select 3 ,'A' val from dual union all
      8  select 3 ,'B' val from dual union all
      9  select 3 ,'C' val from dual )
    10  select GRP_NR, substr( string, 2 ) as string
    11  from t
    12  model
    13  return updated rows
    14  partition by ( GRP_NR )
    15  dimension by ( row_number() over (partition by GRP_NR ORDER BY val asc) as position )
    16  measures ( cast( val as varchar2(1000) ) as string )
    17  rules
    18  upsert
    19  iterate(1000 )
    20  until ( presentv(string[iteration_number+2],1,0) = 0 )
    21  ( string[0] = string[0] || ',' || string[iteration_number+1] )
    22  order by GRP_NR ;
        GRP_NR STRING
             1 A,B
             2 A,B,C
             3 A,B,C
    SQL>

  • Invalid Number Using 'IN' Clause

    Hi,
    I use the following select statement to populate a report.
    <p>
    SELECT cpnidd, ...
    FROM pdrcpn, pdrcpnsts
    WHERE pdrcpnsts.cpnref1=pdrcpn.cpnref
    AND pdrcpn.bizidd1 IN (SELECT PKG_APEX.GetUserBizIds(:APP_USER) from dual)
    <p>
    In the <b>IN</b> clause I use a call to a function to return a list of comma seperated numbers. This only works if a single number is returned, if more than one number is returned (eg. 23,34) I get the following error:
    <p>
    report error:
    ORA-01722: invalid number
    <p>
    Am stumped as to why this is happening or how I can fix it, any help would be greatly appreciated.
    <p>
    Cheers
    <p>
    Simon

    'bizidd1' is a number so SQL is expecting a list of numbers separated by comas. What '(SELECT PKG_APEX.GetUserBizIds(:APP_USER) from dual)' returns is one text string. So if it returns '1,2,3,4' your SELECT will execute the following:
    SELECT cpnidd, ...
      FROM pdrcpn, pdrcpnsts
    WHERE pdrcpnsts.cpnref1=pdrcpn.cpnref
      AND pdrcpn.bizidd1 IN <B>'1,2,3,4'</B>Where what you want to execute is really:
    SELECT cpnidd, ...
      FROM pdrcpn, pdrcpnsts
    WHERE pdrcpnsts.cpnref1=pdrcpn.cpnref
      AND pdrcpn.bizidd1 IN <B>(1,2,3,4)</B>So how to get it to work. Whatever table PKG_APEX.GetUserBizIds retrieves it values from (say YOUR_TABLE) change your SELECT to be something like:
    SELECT cpnidd, ...
      FROM pdrcpn, pdrcpnsts
    WHERE pdrcpnsts.cpnref1=pdrcpn.cpnref
      AND pdrcpn.bizidd1 IN <B>(SELECT your_column FROM your_table WHERE id = :APP_USER)</B>If you are using the SELECT statement for a report region, you could change your region to a PL/SQL function that returns the SELECT statement like:
    DECLARE
      v_sql VARCHAR2(4000);  -- bad to hardcode limits
    BEGIN
      v_sql := 'SELECT cpnidd, ... '||
               '  FROM pdrcpn, pdrcpnsts '||
               ' WHERE pdrcpnsts.cpnref1=pdrcpn.cpnref '||
               '  AND pdrcpn.bizidd1 IN ('||
               REPLACE (PKG_APEX.GetUserBizIds(:APP_USER)||' )';
      RETURN(v_sql);
    END;in a PL/SQL variable and
    Mike

  • Creating blank column in view

    Hi guys, I have created a view which obviously gets data from different tables, however I will (in the future) have an additional row in this view obtaining data from somewhere but as of yet that data does not exist, is it possible to create a row in a view and stick a random value in it untill i have the data available to go back and change it. The reason i need this row is that im creating a report and I want to bring in the column with some random txt in it then once the data is available simply change the view which will save me having to change the report if you get my drift?
    Any help would be greatly appreciated.

    786733 wrote:
    Hi guys, I have created a view which obviously gets data from different tables, however I will (in the future) have an additional row in this view obtaining data from somewhere but as of yet that data does not exist, is it possible to create a row in a view and stick a random value in it untill i have the data available to go back and change it. The reason i need this row is that im creating a report and I want to bring in the column with some random txt in it then once the data is available simply change the view which will save me having to change the report if you get my drift?
    Any help would be greatly appreciated.I think you want to add a column to the view (as the header suggests) and not an additional row. An addition row would make no difference for any reports. However an additional column will need to be cosidered in a report that is build upon that view.
    You can add extra columns to all selects statements. And your view is nothing but a stored select.
    example
    /* Base select */
    select * from dual;
    DUMMY
    X    
    /* Add a string null column colA */
    select d.*, '' as colA  from dual d;
    DUMMY COLA
    X    
    /* Add a number column colA */
    select d.*, cast(null as number) as colA  from dual d;
    DUMMY COLA
    X    
    /* Add a string column colA with random values*/
    select d.*, dbms_random.string('A', 10) as colA  from dual d;
    DUMMY COLA
    X     QvKJWWdbTw
                                                                                                                                                                                                        

  • Question: 9i- 10g

    Hi all,
    What does anyone know or have an opinion regarding 10g's ability with Virtual Private Databases/Row level security and Unix based servers providing client-server forms and reports services to browser based windows and unix clients?
    My organisation has been stuck in Forms 6 land because of heavy limitations of Forms 9's ability to handle row level security in this situation and I was curious to know if anyone has upgraded to 10g and resolved any issues in that regards.
    Thanks all.

    This is another article:
    TECHNOLOGY: Security
    Keeping Information Private with VPD
    By Arup Nanda
    Oracle's row-level security gives users their own virtual private databases.
    Ensuring appropriate information privacy is a pressing concern for many businesses today, given privacy legislation such as the United States' HIPAA (Health Insurance Portability and Accountability Act), Gramm-Leach-Bliley Act, Sarbanes-Oxley Act, and the EU's Safe Harbour Law. Other privacy mandates, such as Visa's Cardholder Information Security Program (CISP), also require businesses to ensure that access to information is tightly controlled.
    Oracle has always included the ability to grant (or deny) users access to database objects, but these privileges are defined at the object level—for an entire table, not for specific rows in that table. Although that approach is sufficient for many applications, any application touching on financial, health, or other kinds of personal information usually requires more-discrete controls over access and authorization.
    Oracle's row-level security (RLS) feature, introduced in Oracle8i, provides fine-grained access control—fine-grained means at the individual row level. Rather than opening up an entire table to any individual user who has any privileges on the table, row-level security restricts access to specific rows in a table. The result is that any individual user sees a completely different set of data—only the data that person is authorized to see—so the overall capabilities are sometimes referred to as Oracle's virtual private database, or VPD, feature.
    Using Oracle's VPD capabilities not only ensures that companies can build secure databases to adhere to privacy policies but also provides a more manageable approach to application development, because although the VPD-based policies restrict access to the database tables, they can be easily changed when necessary, without requiring modifications to application code.
    For example, say a bank's account managers (AMs) provide personal customer support to high-net-worth account holders. AMs use a custom banking application to help them check their customers' balances, deposit or withdraw funds, and decide on loan requirements, for example. At one time, the bank's policy was to allow all AMs to access all account holder information, but that policy was recently changed. Now, AMs are assigned to a particular set of customers, and they need to be able to access information pertaining only to those customers. The policy change needs to be reflected in the application, which currently shows all customer information to each AM, not just information on the customers to whom each particular AM is assigned.
    To make the application comply with the new privacy policy, the bank has three choices:
    Modify the application code to include a predicate (a WHERE clause) for all SQL statements. This option doesn't ensure privacy policy enforcement outside the application, however, and if there are other changes in the future, the code will once again have to be modified, so this is not a good approach in the long term.
    Leave the application intact, creating views with the necessary predicates and creating synonyms with the same name as the table names for these views. This option is better from the perspective of application changes and security, but it can be difficult to administer, because of the potentially large number of views to track and manage.
    Create a VPD for each of the AMs by creating policy functions that generate dynamic predicates, which can then be applied across all objects, regardless of how they are accessed, by setting up policies with the row-level-security built-in package (DBMS_RLS).
    This last option offers the best security without administrative overhead and ensures complete privacy of information—all the account managers see a different view of the table, according to their own credentials.
    This article shows you how to set up a VPD security model. It goes through the process by using the foregoing bank scenario to create policy functions, define policies, and then test results. (Note that the tables are not completely defined, to keep the example simple.)
    Basic Setup for the Example Application
    Briefly, here are the basic assumptions about the example bank application:
    A BANK schema owns two key tables that make up the application—a CUSTOMERS table:
    Name Null? Type
    CUST_ID NOT NULL NUMBER
    CUST_NAME NOT NULL VARCHAR2(20)
    and an ACCOUNTS table:
    Name Null? Type
    ACCT_NO NOT NULL NUMBER
    CUST_ID NOT NULL NUMBER
    BALANCE NUMBER(15,2)
    Listing 1 comprises the SQL script for creating and populating these two basic example tables.
    User SECMAN (security manager) owns an ACCESS_POLICY table that identifies the AMs and their respective customer accounts:
    Name Null? Type
    AM_NAME NOT NULL VARCHAR2(20)
    CUST_ID NOT NULL NUMBER
    ACCESS_TYPE NOT NULL CHAR(1)
    The AM_NAME column stores the user ID of the account manager; CUST_ID identifies the customer; and ACCESS_TYPE defines the specific access entitlement—S (SELECT), I (INSERT), D (DELETE), or U (UPDATE). Some example records from the ACCESS_POLICY table follow:
    AM_NAME CUST_ID ACCESS_TYPE
    SCOTT 123 S
    SCOTT 123 I
    SCOTT 123 D
    SCOTT 123 U
    SCOTT 456 S
    SCOTT 789 S
    LARA 456 I
    LARA 456 D
    LARA 456 U
    LARA 456 S
    As you can see, SCOTT, the AM for customer 123, has all privileges—S, I, D, and U—as does LARA for customer 456. Also, because SCOTT can confirm account balances for one customer of LARA, he has S privileges on customer 456.
    Step 1. Create a Policy Function
    The bank's access rules (contained in the ACCESS_POLICY table) must be applied somehow, dynamically, whenever an AM tries to look into customer account information. The first step is to create a policy function that returns the appropriate predicate to be applied to the table. As with the ACCESS_POLICY table, the policy functions are created and controlled by user SECMAN, for security purposes. It's best to keep privacy rules separate from the tables to which they apply.
    Let's examine the policy function, get_sel_cust_id—shown in Listing 2— in detail:
    Accepts exactly two parameters: the schema name (p_schema in varchar2) and the table name (p_table in varchar2)
    Returns one value only, a string—return varchar2 as l_retstr varchar2(2000);—comprising the predicate that will be appended to every query on the table
    Uses a cursor routine—for cust_ rec in—to get the list of values, because each user may have several cust_ids listed in the table
    Returns a constructed string—l_retstr—to be used as a predicate whenever any user attempts to access the underlying table
    The function returns the predicate where cust_id in with the appended list of customer accounts (cust_id), separated by commas, that the user (am_name = USER) is allowed to see.
    Note that before entering the loop that builds the list of cust_ids for the user, the code in Listing 2 checks to see if the user is the table owner BANK, in which case the function returns a NULL predicate, as follows:
    if (p_schema = user) then
    1_retstr := null;
    After building this function, you want to make sure it returns the appropriate predicate, by testing some sample data. Connect to the database as SECMAN, and insert some records into the ACCESS_POLICY table, giving SECMAN read privileges on a few sample accounts, as follows:
    insert into access_policy values ('SECMAN',123,'S');
    insert into access_policy values ('SECMAN',456,'S');
    insert into access_policy values ('SECMAN',789,'S');
    Now execute the function:
    select get_sel_cust_id
    ('BANK','CUSTOMERS') from dual;
    The function returns a string that will be applied as a predicate, as shown in the following sample output:
    GET_SEL_CUST_ID('BANK','CUSTOMERS')
    CUST_ID IN (123,456,789)
    You need to create similar functions for the other types of access. For simplicity's sake, create a single function for all the other access types—UPDATE, DELETE, INSERT—as shown in Listing 3. However, note that for a real-world application, each type of access should have its own individual function defined, to ensure appropriate privacy.
    The policy function in Listing 3 is nearly identical to the policy function in Listing 2, except that the predicate is further qualified by use of the information from the ACCESS_CONTROL table:
    and access_type in ('I', 'U', 'D')
    Creating a policy function is just the first step. You now need to ensure that the function will be used, by defining the policy that should control its use in your system.
    Step 2. Define a Policy
    Policies are defined with the DBMS_RLS package, which is Oracle-supplied. Be aware that the policies themselves are not database objects owned by any user (schema); they are logical constructs. Any user who has the execute privilege on the DBMS_RLS package can modify or drop a policy created by another user. Privileges to DBMS_RLS should be judiciously controlled and granted with caution.
    In the following example, user SECMAN is granted execute privileges (by SYS) on the DBMS_RLS package:
    grant execute on dbms_rls to secman;
    Listing 4 creates a policy named CUST_SEL_POLICY on the table CUSTOMERS of schema BANK. This policy applies the predicate returned by the function GET_SEL_CUST_ID (which is shown in Listing 2) owned by schema SECMAN to all SELECT statements on the table.
    Similarly, you place another policy on the table for other access types, as shown in Listing 5. This policy applies to inserts, updates, and deletes in the CUSTOMERS table.
    It is almost identical to the SELECT policy, except that this policy includes a check that ensures that the policy will remain compliant even after an update:
    update_check => TRUE
    Data cannot be added to the table unless it adheres to the policy.
    Step 3. Test the Setup
    Now that the building blocks are in place, let's see how they work. Connecting as user BANK and issuing a simple select * from customers; query displays the following:
    CUST_ID CUST_NAME
    123 Jay Kulkarni
    456 Wim Patel
    These two records are the full contents of the CUSTOMERS table, and both records are shown because BANK owns the table, so the predicate clause is NULL—that is, no predicate is applied. However, when user LARA makes the same query, she sees the following:
    select * from customers;
    CUST_ID CUST_NAME
    456 WIM PATEL
    LARA sees only CUST_ID 456, not 123, because that is the row she is authorized to see, as determined by the ACCESS_ POLICY table. Note that the query has no WHERE clause but that the selection from the table is automatically filtered to show only the authorized rows.
    If user SCOTT makes the same query, his results are different from the results for LARA: select * from customers;
    CUST_ID CUST_NAME
    123 Jay Kulkarni
    456 Wim Patel
    User SCOTT sees both rows, because he is authorized to do so, as shown in the ACCESS_POLICY table. When user LARA issues the query, the policy function get_sel_cust_id returns the predicate where cust_id in (456). Lara's original query select * from customers is rewritten as
    select * from
    (select * from customers)
    where cust_id in (456)
    The predicate is automatically appended to the user's original query. The same thing happens when the user updates the table:
    SQL> update bank.customers
    2 set cust_name = 'PAT TERRY';
    1 row updated.
    Note that in this example, only one row is updated, even though there are actually two rows in the underlying table. The policy (CUST_IUD_POLICY) appends the predicate where cust_id in (456) to the update statement. Similarly, while the table is being deleted, only the rows for which the user is authorized are deleted.
    Attempting to insert a row containing data for which the user is not authorized results in an error message. For example, in this query, LARA is attempting to add a record to the CUSTOMER table for an account not under her purview: Next Steps
    READ more about
    VPD Oracle9i Supplied PL/SQL Packages and Types Reference
    Oracle Privacy Security Auditing
    SQL> insert into bank.customers
    2 values (789,'KIM PARK');
    insert into bank.customers
    ERROR at line 1:
    ORA-28115: policy with check option
    violation
    According to the ACCESS_POLICY table, Scott has SELECT privileges on account 789—no other privileges for any other AM are listed in the table.
    Using policies in conjunction with functions ensures authorized access to specific records of a table. The rules are applied regardless of how the table is accessed, whether through an application or directly through an ad hoc query tool, such as SQL*Plus. Users see only rows for which they have been authorized.
    Policies can be applied to multiple tables, and a single policy function can be used by any number of policies. Listing 6 shows a policy on an ACCOUNTS table that uses the get_sel_cust_id function initially created for use with the CUSTOMERS table.
    Arup Nanda ([email protected]) is the chief database architect at Proligence Solutions ( Printer View
    http://otn.oracle.com/oramag/oracle/04-mar/o24tech_security.html
    Joel Pérez
    http://otn.oracle.com/experts

  • How pervasive is this regex bug?  Is there an official bug ID?

    Oracle has a bug in their regular expression handling in 10g 2 and 11g 2. Is this bug also in XE? If so, does it have a bug number I can reference? I don't have support, I'm just evaluating Oracle Database offerings for our company.
    The bug: With 10g 2 Oracle released support for non-greedy quantifiers in regular expressions. See http://docs.oracle.com/cd/E11882_01/appdev.112/e25518/adfns_regexp.htm#autoId6
    However, it has bugs.
    SQL*Plus: Release 10.2.0.5.0 - Production on Tue May 28 22:20:07 2013
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    SQL> select regexp_substr('foo, bar, qux,','.*b.*?,') from dual;
    REGEXP_SUBSTR(
    foo, bar, qux,
    SQL> select regexp_substr('foo, bar, qux,','.*?b.*,') from dual;
    REGEXP_SU
    foo, bar,and same results on SQL*Plus: Release 11.2.0.1.0 Production. This is obviously a bug. One can argue about the differing possible interpretations of the sequence `.\*?`, but there is nothing that suggest `b.\*,` shouldn't pick up `qux`. I have a dozen other examples if you want. So my question is that since this has been a bug in released production code for over a year, is there a bug/defect number I can use to track it's eventual resolution? I don't have a support contract to ask support directly because I'm just evaluating right now. I'm trying to push for Oracle but bugs like this make it hard for me to use the argument that Oracle is relatively bug free.
    Fixed * interpreted as markup

    Oracle has a bug in their regular expression handling in 10g 2 and 11g 2. Is this bug also in XE?If a bug exists in Oracle Database 11.2.0.2, it's very likely to exist in 11.2 XE as well, as 11.2 XE is based on that version.
    and same results on SQL*Plus: Release 11.2.0.1.0 ProductionThis is no matter of SQL*Plus, as this is only the client, while the query you execute is processed by the database you're connected to.
    Despite that, I wonder how it comes you have SQL*Plus 11.2.0.1.0 on your machine, because XE ships with 11.2.0.2. But this has no impact on your issue...
    but there is nothing that suggest `b.*,` shouldn't pick up `qux`. I'm not sure about that. It's a question of where your "preceding" definition ends and how you interprete the documentation. See the differences (or no difference) when using subgroups to separate greedy and nongreedy operators explicitly, e. g.
    select regexp_substr('foo, bar, qux, ','.*?(b.*,)') from dual;
    -- or even
    select regexp_substr('foo, bar, qux, ','(.*?b)(.*,)') from dual; return foo, bar,, which would fit the "first string to match" strategy documented for regexp_substr.
    On the other hand, you could enforce the behaviour you seem to expect with making the greedy subgroup explicit.
    select regexp_substr('foo, bar, qux, ','.*?b(.*,)') from dual;
    -- or
    select regexp_substr('foo, bar, qux, ','(.*b)(.*?,)') from dual; will return your complete string.
    Of course, you can always argue on whether you should "reuse" characters for different groups when evaluating the regex. From my personal experience, using explicit subgroups helps structuring (and understanding) your regex and makes moving through different implementations easier...
    I'm trying to push for Oracle but bugs like this make it hard for me to use the argument that Oracle is relatively bug free.This is mostly a point of view, as your "relatively" indicates...
    -Udo

  • The Regular Expressions and GUID.

    Hello gurus, I hope you can help me!
    I am needing to select GUIDS from a table and for this, I need the Regular Expression. My
    Perl is not good and not good Regular Expression. My database is Oralce 11.2.0.2.0 and
    the Operating System of the Machine is Linux (Oracle Version 6). If you require the further information,
    I will watch closely. Thank you. Jehangir.

    >
    Hi Jehangir and welcome to the forums.
    I am needing to select GUIDS from a table and for this,Well, the first thing you should do is read the forum FAQ and also the post by BluShadow
    at the top of the posts on the forum home page. You should have provided code (DDL
    and DML) showing your particular problem, but since this is your first time, I'll be gentle ;)
    We have done this - sometimes clients have GUIDs as PKs and we need to send data to
    their systems, but it isn't as simple as it may first appear.
    GUIDs can come in three formats.
    The Oracle one - SELECT Sys_GUID() from DUAL which is just a string of 32 Hexadecimal characters.
    Then the string with hyphens and then the string with hypens and {} at beginning and end (see
    sample data).
    with datax as
      SELECT '79A864CCD8E44CD8B0A2765DF9EF337B' as guid  FROM DUAL  UNION ALL
      SELECT '79A864CFD8E44CD7B0A2765DF9EF337B' FROM DUAL UNION ALL
      SELECT '8gdfsgsgfdg' FROM DUAL UNION ALL  -- dummy for testing
      SELECT '21EC2020-3AEA-1069-A2DD-08002B30309D' FROM DUAL UNION ALL
      SELECT '21EC5550-3AEA-1069-A2FF-08002B30309D' FROM DUAL UNION All
      SELECT '{21CC2020-3AFA-1A69-A2DD-08002B30309D}' FROM DUAL
    -- first one is the Oracle format
    select * from datax where regexp_like(guid, '[0-9a-fA-F]{32}'); -- Oracle select sys_guid();
    -- second one is with hyphens
    select * from datax where regexp_like(guid, '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}');
    -- third one is with hyphens and curly brackets.
    select * from datax where regexp_like(guid, '^\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}$');
    -- This converts both of the last two formats back into Oracle format, which is what
    -- we use. Notice, that I haven't used regualar expressions to do this. Regexes are
    -- computationally expensive, and you should use Oracle's string furnctions if possible
    SELECT REPLACE(REPLACE(REPLACE(GUID, '{', ''), '}', ''), '-', '')  FROM Datax;HTH,
    Paul...
    Jehangir.

Maybe you are looking for

  • Error saving column settings with ORA-01403: no data found Error

    Hi I have a region with multi row report updatable. When I am trying to change the query I am getting below error. Anybody let me know what will be the problem. ORA-01403: no data found Error saving column settings Regards Kiran

  • I bought an album and its not showing up in my music library

    i pre ordered it a while ago and when i came out it never downloaded into my music library. It was lorde's new album.

  • Images on buttons

    Hi can anyone help me. I am currently using toggle buttons, but i use images as icons for these buttons. My problems is that the whole image does not seem to show on the button, only a part of the image shows. I am guessing it is because the image is

  • Email Activity Faults

    Hi, Email Activity is not throwing any Faults when SMTP server is not reachable. Is there any way the BPEL process know if that happend? I can see the error "Server not reachable' in logs. But Email activity is not throwing any Faults. Thanks --Sree

  • How to Get Adobe Connect 8 to report Captivate 5 scores as percent?

    I have the latest patch that over wrote CPSWFGenerator.dll that was supposed to fix this but it still doesn't work.  I have created/published a new test, have it set to report score as a percent, and have (what I think are) all of the reporting boxes