Friday, December 16, 2011

Oracle Apex - Auditing


بسم الله الرحمن الرحيم , الحمد لله و الصلاة و السلام على رسول الله

تعديل الجدول

ALTER TABLE demo_products ADD ( last_updated_by varchar2 (35), last_updated_on timestamp (4) with local time zone )

إنشاء القادح

CREATE OR REPLACE TRIGGER  "BI_product_info"
BEFORE INSERT OR UPDATE ON demo_product_info
FOR EACH ROW
BEGIN
  IF (inserting) THEN
    BEGIN
      :new.Last_updated_by := nvl(v('APP_USER'), 'user');
      :new.last_updated_on := systimestamp;
    END;
  ELSIF (updating) THEN
    BEGIN
      :NEW.Last_updated_by := nvl(v('APP_USER'), 'user');
      :NEW.last_updated_on := systimestamp;
   END;
  END IF;
END;


** Attributes
Region Attributes:   style=width:300px

** HTML Table Cell Attributes
style="color:#800517; font-weight: bold"

*** Do not forget to disable the tigger if you are going to upload data to your table:

ALTER TRIGGER bi_products DISABLE



APP_USER Syntax

Reference Type Syntax

  • Bind variable

:APP_USER

  • PL/SQL

V('APP_USER')

  • Substitution string

&APP_USER.

Consider the following examples:

From within an HTML region:Hello you are logged in as &APP_USER.
Using PL/SQL:

htp.p('Hello you are logged in as'||V('APP_USER'));
As a bind variable:

SELECT * FROM some_table WHERE user_id = :APP_USER


Sunday, October 9, 2011

Some Security Skills بعض النقاط حول الأمان


السلام عليكم و رحمة الله وبركاته, الحمد لله و الصلاة و السلام على رسول الله.
 اليوم إن شاء الله سنتكلم منح الصلاحيات للمتسخدمين لمشاهدة بيانات معينة::

  • تحديد البيانات المتاحة لكل مستخدم. فكل مستخدم يستطيع فقط أن يرى البيانات الخاصة به.
  • عرض بعض الأعمدة  و اخفاء البقية عن المستخدمين  الذين لا يملكون صلاحيات
  •  اخفاء  الحقول خلال فترة زمنية معينة أو جعل التطبيق متاح خلال ساعات معينة
  • جعل بعض الحقول للقراءة فقط بحيث لا يكمن تعديلها
-------------------------

1-
Select * from TABLE_NAME where upper (USER_NAME ) =  UPPER (:APP_USER) order by 1 desc 

إذا كنت أود أن أعطي صلاحيات لمستخدم اسمه اوراكل لكي يرى جيمع الصفوف

Select * from TABLE_NAME where upper (USER_NAME ) =  UPPER (:APP_USER) OR upper ( :APP_USER) = 'ORACLE' order by 1 desc 
-------------------------------------------

2-
click on edit page then Report Columns, ( Report Attributes tab). then go to Conditions.
SELECT * FROM DUAL WHERE upper (:app_user) not like 'ZIAD'
--------------------------------------------------
3-
click on edit item. then go to conditions.

TO_CHAR (SYSDATE, 'HH24') NOT BETWEEN '20' AND '23'

-----------------------------------------------------
يتبع إن شاء الله تعالى ....
4- We need to create Dynamic Action. (Show/Hide)

Go to Conditions. 
choose PL/SQL as Condition Type
 upper(:app_user) in ('X','Y','Z','F') and  :P2_empid is not null
في العادة نستخدم
:P2_ID
و في الاصدار الأخير من
APEX
نستخدم
:P2_RowID


الحمد لله و الصلاة و السلام على رسول الله

Sunday, September 25, 2011

تأسيس الاتصال

بسم الله و الحمدلله و الصلاة والسلام على رسول الله:

لتأسيس  الاتصال بين السيرفر و بقية الحواسيب نحتاج إلى التالي :






--------------

