20220601 - APEX JSON을 활용한 AJAX Return

1. PL/SQL with cursor


DECLARE
  l_cursor SYS_REFCURSOR;
BEGIN
  OPEN l_cursor FOR
    select po_mst.cust_nm
         , po_mst.cust_addr
         , po_mst.delivery_req
         , po_mst.memo
      from po_mst
     where rownum <= 2;

  APEX_JSON.initialize_clob_output;
  APEX_JSON.open_object;
  APEX_JSON.write('targetlist', l_cursor);
  APEX_JSON.close_object;
  DBMS_OUTPUT.put_line(APEX_JSON.get_clob_output);

  APEX_JSON.free_output;
END;


2. 결과

{
"targetlist":[
{
"CUST_NM":"OOOO"
,"CUST_ADDR":"주소는 XXXX"
,"DELIVERY_REQ":"감사합니다"
}
,{
"CUST_NM":"OOO"
,"CUST_ADDR":"주소는 OOOOO"
,"DELIVERY_REQ":"네. 감사합니다."
}
]
}



참고

https://oracle-base.com/articles/misc/apex_json-package-generate-and-parse-json-documents-in-oracle


20220601 - 스피너 spinner 보이기/감추기

1. dynamic action for JavaScript

  //execute spinner

  var spinner = apex.util.showSpinner();


2. dynamic action for plsql code

  your plsql code

    

3. dynamic action for JavaScript

  //remove spinner

  $("#apex_wait_overlay").remove();

  $(".u-Processing").remove();



참고

https://parthiban037.wordpress.com/2020/01/03/show-spinner-in-oracle-apex-dynamic-action/

20220524 - IG 항목 column 화면에는 안 보이고 다운로드할 때만 보이도록

1. 기본 설정은 다른 항목과 동일하게

Identification - Type : Text Field

Heading : 우편번호

Export / Printing - Include In Export / Print : YES


2. Server-side Condition

Type : Function body

Language : PL/SQL

PL/SQL Function Body : 

RETURN NVL(:REQUEST,'EMPTY') NOT IN ('CSV','XLS','RTF','HTMLD');


이렇게 하면 다운로드 할 때만 해당 항목이 나타납니다.



참고

https://doyensys.com/blogs/include-or-exclude-column-in-apex-interactive-report-download/

https://www.talkapex.com/2010/06/how-to-only-display-column-when/


20220510 - IG 컬럼 숫자 포맷 0을 공란 blank 로 구현

몇 가지 방법이 있을 수 있겠으나 여기에서는 두 가지 방법을 안내합니다.


1. 포맷 마스크 사용

Identification - Type : Number
Appearance - Format Mask : FMB999G999G999G999G999G999G999



2. SQL에서 포맷팅하여 HTML로 표현

, decode(delivery_fee_pre, 0, '<span></span>', '<span class="css-red">'||to_char(delivery_fee_pre,'999,999,999,999')||'</span>') delivery_fee_pre_css
, decode(delivery_fee,     0, '<span></span>', '<span>'||to_char(delivery_fee,'999,999,999,999')||'</span>')                     delivery_fee_css







참고
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Format-Models.html#GUID-096CA64F-1DA3-4C49-A18B-ECC7518EE56C

20220425 - 읽기 전용 항목 Display Only Item 에 정렬, 진하게 CSS 적용

페이지 아이템 Type을 Display Only 로 지정하게 되면 문자든 숫자든 기존에 설정한 정렬 값들은 무시되고 점선 박스에 좌측 정렬로 변경이 됨.

Theme에서 제공하는 스타일을 적용하여 우측, 진하게, 밑줄강조를 할 수 있음


1. Layout - Column CSS Classes : u-bold

2. Advanced - CSS Classes : u-textEnd u-bold u-underline



그 외 여러가지 Theme에서 제공하는 것들 활용 가능

u-color-1

u-color-1-text

u-color-1-bg

u-color-1-border


  • 페이지를 submit(refresh) 해야하는 상황이 발생을 했는데 display only 항목을 변경해서 세션 상태 보호 위반으로 apex.submit(); 을 처리하지 못함, 하여 Display Only 항목을 아래와 같이 변경하면 submit 처리 시 에러가 발생하지 않음

Identification - Type : Text Field

Settings - Disabled : Yes

Send On Page Submit : No







참고

https://apex.oracle.com/pls/apex/r/apex_pm/ut/content-modifiers

https://apex.oracle.com/pls/apex/r/apex_pm/ut/color-and-status-modifiers


20220419 - 카카오 지도 API 사용하기

