Friday, December 27, 2019

Oracle Apex Upload and Preview Image

Reference 1st : https://www.youtube.com/watch?v=XTao_pQALLg

code in post-text of "FILE BROWSER"  :

<canvas id="image-preview"      width="100" height="50" style="border:1px solid #000000;">

Dynamic Action  of "File Browser": CHANGE AND JAVA SCRIPT CODE :

try {
var canvus =$x('image-preview');
var ctx = canvus.getContext('2d');
var img = new Image;

img.src = window.URL.createObjectURL(this.triggeringElement.files[0]);
img.onload = function() {
 if (img.width > 200) {
   canvus.style.width = "100px";
 }
 canvus.width = img.width;
 canvus.height = img.height;
 ctx.drawImage(img,0,0);
 $("#container-img-preview").show();
}
} catch (e) {
console.log(e);
}

Monday, August 5, 2019

Oracle Apex Desktop Navigation Menu User wise Authentications


CREATE TABLE ALOGIN
(OPRTR    VARCHAR2(10),
 URIGHTS   CHAR(1)
);


INSERT INTO ALOGIN VALUES ('D00001','1');
INSERT INTO ALOGIN VALUES ('D00002','1');
INSERT INTO ALOGIN VALUES ('D00003','1');
INSERT INTO ALOGIN VALUES ('D00004','1');

COMMIT;

Go to : > Shared Components > Navigation Menu > Desktop Navigation Menu > Click <> menu >
Go to : Conditions > Condition Type > (SQL Query Returns at least one row.) >

Write the following code at :

SELECT sys_context('APEX$SESSION', 'APP_USER') FROM DUAL
WHERE sys_context('APEX$SESSION', 'APP_USER') IN
(SELECT UPPER(OPRTR) FROM ALOGIN WHERE UPPER(OPRTR)='D00004')
OR sys_context('APEX$SESSION', 'APP_USER')='LIERP';


Reference 1st :       https://www.youtube.com/watch?v=J83jSqDwxgk


Monday, July 29, 2019

Potential Blogs of Oracle Apex - Links.

  1. Md. Kamal Hossain - http://www.apexexplorer.com/
  2. http://deneskubicek.blogspot.com/
  3. All the Ground Breakers of Oracle Apex : https://apexapps.oracle.com/pls/apex/f?p=119297:3::::::
  4. Noorstech.com

Tuesday, July 16, 2019

Oracle Apex Forms Validation, Alert, Save and Update.


Oracle Apex Jasper Report Integration

unzip jri-2.7.0-jasper-6.16.0.zip  to :

D:\apex_20.1\JasperReportsIntegration

D:\apex_20.1\

mkdir jasper

copy D:\apex_20.1\JasperReportsIntegration to D:\apex_20.1\jasper

cd jasper

mkdir logs

D:\>cd apex_20.1

D:\apex_20.1>cd jasper

D:\apex_20.1\jasper>cd bin

Linux Permission :

chmod +x setConfigDir.sh 

Windows :

setConfigDir.cmd D:\apex_20.1\JasperReportsIntegration\webapp\jri.war D:\apex_20.1\jasper

Linux :

./setConfigDir.cmd D:\apex_20.1\JasperReportsIntegration\webapp\jri.war D:\apex_20.1\jasper   

Windows :

copy D:\apex_20.1\jasper\webapp\jri.war to C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\jri.war

Linux :

cp D:\apex_20.1\jasper\webapp\jri.war to C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\jri.war


Javascript :

var report_server = "http://localhost:8080/jri/report?";

var report_name = "dept";
var report_format = "pdf";
var data_source = "default";

var run_report=""+report_server+"&_repName="+report_name+"&_repFormat="+report_format+"&_dataSource="+data_source+"";

window.open(run_report);

Javascript with parameter :

var report_server = "http://localhost:8080/jri/report?";

var report_name = "dept_param";
var report_format = "pdf";
var data_source = "default";

var ap_1 = $v("P3_DEPT");
var rp_1 = "&P_DEPT";

var param = ""+rp_1+"="+ap_1+"";

