Thursday, July 31, 2025

How to Create shell script to Start Database and Checking Table Space

 #dr_check_db_ERPGF.sh

#!/bin/bash


#run ./dr_check_db_ERPGF.sh | tee dr_ERPGF.out


echo -e "\n"

echo -e "+++++ Start Check Database Oracle EBS (ERP-GF) Date $(date +"%Y-%m-%d %H:%M:%S") +++++\n"

echo -e "\n"

echo "============================================================="

echo "== Process : Start Service (If Not Auto Start) "

echo "============================================================="



# Start the database

sqlplus / as sysdba << EOF

startup;

exit;

EOF


# Start the listener (optional, but recommended if not already running)

lsnrctl start sso1cdb

#wait


echo -e "\n"

echo -e "\n"

echo -e "**Command lsnrctl status \n"


lsnrctl status sso1cdb


echo -e "\n"

echo -e "\n"

echo -e "**Command netstat -nat | grep 1521\n"


netstat -nat | grep 1551 | grep ESTABLISHED 


cd /u03/ORCL/db/19.0.0

. ./ORCL_erpapp.env



# Oracle connection details (replace with your actual values)

DB_USER="apps"

DB_PASSWORD="apps" # Consider using environment variables or secure methods for passwords

ORACLE_SID="ORCL" # e.g., ORCL, XE



# Query the database name from V$DATABASE

HOST_NAME=$(sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}" <<EOF

SET PAGESIZE 0 FEEDBACK OFF HEADING OFF VERIFY OFF

SELECT HOST_NAME FROM V\$INSTANCE;

EXIT;

EOF

)


DB_NAME=$(sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}" <<EOF

SET PAGESIZE 0 FEEDBACK OFF HEADING OFF VERIFY OFF

SELECT NAME FROM V\$DATABASE;

EXIT;

EOF

)


echo -e "\n"

echo -e "\n"

echo -e "\n"

echo "Host Name: $HOST_NAME"

echo -e "Oracle Database Name: $DB_NAME\n"

echo -e "\n"

echo "============================================================="

echo "== Process : Check Database & Service Status "

echo -e "=============================================================\n"




DB_STATUS=$(echo "SET LINESIZE 1000;

column INSTANCE_NAME FORMAT A15;

column HOST_NAME FORMAT A20;

column STARTUP_TIME FORMAT A20;

SELECT INSTANCE_NAME, HOST_NAME, VERSION, STARTUP_TIME, STATUS, DATABASE_STATUS, EDITION FROM V\$INSTANCE;" | sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}")


echo "$DB_STATUS"



# Check if sqlplus is available

if ! command -v sqlplus &> /dev/null 

then

echo "Error: sqlplus command not found. Ensure Oracle client is installed and configured in PATH."

exit 1

fi


echo -e "\n"

echo "============================================================="

echo "== Process : Tablespace Status "

echo -e "=============================================================\n"

echo "***** Table Space Status at $(date +"%Y-%m-%d %H:%M:%S") *****"

echo -e "**Command : select tablespace_name, status from dba_tablespaces order by tablespace_name \n"


TBS_STATUS=$(echo "select tablespace_name, status from dba_tablespaces order by tablespace_name;" | sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}")


TBD_STATUS=$(echo "SET LINESIZE 1000;

column TableSpaceName FORMAT A20;

select a.TABLESPACE_NAME "TableSpaceName",

round(a.BYTES / 1024 / 1024) "MBAllocated",

round((a.BYTES-nvl(b.BYTES, 0)) / 1024 / 1024) "MBUsed",

nvl(round(b.BYTES / 1024 / 1024), 0) "MBFree",

round(((a.BYTES-nvl(b.BYTES, 0))/a.BYTES)*100,2) "PctUsed",

round((1-((a.BYTES-nvl(b.BYTES,0))/a.BYTES))*100,2) "PctFee"

from   (select   TABLESPACE_NAME, sum(BYTES) BYTES

from     sys.dba_data_files

group by TABLESPACE_NAME) a,

(select   TABLESPACE_NAME, sum(BYTES) BYTES

from     sys.dba_free_space

group by TABLESPACE_NAME) b

where  a.TABLESPACE_NAME = b.TABLESPACE_NAME (+)

order  by ((a.BYTES-b.BYTES)/a.BYTES) desc;" | sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}")


TBS_COUNT=$(echo "@$HOME/CountTB.sql" | sqlplus -S "${DB_USER}/${DB_PASSWORD}@${ORACLE_SID}")



# Check if the query returned a database name

if [ -z "$DB_NAME" ]; then

echo "Error: Could not retrieve Oracle database name. Check connection details and database status."

else

echo "$TBS_STATUS"

echo -e "$TBD_STATUS\n"

echo -e "\n"

echo "$TBS_COUNT"

fi


# Start the database

#sqlplus apps/apps@ORCL << EOF

#@$ORACLE_HOME\CountTB.sql

#exit;

#EOF


How to Fix Toad 12.8.0.49

 How to Fix Toad 12.8.0.49

Error ORA-00904: "REF": invalid Identifier




How to Fix

1.click edit/view script option

2.click up check Audit Statements 




it work.