Listener Configuration:
C:\Program Files\Java\jre6\bin\java -Dapex.erase -Dapex.port=3142 -Dapex.home=C:\Connection -Dapex.images=C:\apex\images -jar C:\Connection\apex.war
--------------
Start up file:
"C:\Program Files\Java\jre6\bin\java" -Dapex.erase -Dapex.port=3142 -Dapex.home=C:\Connection -Dapex.images=C:\apex\images -jar C:\Connection\apex.war  >>C:\Connection\my_apex_listener.log 2>&1
--------------
Unlock APEX_PUBLIC_USER:

CONNECT TO SQLPLUS as sysdba
then type:
alter user apex_public_user account unlock
alter user apex_public_user identified by oracle
--------------
Change HTTP Port:
أولا تأكد من رقم البورت


select dbms_xdb.gethttpport as "HTTP-Port"
            , dbms_xdb.getftpport as "FTP-Port" from dual;
لتغير رقم البورت 

 
begin
   dbms_xdb.sethttpport('هنا ضع رقم البورت الذي تريد');
   dbms_xdb.setftpport('هنا ضع رقم البورت الذي تريد');
  end;

 3142 إذا كنت ترغب في تغير رقم البورت المستخدم للاتصال بالسيرفر, فعليك تغير الرقم  
في 
Startup file and listener configuration 


الحمدلله و الصلاة والسلام على رسول الله.
السلام عليكم و رحمة الله وبركاته


Tuesday, September 6, 2011

تصدير تطبيق 2 , إنشاء أغراض قواعد البيانات




بسم الله و الحمد لله و الصلاة و السلام عل رسول الله
السلام عليكم و رحمة الله و بركاته,  من أجل أن تكون الأمور واضحة سنقوم في هذه المحاضرة بإنشاء :
Tables , Sequences, Triggers.
و سنرى إن شاء الله تعالى كيفك يتم توليد الكود لهذه الأغراض . أقصد
Generate DDL : Data Dentition Language 
على أي حال حفاظأ على قتك . ربما تستطيع مشاهدة هذه المحاضرة و أنت تتناول الغداء فهي لا تحتاج إلى تركيز...  إلا إذا كنت مبتدأ
علما أنني عمدا قمت بإنشاء الجداول أولا ثم إضافة القيود .....
ثم في المحاضرة التالية سنبيني التطبيق بالاعتماد على هذه الأغراض:  إن شاء الله تعالى


إنشاء جداول الموظفين و الأقسام:

CREATE TABLE  EMP2
   (
EMPNO NUMBER(4,0) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4,0),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2,0)
);
-------

CREATE TABLE  DEPT2
(
DEPTNO NUMBER(2,0),
DNAME VARCHAR2(14),
LOC VARCHAR2(13)
        );
-------------------------------------------------
إنشاء القيود

alter table emp2 add constraint PK_emp2 primary key (EMPNO);

-------



alter table dept2 add constraint PK_dept2 primary key (deptno);
-------



alter table emp2 add constraint FK_emp2 foreign key (DEPTNO) references DEPT2 (DEPTNO);

-------------------------------------------------


إنشاء المتسلسلات Sequences

create sequence emp2_seq;


-------



create sequence dept2_seq;

-------------------------------------------------
إنشاء القوادح Triggers



create or replace trigger BI_emp2
before insert on emp2
for each row
begin
if :new.empno is null then
select emp_seq2.nextval into :new.empno from dual;
end if;
end;

-------

alter trigger bi_emp enable;


-------

create or replace trigger BI_dept2


before insert on dept2
for each row
begin
if :new.DEPTNO is null then
select dept2_seq.nextval into :new.DEPTNO from dual;
end if;
end;

-------

alter trigger BI_dept2 enable;



-------------------------------------------------



إدخال البيانات: Inserting The Data