var report=""+report_server+"&_repName="+report_name+"&_repFormat="+report_format+"&_dataSource="+data_source+"";

var run_report = ""+report+""+param+"";

window.open(run_report);

Sample Jasper Report files (with and without parameter) :


Potential Youtube channel to learn Jasper Report :

Previous Research:


Reference : http://www.opal-consulting.de/downloads/free_tools/JasperReportsIntegration/2.4.0/Index.html

Installation
Download the files
Installation in the J2EE server
Installation of database objects
Installation of the test application

1. Download the files
You can download the files from here and unzip them.

2. Installation in the J2EE server
We need to install the J2EE application and configure the data sources in this step. The J2EE application has to find various configuration files

(e.g. conf/application.properties,  conf/log4j.properties) and also the different reports that we can run (e.g. reports/test.jasper).

It is recommended practice to separate the configuration-/report files from the J2EE application itself. In the early versions of the

JasperReportsIntegration all reports were placed directly in the web application itself, for example into the directory

$TOMCAT_HOME/webapps/reports. In order to easily upgrade your installation in the future it is recommended to put the configuration and report files

into a separate directory and not store them inside of the J2EE application.

Nevertheless the J2EE application must be able to locate these files.

We have two options here:

Configure the server environment using an operating system environment variable

Configure the setting in the web.xml file of the JasperReportsIntegration.war file

The difference comes into play when you deploy the JasperReportsIntegration.war file multiple times on the same J2EE server or on different J2EE

servers on the same machine. When using the operating system environment variable, all instances of the JasperReportsIntegration will use the same

configuration and reports.

If you want to use different configurations for your different instances on the same machine (either you deploy different version of the

JasperReportsIntegration or you have your development, test and production environment running on the same machine but on different J2EE servers),

you would use the direct manipulation of the web.xml file.

2.1. Configure the server environment using an operating system environment variable
Using the operating system environment variable OC_JASPER_CONFIG_HOME we can configure where these files reside on the filesystem. This directory is

the same as the base directory of your downloaded files, i.e. it should at least contain the sub directories conf, reports, logs.

2.1.1 Create the required directory structure
First you need to set up the required directory structure in the target directory. Just copy the directories conf, reports and logs to the target

directory, e.g. c:\app\JasperReportsIntegration:

directory structure

2.1.2.a) Unix / Linux: set the environment variable
On a Unix / Linux system running Tomcat you could for example add this setting to the Tomcat startup script (e.g. /usr/local/tomcat/bin/startup.sh):
OC_JASPER_CONFIG_HOME=/opt/JasperReportsIntegration
export OC_JASPER_CONFIG_HOME

2.1.2.b) Windows: set the environment variable
On a Windows machine you could do the same (e.g. c:\program files\apache tomcat\bin\startup.cmd):
SET OC_JASPER_CONFIG_HOME=c:\app\JasperReportsIntegration
or you could modify the system environment of the machine and create the variable OC_JASPER_CONFIG_HOME=c:\app\JasperReportsIntegration

2.2 Configure the setting in the web.xml file of the JasperReportsIntegration.war file
By using this approach you can tell the JasperReportsIntegration.war file directly where it can find its configuration files. The following

procedure will manipulate the J2EE context-parameter oc.jasper.config.home in the file web.xml of the JasperReportsIntegration.war directly for you.

2.2.1 Create the required directory structure
First you need to set up the required directory structure in the target directory. Just copy the directories conf, reports and logs to the target

directory, e.g. c:\app\JasperReportsIntegration:

directory structure

2.2.2.a) Unix / Linux:  Set the configuration directory directly in the JasperReportsIntegration.war file
In the following example we will use /opt/JasperReportsIntegration as the target directory.
cd bin
./setConfigDir.sh ../webapp/JasperReportsIntegration.war /opt/JasperReportsIntegration

2.2.2.b) Windows:  Set the configuration directory directly in the JasperReportsIntegration.war file
In the following example we will use c:\app\JasperReportsIntegration as the target directory.
cd bin
setConfigDir.cmd ..\webapp\JasperReportsIntegration.war c:\app\JasperReportsIntegration

