Thursday, August 9, 2018

How To Create Oracle ORDS REST webservice - APEX PLSQL

How To Create Oracle ORDS REST webservice - APEX PLSQL


  • Schema: EMPLOYEE
  • Module: restws
  • Template: transfer
Handler: POST


Enable ORDS Schema

BEGIN
ORDS.ENABLE_SCHEMA(
     p_enabled             => TRUE,
     p_schema              => 'EMPLOYEE',
     p_url_mapping_type    => 'BASE_PATH',
     p_url_mapping_pattern => 'restws',
     p_auto_rest_auth      => FALSE);
END;

/


Create ORDs Module

BEGIN
ORDS.DEFINE_MODULE(
     p_module_name    => 'emp.v1',
     p_base_path      => '/emp.v1/',
     p_items_per_page =>  25,
     p_status         => 'PUBLISHED',
     p_comments       => NULL);
END;
/

Create ORDS Templates


BEGIN
ORDS.DEFINE_TEMPLATE(
     p_module_name    => 'emp.v1',
     p_pattern        => ‘create’,
     p_priority       => 0,
     p_etag_type      => 'HASH',
     p_etag_query     => NULL,
     p_comments       => NULL);

END;



Create ORDS Handler

BEGIN
 ORDS.DEFINE_HANDLER(
     p_module_name    => 'emp.v1',
     p_pattern        => 'update',
     p_method         => 'POST',
     p_source_type    => 'plsql/block',
     p_items_per_page =>  0,
     p_mimes_allowed  => '',
     p_comments       => NULL,
     p_source         =>
'BEGIN
  
- call any plsql package or do insert/update .....
status := 'OK';

END;'
END;

/

Add Response Params
BEGIN
ORDS.DEFINE_PARAMETER(
  p_module_name        => 'asset.track.v1',
     p_pattern            => 'transfer',
     p_method             => 'POST',
     p_name               => 'X-APEX-STATUS-CODE', -- or any Name
     p_bind_variable_name => 'status',
     p_source_type        => 'RESPONSE',
     p_param_type         => 'INT',
     p_access_method      => 'OUT',
     p_comments           => NULL);

END;/





Wednesday, August 8, 2018

X-APEX-STATUS-CODE Rest response in PLSQL

X-APEX-STATUS-CODE Rest response in PLSQL



BEGIN
ORDS.DEFINE_PARAMETER(
  p_module_name        => 'assetws',
     p_pattern            => 'transfer',
     p_method             => 'POST',
     p_name               => 'X-APEX-STATUS-CODE',
     p_bind_variable_name => 'status',
     p_source_type        => 'RESPONSE',
     p_param_type         => 'INT',
     p_access_method      => 'OUT',
     p_comments           => NULL);
 ORDS.DEFINE_PARAMETER(
     p_module_name        => 'assetws',
     p_pattern            => 'transfer',
     p_method             => 'POST',
     p_name               => 'alert',
     p_bind_variable_name => 'alert',
     p_source_type        => 'HEADER',
     p_param_type         => 'STRING',
     p_access_method      => 'IN',
     p_comments           => NULL);

END;

Maven update project dependencies


Maven update project dependencies


mvn dependency:resolve
Or  single dependency:
mvn dependency:get -Dartifact=groupId:artifactId:version


mvn clean install -U
-U means force update of dependencies.

Monday, August 6, 2018

can not create Oracle user ORA-65096: invalid common user or role name in oracle

ORA-65096: invalid common user or role name in oracle

can not create Oracle user 

Fix
alter session set "_oracle_script"=true;

How to Stop firewall in Linux, Oracle Linux

How to Stop firewall in Linux, Oracle Linux

Oracle Linux 7, Redhat 7

service firewalld stop
systemctl disable firewalld

Oracle linux 7, Redhat 6

chkconfig iptables off

Monday, July 30, 2018

Oracle APEX info message and error message from PL/SQL

Oracle APEX info message and error message from PL/SQL

Info message
pex_application.g_print_success_message := '<span style="color:green">'|| result ||'</span>';


Error message

DECLARE
 sMsg VARCHAR2(40) := 'aaa';
BEGIN
  apex_error.add_error (
    p_message          => sMsg,
    p_display_location => apex_error.c_inline_in_notification );
END;

Friday, July 27, 2018

Banner 9: Validate NULL for textbox



Banner 9: Validate NULL for textbox


In Form controller


@ActionTrigger(action="VALIDATE_NULL")
public void Ftmvend_ValidateNull()
{


FtvvendAdapter ftvvendElement = (FtvvendAdapter)this.getFormModel().getFtvvend().getRowAdapter(true);
if (ftvvendElement==null)
return;

if ( !ftvvendElement.getFtvvendTaxFormStatus().isNull() && ftvvendElement.getFtvvendTaxFormDate().isNull() )
{
errorMessage(GNls.Fget(toStr("DDD-0037"), toStr("FORM"), toStr("A status date must be entered for the related Tax Form Status.")));
goItem(toStr("FTVVEND_TAX_FORM_DATE"));
throw new ApplicationException();
}

}


In Block controller


@ActionTrigger(action="KEY-COMMIT", function=KeyFunction.SAVE)
public void ftvvend_Save()
{


FtvvendAdapter ftvvendElement = (FtvvendAdapter)this.getFormModel().getFtvvend().getRowAdapter(true);
if (ftvvendElement==null)
return;

executeAction("VALIDATE_NULL");
getTask().getGoqrpls().gCheckFailure();

commitTask();
getTask().getGoqrpls().gCheckFailure();
getTask().getGoqrpls().gCheckStatusQuery();
}

AWS how to delete VPC when it has error with Network interface , Gateway decencies

   how to delete VPC when it has error with Network interface , Gateway decencies  in AWS 1. Check if it is running on EC2 instance then Sto...