INSERT INTO EMP2 VALUES
(7369,'SMITH','CLERK',7902,to_date('17-12-1980','dd-mm-yyyy'),800,NULL,20);
INSERT INTO EMP2 VALUES
(7499,'ALLEN','SALESMAN',7698,to_date('20-2-1981','dd-mm-yyyy'),1600,300,30);
INSERT INTO EMP2 VALUES
(7521,'WARD','SALESMAN',7698,to_date('22-2-1981','dd-mm-yyyy'),1250,500,30);
INSERT INTO EMP2 VALUES
(7566,'JONES','MANAGER',7839,to_date('2-4-1981','dd-mm-yyyy'),2975,NULL,20);
INSERT INTO EMP2 VALUES
(7654,'MARTIN','SALESMAN',7698,to_date('28-9-1981','dd-mm-yyyy'),1250,1400,30);
INSERT INTO EMP2 VALUES
(7698,'BLAKE','MANAGER',7839,to_date('1-5-1981','dd-mm-yyyy'),2850,NULL,30);
INSERT INTO EMP2 VALUES
(7782,'CLARK','MANAGER',7839,to_date('9-6-1981','dd-mm-yyyy'),2450,NULL,10);
INSERT INTO EMP2 VALUES
(7788,'SCOTT','ANALYST',7566,to_date('13-JUL-87')-85,3000,NULL,20);
INSERT INTO EMP2 VALUES
(7839,'KING','PRESIDENT',NULL,to_date('17-11-1981','dd-mm-yyyy'),5000,NULL,10);
INSERT INTO EMP2 VALUES
(7844,'TURNER','SALESMAN',7698,to_date('8-9-1981','dd-mm-yyyy'),1500,0,30);
INSERT INTO EMP2 VALUES
(7876,'ADAMS','CLERK',7788,to_date('13-JUL-87')-51,1100,NULL,20);
INSERT INTO EMP2 VALUES
(7900,'JAMES','CLERK',7698,to_date('3-12-1981','dd-mm-yyyy'),950,NULL,30);
INSERT INTO EMP2 VALUES
(7902,'FORD','ANALYST',7566,to_date('3-12-1981','dd-mm-yyyy'),3000,NULL,20);
INSERT INTO EMP2 VALUES
(7934,'MILLER','CLERK',7782,to_date('23-1-1982','dd-mm-yyyy'),1300,NULL,10);



-------



