A script-enabled browser is required for this page to function properly.

Creating Modules Using the Open API

To create a basic Oracle Forms module:

  1. Include the appropriate C header files in your C source code.
  2. Make calls to the desired Open API functions in your C source code.
  3. Link your source files against the Open API library (frmd2f32.lib).
  4. Compile the files to create an executable.
  5. Run the executable to create a Oracle Forms module.

Creating modules using the Open API Examples

Example

/*
This example creates a master-detail form based on the dept and emp database tables owned by the user scott. The master contains the following fields: empno, ename, job, sal, and deptno. The detail contains the following fields deptno, dname, and loc. The join condition is deptno.
*/

#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<d2fctx.h>
#include<d2ffmd.h>
#include<d2ffpr.h>
#include<d2fob.h>
#include<d2fcnv.h>
#include<d2ftrg.h>
#include<d2blk.h>
#include<d2fitm.h>
#include<d2fwin.h>
#include<d2frel.h>


#define D2FS_SUCCESS 0
#define FAIL 1
#define BUFSIZE 128
#define WBP_TXT "null;/n"


int WINAPI WinMain(HANDLE hInstance,
HANDLE hPrevInstance,
LPSTR lpszCommandLine,
int cmdShow)
{
d2fctx *pd2fctx;
d2ffmd *pd2ffmd;
d2fcnv *pd2fcnv;
d2fwin *pd2fwin;


d2fblk *pempblk;
d2fblk *pdeptblk;
d2frel *pd2frel;


d2fitm *pEempnoitm;
d2fitm *pEenameitm;
d2fitm *pEjobitm;
d2fitm *pEsalitm;

d2fitm *pEdeptnoitm;
d2fitm *pDdeptnoitm;
d2fitm *pDdnameitm;
d2fitm *pDlocitm;


text *name = (text *)0;
text *form_name = (text *)0;
d2fctxa d2fctx_attr;
d2fstatus retval;
char buf[BUFSIZE];


/* Get form name */
strncpy(buf, "empdept", BUFSIZE);
form_name = (text*)strtok(buf, ".");

/* Initialize the attribute mask */
d2fctx_attr.mask_d2fctxa = 0;

/* Create the API context */
status = d2fctxcr_Create(&pd2fctx, &d2fctx_attr);

/* Create the context */
d2fctxcn_Connect(pd2fctx, (text*)"scott/tiger@test");

/* Create the form */
d2ffmdcr_Create(pd2fctx, &pd2ffmd, form_name);

/* Create a window */
d2fwincr_Create(pd2fctx,pd2ffmd,&pd2fwin,(text*)"MYWIN");


/*** Create Canvas and set canvas-related properties ***/
/* Create a canvas */
d2fcnvcr_Create(pd2fctx, pd2ffmd, &pd2fcnv, (text*)"MYCANVAS");

/* Set viewport width */
d2fcnvs_vprt_wid(pd2fctx, pd2fcnv, 512);

/* Set viewport height */
d2fcnvs_vprt_hgt(pd2fctx, pd2fcnv, 403);

/* Set window */
dwfcnvs_wnd_obj(pd2fctx, pd2fcnv, pd2fwin);

/* Set viewport X-position */
d2fcnvs_vprt_x_pos(pd2fctx, pd2fcnv, 0);

/* Set viewport Y-position */
d2fcnvs_vprt_y_pos(pd2fctx, pd2fcnv, 0);

/* Set width */
d2fcnvs_width(pd2fctx, pd2fcnv, 538)

/* Set height */
d2fcnvs_height(pd2fctx, pd2fcnv, 403)


/*** Create Emp block and set block-related properties ***/
/* Create block */
d2fblkcr_Create(pd2fctx, pd2ffmd, &pempblk, (text*)"EMP");

/* Set to database block */
d2fblks_db_blk(pd2fctx, pempblk, TRUE);

/* Set query data source to Table */
d2fblks_qry_dat_src_typ(pd2fctx, pempblk, D2FC_QRDA_TABLE);

/* Set query data source name to EMP table */
d2fblks_qry_dat_src_nam(pd2fctx, pempblk, "EMP");

/* Set DML data source type to Table */
d2fblks_dml_dat_typ(Pd2fctx, pempblk, D2FC_DMDA_TABLE);

/* Set DML data source name to EMP table */
d2fblks_dml_dat_nam(pd2fctx, pempblk, (text*)"EMP");


/*** Create Dept block and set block-related properties ***/
/* Create block */
d2fblkcr_Create(pd2fctx, pd2ffmd, &pdeptblk, (text*)"DEPT");

/* Set to database block */
d2fblks_db_blk(pd2fctx, pdeptblk, TRUE);

/* Set query data source to Table */
d2fblks_qry_dat_src_typ(pd2fctx, pdeptblk, D2FC_QRDA_TABLE);

/* Set query data source name to EMP table */
d2fblks_qry_dat_src_nam(pd2fctx, pdeptblk, "DEPT");

/* Set DML data source type to Table */
d2fblks_dml_dat_typ(Pd2fctx, pdeptblk, D2FC_DMDA_TABLE);

/* Set DML data source name to EMP table */
d2fblks_dml_dat_nam(pd2fctx, pdeptblk, (text*)"DEPT");


/*** Create empno item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pempblk, &pEempnoitm, (text*)"EMPNO");

/* Set item type */
d2fitms_itm_type(pd2fctx, pEempnoitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pEempnoitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pEempnoitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pEempnoitm, D2FC_DATY_NUMBER);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pEempnoitm, 6);

