Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

OS group id for External Table Issue

Soumyajit HaldarAug 25 2014 — edited Aug 25 2014

Hi,

I have a distibuted environment where application and database are residing in two different unix servres. OS UID and GID for the user oracle:oinstall is different in two servers and thus we have an extra group ext_dba whose GID is same accross the server to access the files from application generated by db.

My application is EBS R12 (12.1.3) and database is 11.2.0.3. Both are running on Redhat Linus 5.8.

Everything is working fine for me except the files generated with EXTERNAL_TABLE. If I use UTL_FILE, files are generated with owner as oracle:ext_dba and thus can be accessed from application without any issue, however, if I execute the below SQL, the files are generating as oracle:oinstall, however the log file for the same is generated as oracle:ext_dba which causing my read from application to fail.

Any help is much appreciated.

Create table all_objects_xt

organization external

(

  type oracle datapump

  default directory custom_dir

  location ('allobj_25Aug.dmp')

)

parallel 4

as

select * from all_objects;

The files are generating as below:

$ ls -ltr allobj_15Aug.dmp

-rw-r----- 1 oracle oinstall 9039872 Aug 25 15:58 allobj_25Aug.dmp

$ ls -ltr all_objects_xt_2532.log

-rw-r--r-- 1 oracle ext_dba 41 Aug 25 15:58 all_objects_xt_2532.log

Regards,

Soumyajit

Comments

cormaco
Answer

You can write it down explicitly like this:

select * from employee_view  
where 
    :p_cnic = 'YES' and emp_cnic is not null or 
    :p_cnic = 'NO'  and emp_cnic is null
    
Marked as Answer by Muhammad Masoom Ansari · Aug 23 2021
BluShadow

undefined (0 Bytes)
Whilst order of precedence works, for clarity of reading (and to ensure future lazy developers don't break it so easily), I always prefer to use parentheses/brackets around my OR clauses...

select * from employee_view  
where 
    (    :p_cnic = 'YES'
     and emp_cnic is not null
    )
    or
    (    :p_cnic = 'NO'
     and emp_cnic is null
    )

Just makes it absolutely clear which clauses belong with which other clauses. Nothing worse than a future developer coming along adding another "and" clause thinking it will apply to everything but they've not seen the OR statement and then it's not working as it should.

Jan Gorkow

Hi Muhammad,
here's a little correction of the query of cormaco and BluShadow to satisfy your requirement to select all records if no value is passed:

SELECT *
  FROM employee_view
 WHERE    ( :p_cnic = 'YES' AND emp_cnic IS NOT NULL)
       OR ( :p_cnic = 'NO' AND emp_cnic IS NULL)
       OR ( :p_cnic IS NULL)

Best regards
Jan

Hi Cormaco
after little bit change giving me right answer such as
select emp_id,emp_name,emp_cnic
from employee_view a
where a.emp_id in ( select distinct emp_id from hml_emp_attend_register where month_id = :p_month )
and ( (:p_cnic = 'YES' and emp_cnic is not null) or
( :p_cnic = 'NO' and emp_cnic is null)
)
Many thanks Jan n Blue Shadow

Frank Kulash

Hi, [Muhammad Masoom Ansari](/ords/forums/user/Muhammad Masoom Ansari)
Here's another way to write the WHERE clause, that's a little more concise:

WHERE  :p_cnis IS NULL
OR     :p_cnis = NVL2 (emp_cnis, 'YES', 'NO')

I tried with decode function but I think it don't support the "not null"
Right. DECODE must return a value in one of the SQL data types, such as VARCHAR2 or NUMBER. That means, the 3rd, 5th, ... arguments must all be expressions that result in the same kind of SQL data type. But
emp_cnis is not null
is a BOOLEAN expression, and there is no BOOLEAN data type in SQL.

Jan Gorkow

Hi Muhammad,
be aware that your "... all records should be viewed" requirement is not met by your query.
Best regards
Jan

User_H3J7U

@frank-kulash
a little more concise
lnnvl(:p_cnis = NVL2 (emp_cnis, 'NO', 'YES'))

Hi @Jan Gorkow
Thank you very much for pointing out, now its fine.
select emp_id,emp_name,emp_cnic
from employee_view a
where a.emp_id in ( select distinct emp_id from hml_emp_attend_register where month_id = :p_month )
and ( (:p_cnic = 'YES' and emp_cnic is not null) or
( :p_cnic = 'NO' and emp_cnic is null)
or (:p_cnic is null and (emp_cnic is not null or emp_cnic is null))
)

Frank Kulash

Hi, [Muhammad Masoom Ansari](/ords/forums/user/Muhammad Masoom Ansari)
There's no point in saying
 or  (:p_cnic is null and (emp_cnic is not null or emp_cnic is null))  
Simply say

 or  (:p_cnic is null)  

instead.

Hi @frank-kulash
Yes, correct working suggested by you.
Thank you.

1 - 10
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 22 2014
Added on Aug 25 2014
2 comments
1,054 views