INSERT INTO DEPT2 VALUES
(10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT2 VALUES
                 (20,'RESEARCH','DALLAS');
INSERT INTO DEPT2 VALUES
(30,'SALES','CHICAGO');
INSERT INTO DEPT2 VALUES
(40,'OPERATIONS','BOSTON');




I hope that has been informative for you. Please do not hesitate to pose any question, and I will answer you as I have time بإذن الله تعالى







Saturday, September 3, 2011


Oracle Application Express


Upgrading Oracle Application Express within Oracle 


Database 10g Express Edition (XE)

Oracle Database 10 g Express Edition (Oracle XE) includes Oracle Application Express release 2.1. It is strongly recommended that you upgrade to the latest release of Oracle Application Express to take advantage of all the latest features.



How to Upgrade

To install the latest version of Oracle Application Express in your Oracle Database XE, first download the latest version of Application Express from the Oracle Technology Network.
1. Unzip the downloadloaded zip file:
  • Linux: Unzip <filename>.zip
  • Windows: Double click <filename>.zip in Windows Explorer
  • [Note: You should keep the directory tree where you unzip the files short and not under directories that contain spaces. 
    For example, within Windows unzip to C:\.]
2. Change your working directory to apex.
3. Start SQL*Plus and connect to the Oracle XE database:
  • Linux:
    $ sqlplus /nolog
    	SQL> CONNECT SYS as SYSDBA
    	Enter Password:	
    	SYS_Password
  • Windows:
    {Command prompt} C:\apex> sqlplus /nolog
    	SQL> CONNECT SYS as SYSDBA
    	Enter Password:	
    	SYS_Password
    		
  • [Note: You should keep the directory tree where you unzip the files short and not under directories that contain spaces. 
    For example, within Windows unzip to C:\.]
4. Install Application Express:
  • SQL> @apexins SYSAUX SYSAUX TEMP /i/
5. Log back into SQL*Plus (as above) and load images:
  • SQL> @apxldimg.sql APEX_HOME
  • [Note: APEX_HOME is the directory you specified when unzipping the file. For example, with Windows 'C:\'.]
6. Upgrade Application Express password:
  • SQL> @apxchpwd
    Enter password for Application Express ADMIN account.
7. In a Web browser, navigate to the Oracle Application Express Administration Services application:
  • http://localhost:8080/apex/apex_admin
  • In Username, enter ADMIN

Friday, February 4, 2011

Add A Banner To Your Application


 السلام عليكم  ورحمة الله تعالى وبركاته

أولا إذهب إلى هذا الرابط و حمل البانر

ثم تابع الفيديو



HTML Source:




<div id="container">
    <div id="example">

   <div id="slides">
    <div class="slides_container">
     <div class="slide">
      <a href="http://www.google.com" title="" target="_blank"><img src="https://lh5.googleusercontent.com/-9rrld1jf0GM/TygBxMIYZqI/AAAAAAAAAFM/1jrt46zOH5k/s640/IMG_1502.JPG" width="570" height="270" alt="Slide 1"></a>
      <div class="caption">
       <p></p>
      </div>
     </div>
   
     <div class="slide">
      <a href="" title="" target="_blank"><img src="https://lh4.googleusercontent.com/-vPABKgqr_eI/TygBxKvfGeI/AAAAAAAAAFI/6FoG0lB4hc4/s640/IMG_1504.JPG" width="570" height="270" alt="Slide 1"></a>
      <div class="caption">
       <p></p>
      </div>
     </div>
     <div class="slide">
      <a href="" title="" target="_blank"><img src="https://lh6.googleusercontent.com/-_xuU-00z5n4/TygBwuOr_gI/AAAAAAAAAFE/DD4y_GQ9XgI/s640/IMG_1514.JPG" width="570" height="270" alt="Slide 1"></a>
      <div class="caption">
       <p></p>
      </div>
     </div>
     <div class="slide">
      <a href="" title="" target="_blank"><img src="https://lh4.googleusercontent.com/-sspuQUgGykI/TygBzTMmAzI/AAAAAAAAAFc/dG1gaMJiIG8/s640/IMG_1515.JPG
" width="570" height="270" alt="Slide 1"></a>
      <div class="caption">
       <p></p>
      </div>
     </div>
   
     <div class="slide">
      <a href="" title="" target="_blank"><img src="https://lh5.googleusercontent.com/-YFL12-gL1t8/TygB0KSAszI/AAAAAAAAAFg/1CnCXteMTK4/s640/IMG_1519.JPG" width="570" height="270" alt="Slide 2"></a>
      <div class="caption">
       <p></p>
      </div>
     </div>
    </div>
    <a href="#" class="prev"><img src="#IMAGE_PREFIX#slider/arrow-prev.png" width="24" height="43" alt="Arrow Prev"></a>
    <a href="#" class="next"><img src="#IMAGE_PREFIX#slider/arrow-next.png" width="24" height="43" alt="Arrow Next"></a>
   </div>
   <img src="#IMAGE_PREFIX#slider/example-frame.png" width="740" height="341" alt="Example Frame" id="frame">

  </DIV>
 </div>




Java Script:



$(function(){
$('#slides').slides({
preload: true,
preloadImage: ' #IMAGE_PREFIX#slider/loading.gif',
play: 5000,
pause: 2500,
hoverPause: true,
animationStart: function(current){
$('.caption').animate({
bottom:-35
},100);
if (window.console && console.log) {
// example return of current slide number
console.log('animationStart on slide: ', current);
};
},
animationComplete: function(current){
$('.caption').animate({
bottom:0
},200);
if (window.console && console.log) {
// example return of current slide number
console.log('animationComplete on slide: ', current);
};
},
slidesLoaded: function() {
$('.caption').animate({
bottom:0
},200);
}
});
});