/* Set item Required property */
d2fitms_required(pd2fctx, pEempnoitm, TRUE);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pEempnoitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pEempnoitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pEempnoitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pEempnoitm, 6);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pEempnoitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pEempnoitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pEempnoitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pEempnoitm, 32);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pEempnoitm, 50);

/* Set Item Width */
d2fitms_width(pd2fctx, pEempnoitm, 51);

/* Set Item Height */
d2fitms_height(pd2fctx, pEempnoitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pEempnoitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PEempnoitm, (text*)"Enter value for :EMPNO");


/*** Create Ename item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pempblk, &pEenameitm, (text*)"ENAME");

/* Set item type */
d2fitms_itm_type(pd2fctx, pEenameitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pEenameitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pEenameitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pEenameitm, D2FC_DATY_CHAR);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pEenameitm, 10);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pEenameitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pEenameitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pEenameitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pEenameitm, 10);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pEenameitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pEenameitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pEenameitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pEenameitm, 83);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pEenameitm, 50);

/* Set Item Width */
d2fitms_width(pd2fctx, pEenameitm, 77);

/* Set Item Height */
d2fitms_height(pd2fctx, pEenameitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pEenameitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PEenameitm, (text*)"Enter value for :ENAME");


/*** Create JOB item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pempblk, &pEjobitm, (text*)"JOB");

/* Set item type */
d2fitms_itm_type(pd2fctx, pEjobitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pEjobitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pEjobitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pEjobitm, D2FC_DATY_CHAR);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pEjobitm, 9);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pEjobitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pEjobitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pEjobitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pEjobitm, 9);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pEjobitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pEjobitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pEjobitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pEjobitm, 160);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pEjobitm, 50);

/* Set Item Width */
d2fitms_width(pd2fctx, pEjobitm, 70);

/* Set Item Height */
d2fitms_height(pd2fctx, pEjobitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pEjobitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PEjobitm, (text*)"Enter value for :JOB");


/*** Create SALARY item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pempblk, &pEsalitm, (text*)"SAL");

/* Set item type */
d2fitms_itm_type(pd2fctx, pEsalitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pEsalitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pEsalitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pEsalitm, D2FC_DATY_NUMBER);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pEsalitm, 9);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pEsalitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pEsalitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pEsalitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pEsalitm, 9);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pEsalitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pEsalitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pEsalitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pEsalitm, 352);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pEsalitm, 50);

/* Set Item Width */
d2fitms_width(pd2fctx, pEsalitm, 70);

/* Set Item Height */
d2fitms_height(pd2fctx, pEsalitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pEsalitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PEsalitm, (text*)"Enter value for :SAL");


/*** Create DEPTNO item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pempblk, &pEdeptnoitm, (text*)"DEPTNO");

/* Set item type */
d2fitms_itm_type(pd2fctx, pEdeptnoitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pEdeptnoitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pEdeptnoitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pEdeptnoitm, D2FC_DATY_NUMBER);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pEdeptnoitm, 4);

/*Set item Required property */
d2fitms_required(pd2fctx, pEdeptnoitm, TRUE);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pEdeptnoitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pEdeptnoitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pEdeptnoitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pEdeptnoitm, 4);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pEdeptnoitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pEdeptnoitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pEdeptnoitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pEdeptnoitm, 493);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pEdeptnoitm, 50);

/* Set Item Width */
d2fitms_width(pd2fctx, pEdeptnoitm, 30);

/* Set Item Height */
d2fitms_height(pd2fctx, pEdeptnoitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pEdeptnoitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PEdeptnoitm, (text*)"Enter value for :DEPTNO");


/*** Create DEPTNO item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pdeptblk, &pDdeptnoitm, (text*)"DEPTNO");

/* Set item type */
d2fitms_itm_type(pd2fctx, pDdeptnoitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pDdeptnoitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pDdeptnoitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pDdeptnoitm, D2FC_DATY_NUMBER);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pDdeptnoitm, 4);

/*Set item Required property */
d2fitms_required(pd2fctx, pDdeptnoitm, TRUE);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pDdeptnoitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pDdeptnoitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pDdeptnoitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pDdeptnoitm, 4);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pDdeptnoitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pDdeptnoitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pDdeptnoitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pDdeptnoitm, 32);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pDdeptnoitm, 151);