enjoy.

Tuesday, April 30, 2024

Register รายงาน Oracle Report บน Oracle E-Business

 

Register รายงาน Oracle Report บน Oracle E-Business

Copy .rdf into folder in Module on application server

การสร้าง Executable Program และผูกกับ Executable: Oracle Report

Nav.System Administrator -> Concurrent -> Program -> Executable


Nav.System Administrator -> Concurrent -> Program -> Define


Set Parameter


Nav.System Administrator -> Security -> Responsibility -> Request (Set Call Report to Module)












Register รายงาน Oracle Form บน Oracle E-Business

 Register รายงาน Oracle Form บน Oracle E-Business

การลงทะเบียน Form

Select Application Developer-> Application -> Form


Application Developer-> Application -> Function


 Application Developer-> Application -> Menu


ตัวอย่างเมนู PO Purchasing





Monday, July 10, 2023

 วิธีการ เชื่อมต่อ BOT Webservice Bank of Thailand

  1. ลงทะเบียน จากเว็ป Bank of Thailand





ทำการ Log in จากที่ท่านได้ลงทะเบียนมาและทำการเทส จากหน้าเว็ปของทาง ธนาคารแห่งประเทศไทย


  1. ทำ Log in เพื่อสร้าง App เพื่อสร้าง Client Id and Secret

 


ทำการระบุ Title อะไรก็ได้ ในตัวอย่างระบุ ExCur ที่ Title และสร้างระบุ Description ในการอธิบาย ระบุเสร็จทำการ คลิ๊กเลือกไปที่ App ที่ทำการสร้าง ในที่นี้เป็น ExCur


นำไประบุใน ส่วนของ Post man ในส่วน Header


ทำการ Sub Scrit Application


ทำการเลือกฟังค์ชั่น Webservice ที่ต้องการทดสอบและทำการ ทดสอบ โดยการระบุ parameter ที่มีดวงจันและ กด Call opration เพื่อดู ผลการรัน

 

ระบบจะแสดง ว่าทำสำเร็จหรือว่า Error จาก Response ได้ 200 success ถือว่าผ่านการทดสอบ

 

  1. ทำการ สร้าง Post Man เพื่อทำการทดสอบ

https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/?start_period=2020-03-09&end_period=2020-03-10

Key accept                       VALUE   application/json

Key X-IBM-Client-Id         VALUE   0f2282xxxxxxxxxxxxxxxxxxxxxxxxxxxxx





ทำการระบุ Parameter ตามตัวอย่างและทำการ ทดสอบ รัน โดยการกดปุ่ม Send

ถ้าทำการส่งผ่าน ผลลัพธ์ที่ได้จะ ได้ 200 OK ถือว่า สำเร็จ







Wednesday, March 3, 2021

How to check concurrent list all in oracle EBS

select concurrent_program_id, program_application_id, printer,

        program_short_name, argument_text, print_style,

        user_print_style, save_output_flag, row_id,

        actual_completion_date, completion_text, parent_request_id,

        request_type, fcp_printer, fcp_print_style, fcp_required_style,

        last_update_date, last_updated_by, requested_by,

        has_sub_request, is_sub_request, update_protected,

        queue_method_code, responsibility_application_id, responsibility_id,

        controlling_manager, last_update_login, priority_request_id,

        enabled, requested_start_date, phase_code,

        hold_flag, status_code, request_id,

        program, requestor, priority

from fnd_conc_req_summary_v

where 1=1

    and phase_code = 'P' 

    and status_code in ('I', 'Q') 

    and ((decode(implicit_code, 'N', status_code,'E', 'E', 'W', 'G') = status_code or decode(implicit_code, 'W', 'E') = status_code))

order by request_id desc-- check Concurrent All

select concurrent_program_id, program_application_id, printer,

        program_short_name, argument_text, print_style,

        user_print_style, save_output_flag, row_id,

        actual_completion_date, completion_text, parent_request_id,

        request_type, fcp_printer, fcp_print_style, fcp_required_style,

        last_update_date, last_updated_by, requested_by,

        has_sub_request, is_sub_request, update_protected,

        queue_method_code, responsibility_application_id, responsibility_id,

        controlling_manager, last_update_login, priority_request_id,

        enabled, requested_start_date, phase_code,

        hold_flag, status_code, request_id,

        program, requestor, priority

from fnd_conc_req_summary_v

where 1=1

    and phase_code = 'P' 

    and status_code in ('I', 'Q') 

    and ((decode(implicit_code, 'N', status_code,'E', 'E', 'W', 'G') = status_code or decode(implicit_code, 'W', 'E') = status_code))

order by request_id desc

How to set Default OU oracle EBS in tools Query data

Set Default OU

--after run alter seesion

alter session set nls_language = american


--and next run script

BEGIN

        mo_global.set_policy_context('S', 94); -- 94 is ID in Operation_unit 

END;


Select test data show by OU, Enjoy

How to Create shell script to Start Database and Checking Table Space

 #dr_check_db_ERPGF.sh #!/bin/bash #run ./dr_check_db_ERPGF.sh | tee dr_ERPGF.out echo -e "\n" echo -e "+++++ Start Check Dat...