2.2.3.a) Unix / Linux: Get the configuration directory from the JasperReportsIntegration.war file
In order to determine the configuration directory from a specific JasperReportsIntegration.war file, you can run the following command to see where

it points to. This is just for verification purposes.
cd bin
./getConfigDir.sh ../webapp/JasperReportsIntegration.war

2.2.3.b) Windows: Get the configuration directory from the JasperReportsIntegration.war file
In order to determine the configuration directory from a specific JasperReportsIntegration.war file, you can run the following command to see where

it points to. This is just for verification purposes.
cd bin
getConfigDir.cmd ..\webapp\JasperReportsIntegration.war

2.3 Configure your database access
Edit the file conf/application.properties in your target directory and configure the data source default to connect to your Oracle schema (change

the parts in bold to point to the Oracle schema you want to connect to):

#====================================================================
# JDBC datasource configuration
# http://www.orafaq.com/wiki/JDBC#Thin_driver
# type=jdbc|jndi
#====================================================================

[datasource:default]
type=jdbc
name=default
url=jdbc:oracle:thin:@192.168.2.114:1521:XE
username=HR
password=hr_password

Alternatively you could use the native JNDI data source of your application server. See the documentation there on how to configure it. In this

configuration file you would have to register just the JNDI datasource you want to use:

#====================================================================
# Native JNDI datasource, to be configured in the application server
# name: jndi_test
#====================================================================
[datasource:jndi_test]
type=jndi
name=jndi_test

2.4 Encrypting all passwords in the application.properties file
You can optionally encrypt the passwords in the application.properties file. Just follow the following steps, the file will automatically be updated

with the encrypted passwords for all of the datasources.

2.4.1.a) Unix / Linux
In order to determine the configuration directory from a specific JasperReportsIntegration.war file, you can run the following command to see where

it points to. This is just for verification purposes.
cd bin
./encryptPasswords.sh <path to application.properties file>
  e.g.: ./encryptPasswords.sh /opt/JasperReportsIntegration/conf/application.properties

2.4.1.b) Windows
In order to determine the configuration directory from a specific JasperReportsIntegration.war file, you can run the following command to see where

it points to. This is just for verification purposes.
cd bin
encryptPasswords.cmd <path to application.properties file>
  e.g.: encryptPasswords.cmd c:\app\JasperReportsIntegration\conf\application.properties

2.5 Deploy the J2EE application
Take the application server of your choice and deploy the file webapp/JasperReportsIntegration.war to it. For an Apache Tomcat this typically means

to copy the file JasperReportsIntegration.war into the directory webapps of your Tomcat application. If the Tomcat doesn't deploy it automatically,

you would have to restart the Tomcat.

After that you can reach the JasperReportsIntegration homepage with the URL http://<server>:<port>/JasperReportsIntegration.

Here you will find the included documentation, information about the location of the configuration files, you can test the database connections and

run the test reports:


2.6 Securing the homepage of the J2EE application
Since the homepage tells you a lot about the system you will typically protect that information in a production environment.
Therefore you can edit the file conf/application.properties and set the config parameter infoPageIsEnabled=false.

#====================================================================
# Application properties (global)
#====================================================================
[application]
configFileVersion=2.3.0
jndiPrefix=java:comp/env/jdbc/
# infoPageIsEnabled will show the initial start page of the j2ee application
# including testing and the environment settings
infoPageIsEnabled=false

After you restart the J2EE application the homepage will be protected:

Protected Homepage
3. Installation of database objects
The database objects required for the integration will be installed into each application schema that you want to use with the integration.
The installation instructions will refer to the application schema (in which you install the software) as [application schema]. The password for the

application schema will be referred to as [application schema password].

Thus when I use an instruction like sqlplus [application schema]/[application schema password]@[database] please replace that with the actual values

of your local installation. For example, if you want to install the integration kit into the schema HR with the password hr1 into your local XE

instance (having a TNS entry named xe) then this instruction translates to:

sqlplus hr/hr1@xe

3.1 Database installation (SYS)
First of all we need to grant the required privileges to the Oracle user who will own the packages for the integration.