1. API KEY 받기 (https://apis.map.kakao.com/web/guide/)

1일 300,000회 무료로 사용 가능하므로 개인이나 소규모 비지니스처럼 대량으로 API 호출이 일어나지 않는 경우는 무료라고 봐도 무방하겠습니다.





- 등록한 도메인에서의 호출만 가능하므로 도메인 확인 후 등록

- JavaScript 키 사용




2. 예제 코드로 생성 - 여러개 마커 제어하기

코드 부분 복사, Static 리전 생성 후 붙여넣기




HTML 내부의 버튼 대신(코드 삭제) 별도 버튼 생성 후 이벤트 실행


<p>
    <button onclick="hideMarkers()">마커 감추기</button>
    <button onclick="showMarkers()">마커 보이기</button>
</p>




결과 화면




참고

https://apis.map.kakao.com/

https://apis.map.kakao.com/web/guide/

https://apis.map.kakao.com/web/sample/

https://juahnpop.tistory.com/254

20220413 - 나만의 도메인과 NGINX 웹 서버로 APEX 서비스 접속하기

사전 준비 : 도메인과 공용 IP 그리고 프록시 컴퓨트 인스턴스

(OS 이미지는 Oracle-Linux-7.9-aarch64-2021.10.20-0 사용)


1. root 사용자로 전환하여 최신 패키지들로 업데이트


sudo su -
yum update -y
yum install -y yum-utils



2. nginx repository 설정 후 설치


vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

yum install -y nginx


3. nginx 설치 후 상태 확인 및 서비스 시작


ps -ef | grep nginx
systemctl start nginx
systemctl status nginx
systemctl enable nginx
ps -ef | grep nginx



4. http, https 서비스를 위한 방화벽 오픈


firewall-cmd --permanent --list-all --zone=public
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
firewall-cmd --permanent --list-all --zone=public



5. 해당 도메인 웹 서비스에 대한 설정


vi /etc/nginx/conf.d/oraclecloudapex.com.conf
server {
    listen         80;
    listen         [::]:80;
    server_name    oraclecloudapex.com www.oraclecloudapex.com;
    root           /usr/share/nginx/html/oraclecloudapex.com;
    index          index.html;
    try_files $uri /index.html;
}



6. 웹 서비스 기본 페이지 생성


mkdir /usr/share/nginx/html/oraclecloudapex.com
vi /usr/share/nginx/html/oraclecloudapex.com/index.html
Hello!!

nginx -s reload
nginx -t



7. (무료) SSL 인증 발급을 위한 패키지 설치 및 SSL 인증서 발급


cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
ls *.rpm
yum install -y epel-release-latest-7.noarch.rpm
yum install -y certbot python2-certbot-nginx

certbot --nginx -d oraclecloudapex.com -d www.oraclecloudapex.com --register-unsafely-without-email





8. 해당 웹 서비스 설정 파일에 APEX 서비스 고유 URL redirection 추가


vi /etc/nginx/conf.d/oraclecloudapex.com.conf
/* Adding ================>>> */
  location / {
    rewrite ^/$ /ords/f?p=xxxxx:xxxx redirect;
  }

  location /ords/ {
    proxy_pass https://yourapexserviceurl.com/ords/;
    proxy_set_header Origin "" ;
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
  }

  location /i/ {
    proxy_pass https://yourapexserviceurl.com/i/;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }



서비스 다시 로드


nginx -s reload
nginx -t



참고

테스트를 위해 최신 OL8 에 설치한 후 Gateway 에러 때문에 이틀을 맘고생 했네요.

Oracle-Linux-8.5-aarch64-2022.03.17-1

결국에는 강화된 보안 때문이었음.


vi /etc/selinux/config
SELINUX=disabled


==============

(Oracle Linux8) 7. (무료) SSL 인증 발급을 위한 패키지 설치 및 SSL 인증서 발급


cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
ls *.rpm
yum install -y epel-release-latest-8.noarch.rpm
yum install -y certbot python3-certbot-nginx

certbot --nginx -d oraclecloudapex.com -d www.oraclecloudapex.com --register-unsafely-without-email


Saving debug log to /var/log/letsencrypt/letsencrypt.log

Requesting a certificate for oraclecloudapex.com and www.oraclecloudapex.com


Successfully received certificate.

Certificate is saved at: /etc/letsencrypt/live/oraclecloudapex.com/fullchain.pem

Key is saved at:         /etc/letsencrypt/live/oraclecloudapex.com/privkey.pem

This certificate expires on 2023-12-25.

These files will be updated when the certificate renews.

Certbot has set up a scheduled task to automatically renew this certificate in the background.


Deploying certificate

Successfully deployed certificate for oraclecloudapex.com to /etc/nginx/conf.d/oraclecloudapex.com.conf

Successfully deployed certificate for www.oraclecloudapex.com to /etc/nginx/conf.d/oraclecloudapex.com.conf

Congratulations! You have successfully enabled HTTPS on https://oraclecloudapex.com and https://www.oraclecloudapex.com


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

If you like Certbot, please consider supporting our work by:

 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate

 * Donating to EFF:                    https://eff.org/donate-le

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




20250315 - 글로벌 변수 Global Variables

G_USER Specifies the currently logged in user. G_FLOW_ID Specifies the ID of the currently running application. G_FLOW_STEP_ID Specifi...