/* Set Item Width */
d2fitms_width(pd2fctx, pDdeptnoitm, 38);

/* Set Item Height */
d2fitms_height(pd2fctx, pDdeptnoitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pDdeptnoitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PDdeptnoitm, (text*)"Enter value for :DEPTNO");


/*** Create DNAME item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pdeptblk, &pDdnameitm, (text*)"DNAME");

/* Set item type */
d2fitms_itm_type(pd2fctx, pDdnameitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pDdnameitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pDdnameitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pDdnameitm, D2FC_DATY_CHAR);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pDdnameitm, 14);

/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pDdnameitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pDdnameitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pDdnameitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pDdnameitm, 14);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pDdnameitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pDdnameitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pDdnameitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pDdnameitm, 70);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pDdnameitm, 151);

/* Set Item Width */
d2fitms_width(pd2fctx, pDdnameitm, 102);

/* Set Item Height */
d2fitms_height(pd2fctx, pDdnameitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pDdnameitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PDdnameitm, (text*)"Enter value for :DNAME");


/*** Create LOC item and item-related properties ***/
/* Create item */
d2fitmcr_Create(pd2fctx, pdeptblk, &pDlocitm, (text*)"LOC");

/* Set item type */
d2fitms_itm_type(pd2fctx, pDlocitm, D2FC_ITTY_TI);

/* Set Enable property */
d2fitms_enabled(pd2fctx, pDlocitm, TRUE);

/* Set item (keyboard) navigable property */
d2fitms_kbrd_navigable(pd2fctx, pDlocitm, TRUE);

/* Set item Data Type property */
d2fitms_dat_typ(pd2fctx, pDlocitm, D2FC_DATY_CHAR);

/* Set item Max Length property */
d2fitms_max_len(pd2fctx, pDlocitm, 13);


/* Set Distance Between Records property */
d2fitms_dist_btwn_recs(pd2fctx, pDlocitm, 0);

/* Set Database block(Database Item) property */
d2fitms_db_itm(pd2fctx, pDlocitm, TRUE);

/* Set Query Allowed */
d2fitms_qry_allowed(pd2fctx, pDlocitm, TRUE);

/* Set Query Length */
d2fitms_qry_len(pd2fctx, pDlocitm, 13);

/* Set Update Allowed */
d2fitms_updt_allowed(pd2fctx, pDlocitm, TRUE);

/* Set Item Displayed (Visible) */
d2fitms_visible(pd2fctx, pDlocitm, TRUE);

/* Set Item Canvas property */
d2fitms_cnv_obj(pd2fctx, pDlocitm, pd2fcnv);

/* Set Item X-position */
d2fitms_x_pos(pd2fctx, pDlocitm, 173);

/* Set Item Y-position */
d2fitms_y_pos(pd2fctx, pDlocitm, 151);

/* Set Item Width */
d2fitms_width(pd2fctx, pDlocitm, 96);

/* Set Item Height */
d2fitms_height(pd2fctx, pDlocitm, 17);

/* Set Item Bevel */
d2fitms_bevel(pd2fctx, pDlocitm, D2FC_BEST_LOWERED);

/* Set item Hint */
d2fitms_hint(pd2fctx, PDlocitm, (text*)"Enter value for :LOC");


/*** Create Relations and relations-related properties ***/
/* Create Relation */
d2frelcr_Create(pd2fctx, (d2fob *)pdeptblk, &pd2frel, (text*)"DEPT_EMP");

/* Set Relation Detail block */
d2frels_detail_blk(pd2fctx, pd2frel, (text *)"EMP");

/* Set Master Deletes property */
d2frels_del_rec([pd2fctx, pd2frel, D2FC_DERE_NON_ISOLATED);

/* Set Deferred property */
d2frels_deferred(pd2ctx, pd2frel, FALSE);

/* Set Auto Query property */
d2frels_auto_qry(pd2ctx, pd2frel, FALSE);

/* Set Prevent Masterless property */
d2frels_prvnt_mstrless_ops(pd2ctx, pd2frel, FALSE);

/* Set Join Condition property */
d2frels_join_cond(pd2ctx, pd2frel, (text*)"DEPTNO");

/* Instantiate Relation: creates master-detail triggers */
d2frelup_Update(pd2fctx, pd2frel);


/* Save Form */
d2ffmdsv_Save(pd2fctx, pd2ffmd, (text*)0, FALSE, TRUE);

/* Compile Form */
d2ffmdcf_CompileFile(pd2fctx, pd2ffmd);

/* Destroy Context */
d2fctxde_Destroy(pd2fctx);
}


About the Open API

Modifying modules using the Open API

About Open API header files

About Open API objects and relations

Open API properties by object

About Open API functions by objects

Open API macros by objects