Extract the downloaded zip file.
Open a command shell:
e.g. on Windows: Start > Execute : cmd
Go to the subdirectory sql (of where you extracted the file):
cd sql
Connect as SYS to the local instance (using sqlplus)
sqlplus "sys/[sys password]@[database] as sysdba"
Run the installation script (and pass the name of the target application schema as a parameter)
@sys_install.sql [application schema]
[optional] If you are installing on an Oracle Release 11.0 and higher, you have to grant the required network privileges to the application schema.
The  script sys_install_acl.sql allows access to the local machine on port 80 to port 10000. Please adapt the script to suit your needs, especially

if the J2EE server is running on a different machine. It needs to be run for each application schema using the integration.
@sys_install_acl.sql [application schema]

3.2 Database installation (Application Schema)
Open a command shell:
e.g. on Windows: Start > Execute : cmd
Go to the subdirectory sql (of where you extracted the file):
cd sql
Connect as the application schema to the local instance (using sqlplus)
sqlplus [application schema]/[application schema password]@[database]
Run the installation script
@user_install.sql

4. Installation of the test application
The test application will allow for basic testing of the integration with all relevant parts. Install the application file apex

\f121_JasperReportsIntegration-Test_x.x.x.x.sql into your workspace.
It will perform checks on the installation and allow you to run the test reports.



In some circumstances you can encounter errors, mostly due to enhanced security constraints:
Expected errors during validation

Check 4 can fail when there is no valid index page for the J2EE container

Check 5 and Check 6 can fail, when the setting infoPageIsEnabled=false in the application.properties file is set

Check 7 should be always be working correctly.

Javascript :

var r_server = "server address with report folder?_repName=report_name&_repFormat=pdf&_dataSource=data_source_name";
var r_branch_code = $v("P126_BRANCH");
var r_emp_id = $v("P126_FO");
var r_year = $v("P126_YEAR");
var rp_1 = "&P_BRANCH";
var rp_2 = "&P_EMP";
var rp_3 = "&P_YEAR";

var r_link = ""+r_server+""+rp_1+"="+r_branch_code+""+rp_2+"="+r_emp_id+""+rp_3+"="+r_year+"";
window.open(r_link);

Javascript 2 :


var r_server = "http://localhost:8181/JasperReportsIntegration/report?_repName=CountryList&_repFormat=pdf&_dataSource=default";
var r_id1 = $v("P15_ID1");
var r_id2 = $v("P15_ID2");
var rp_1 = "&P1";
var rp_2 = "&P2";

var r_link = ""+r_server+""+rp_1+"="+r_id1+""+rp_2+"="+r_id2+"";
window.open(r_link);




Saturday, July 6, 2019

How to install ORDS and tomcat for Oracle Apex



Apex + ORDS + Tomcat

1 - Download ORDS and apache tomcat (Search in google.)
2 - Copy ORDS to c:\ and extract. and rename to ords.
3 - Rename ords.war to noorbd.war
4 - Create a folder config in c:\ords

java -jar noorbd.war

Enter the location to store configuration date: c:\ords\config

Enter the name of the database server [Localhost]: Enter
Enter the database listen port [1521]:
Enter 1 to specify the database service name,or 2 to specify the database SID : 2
Enter the database SID [xe]:
Enter the database password for ORDS_PUBLIC_USER:
Confirm Password :

Retrieving information.

Enter 1 if you want to user PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]: 1
Enter the database password for APEX_PUBLIC_USER:
Confirm Password :

Enter 1 to specify passwords for Application Express RESTful Services database users (APEX LISTENER...): 1
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:

Enter 1 if you wish to start in standalone mode or 2 to exit [1]: 2

>>>>Now Install Apache tomcat.

copy the noorbd.war where ROOT folder exist in tomcat folder.

Create a directory 'i' here.

Copy image to i

edit server in notepad : ../Tomcat8.5/conf

Search appBase ="webapps"

Write

<Context docBase="C:\apex\images" path="/i" />

Run Apache Server.

Change the port number at : C:\Program Files\Apache Software Foundation\Tomcat 8.5\conf\server.xml  to

<Connector port="8181" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />


---- Run in command prompt : CMD

java -jar noorbd.war validate orcl

---- SQLplus /nolog
---- conn / as sysdba

EXEC DBMS_XDB.SETHTTPPORT(8181);


How to install Oracle Apex 18.1

01 - Create a new tablespace to act as the default tablespace for APEX.

CREATE TABLESPACE apex DATAFILE 'F:\app\Administrator\oradata\TEMPDB\apex_01.dbf' SIZE 1000M AUTOEXTEND ON NEXT 1M;

02 - Installation:
------------------

Change directory to the directory holding the unzipped APEX software.

D:\apex_18.1_en\apex

F:\app\Administrator\product\11.2.0\dbhome_1\BIN\sqlplus.exe /nolog

CONN sys/sys@tempdb AS SYSDBA

@apexins.sql APEX APEX TEMP /i/

03 - Once complete, change the admin password by running the "apxchpwd.sql" scripts as the SYS user.
----------------------------------------------------------------------------------------------------

CONN sys/sys@tempdb AS SYSDBA

@apxchpwd.sql

04 - Create the APEX_LISTENER and APEX_REST_PUBLIC_USER users by running the "apex_rest_config.sql" script.
------------------------------------------------------------------------------------------------------------

CONN sys/sys@tempdb AS SYSDBA

@apex_rest_config.sql

05 - Embedded PL/SQL Gateway (EPG) Configuration :
--------------------------------------------------

CONN sys/sys@tempdb AS SYSDBA

@apex_epg_config.sql D:\apex_18.1_en

06 - Unlock the ANONYMOUS account :
-----------------------------------

CONN sys/sys@tempdb AS SYSDBA

ALTER USER ANONYMOUS IDENTIFIED BY a;

alter user anonymous account unlock;


DECLARE
  l_passwd VARCHAR2(40);
BEGIN
  l_passwd := DBMS_RANDOM.string('a',10) || DBMS_RANDOM.string('x',10) || '1#';
  -- Remove CONTAINER=ALL for non-CDB environments.
  EXECUTE IMMEDIATE 'ALTER USER anonymous IDENTIFIED BY ' || l_passwd || ' ACCOUNT UNLOCK CONTAINER=ALL';
END;
/

07 - Check the port setting for XML DB Protocol Server:
-------------------------------------------------------

CONN sys/sys@tempdb AS SYSDBA

SELECT DBMS_XDB.gethttpport FROM DUAL;

GETHTTPPORT
-----------
          0

CONN sys/sys@tempdb AS SYSDBA

EXEC DBMS_XDB.sethttpport(8080);

08- Find the URL here :
-----------------------

http://localhost:8080/apex

workspace : TEST
UserName  : TEST
Password  : TEST

Schema    : Test/t@tempdb







How to install Jasper iReport 5.1

1 - Install Jre7  https://drive.google.com/file/d/0B3LTUDyiHdTNNXVnek1uQ1VtMk0/view
2 - Install Jasper Ireport 5.1
3 - Go to :   C:\Program Files (x86)\Jaspersoft\iReport-5.1.0\etc\ireport.conf
              #jdkhome="C:\Program Files (x86)\Java\jre7"
4 - Run Ireport.
5 - Go to : Tools>Options>ClassPath>   Add jar >  show ojdbc14.jar   Click Reloadable. OK.
6 - Click Report DataSource.
7 - Click New.
8 - JDBC connections.
9 - Next > Show Oracle Driver.
10 - Name the connection.
11 - Change the JDBC URL: jdbc:oracle:thin:@localhost:1521:tempdb
12 - Test.
13 - Save.

Thursday, July 4, 2019

Picture in Report

select "EMPNO",
"ENAME",
"JOB",
"MGR",
"HIREDATE",
"SAL",
"COMM",
"DEPTNO",
dbms_lob.getlength("PHOTO") "PHOTO"
"GENDER",
"ROSTER_TYP"
from "#OWNER#"."EMP"

css in PAGE:

img{
width:50px;
height: 100 px;
}