Oracle APEX: using APEX_IG package to manipulate IG - oracle-apex

After upgrading APEX version I wanted to start using APEX_IG package for IG manipulation instead of using javascript.
I looked over the documentation for adding a filter and it requires to know the numeric ID for the IG which I do not have. My IG has a static ID but it is a string. How do i go about finding the region ID?
APEX_IG.ADD_FILTER(
p_page_id IN NUMBER,
p_region_id IN NUMBER,
p_filter_value IN VARCHAR2,
p_column_name IN VARCHAR2 DEFAULT NULL,
p_operator_abbr IN VARCHAR2 DEFAULT NULL,
p_is_case_sensitive IN BOOLEAN DEFAULT FALSE,
p_report_name IN VARCHAR2 DEFAULT NULL );

Use the below code to get the region id
select region_id
from apex_application_page_regions
where page_id = YOUR_PAGE_NUMBER
and static_id = 'YOUR_REGION_STATIC_ID';

Related

How to set session oracle apex?

SUPPOSE If i run any form in apex and then I will update any record then they get capture "APEX_PUBLIC_USER".
I want to capture my login user id by default using login URL
how to solve this ??
I'm not sure I understand what
I want to capture my login user id by default using login URL
means, but - user who is currently logged in is contained in :APP_USER so I suggest you use it.
The best practice in APEX to capture the audit fields (created_by, created, updated_by, update) is to use a trigger on the table. That way no coding is needed in apex itself.
Suppose you have a table rahul with a column "name" that you want to add records to via apex. Then you'd just create a form with the page item P1_NAME and let the database handle the other columns for you with the trigger.
create table rahul (
id number generated by default on null as identity
constraint koen_id_pk primary key,
name varchar2(255 char),
created date not null,
created_by varchar2(255 char) not null,
updated date not null,
updated_by varchar2(255 char) not null
)
;
-- triggers
create or replace trigger rahul_biu
before insert or update
on rahul
for each row
begin
if inserting then
:new.created := sysdate;
:new.created_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);
end if;
:new.updated := sysdate;
:new.updated_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);
end rahul_biu;
/

wso2 is change the embedded database schema

I am working with the WSO2 IS 5.2.0
for some reasons, I would like to change the data schema of the default embedded H2 database.
for example,
the maximum length of volume "ACCESS_TOKEN" in table "IDN_OAUTH2_ACCESS_TOKEN" is 255 chars. I would like to change it to 8194.
I made the following change the configuration file "/dbscripts/identity/h2.sql" (see the value "8194")
CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN (
TOKEN_ID VARCHAR (255),
ACCESS_TOKEN VARCHAR (8194),
REFRESH_TOKEN VARCHAR (255),
CONSUMER_KEY_ID INTEGER,
AUTHZ_USER VARCHAR (100),
TENANT_ID INTEGER,
USER_DOMAIN VARCHAR(50),
USER_TYPE VARCHAR (25),
GRANT_TYPE VARCHAR (50),
TIME_CREATED TIMESTAMP DEFAULT 0,
REFRESH_TOKEN_TIME_CREATED TIMESTAMP DEFAULT 0,
VALIDITY_PERIOD BIGINT,
REFRESH_TOKEN_VALIDITY_PERIOD BIGINT,
TOKEN_SCOPE_HASH VARCHAR (32),
TOKEN_STATE VARCHAR (25) DEFAULT 'ACTIVE',
TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE',
SUBJECT_IDENTIFIER VARCHAR(255),
PRIMARY KEY (TOKEN_ID),
FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE,
CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY_ID,AUTHZ_USER,TENANT_ID,USER_DOMAIN,USER_TYPE,TOKEN_SCOPE_HASH,
TOKEN_STATE,TOKEN_STATE_ID)
the problems is that I just cannot put this change into effect. I did everything (restart, reinstall), the original settings ("256") persists...
it seems that the database schema had been generated in the IS server image. and the generating script file says "GENERATE IF NOT EXISTS..."
anyone has any idea?
thanks
Remove <IS_HOME>/repository/database/*. Then start server with -Dsetup.
./wso2server.sh -Dsetup
Yes, It is generated with the server distribution. What you can do is (backup and) remove the content of repository/database, update the db scripts and start the server with bin/wso2server.sh -Dsetup. This needs to be done only once, from next time on you can start the server as usual.
One other possibility is to use the H2 console. If you already have data, it will be the better option.

apex_item into a specific subregion

Hi I need to create programmatically some items, but I need them to be located into a specific subregion, from apex_item documentation I cannot see how this could be achieved, is this possible?
For instance a text item parameters are:
APEX_ITEM.TEXT(
p_idx IN NUMBER,
p_value IN VARCHAR2 DEFAULT NULL,
p_size IN NUMBER DEFAULT NULL,
p_maxlength IN NUMBER DEFAULT NULL,
p_attributes IN VARCHAR2 DEFAULT NULL,
p_item_id IN VARCHAR2 DEFAULT NULL,
p_item_label IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;
But none of them indicates where to put it.
Thank you for your time.
Dynamic items must be generated in a report or dynamic PL/SQL region, so create the subregion using one of these region types.

How can I assign a shared foreign key to all records inserted using the Data Load Wizard?

I have an ApEx application which, amongst other purposes, has a requirement to upload billing data provided by telecommunications providers. The data is being provided as a CSV file.
We have two tables. The first table, phone_invoice, contains per-invoice metadata such as billing dates and provider name. The second table, phone_invoice_detail is based largely on call logs.
phone_invoice_detail has a foreign key, invoice_id, which keys into phone_invoice(id). This creates a stock-standard master-detail relationship.
We have used the ApEx Data Load Wizard to set up the import capability for our users. But I need to assign the invoice_id to each imported row.
Currently, I have a Phone Invoice page. Users click a button, "Import Data for Invoice", which branches to the Data Load Wizard and sets a page item, P1000_INVOICE_ID with the value of that invoice ID -- P999_ID.
When the user begins the process, the CSV data supplied has all the fields except for an invoice ID. What I want is for that column in the underlying table -- invoice_id -- to be set to to the value of P1000_INVOICE_ID.
My current focus is on using the Transformation Rules. This has been tremendously frustrating because the documentation tells you nothing about them and there are no examples.
Permutations I have tried:
-- PL/SQL Expression:
:INVOICE_ID := :P1000_INVOICE_ID
:INVOICE_ID := :P999_ID
SELECT :P1000_INVOICE_ID INTO :INVOICE_ID FROM DUAL
SELECT :P999_ID INTO :INVOICE_ID FROM DUAL
-- Replace:
-- Expression 1 Expression 2
:P1001_INVOICE_ID :INVOICE_ID
:P999_INVOICE_ID :INVOICE_ID
As you can see, APEX creates 4 pages for import. And it use apex collection named LOAD_CONTENT to store imported data. So, you can change this collection before it will be loaded into the table.
Go to the page named 'Data Validation' (this page have report Data Validation), and add page process, with next parameters:
Type: PL/SQL anonymous block
Process Point: On Load - Before Header
Source:
declare
-- Local variables here
i integer;
begin
for i in (
select t.seq_id
from apex_collections t
where t.collection_name = 'LOAD_CONTENT'
) loop
apex_collection.update_member_attribute(
p_collection_name => 'LOAD_CONTENT',
p_seq => i.seq_id,
p_attr_number => 3, -- here number of your column you want update
p_attr_value => :P1000_INVOICE_ID -- value
);
end loop;
end;
But change in this process number of your column.
I've tried this example in my APEX version 4.1 - it works fine.

How to get the default value of a column of MS Access Database using C++?

This is the sql script I used to create a table in MS Access Database.
CREATE TABLE Contracts (
id int NULL DEFAULT 0,
sex varchar(255) DEFAULT 'female' NOT NULL
)
Now I want to programmatically get the default value of the field: "sex", I know it's 'female' but I don't know how to get it using C++ ADO interface.
Below is a snippet of my code:
m_pRecordset->Fields->get_Item(vIntegerType, &pvObject);
bstrColName = pvObject->GetName();
dtype = pvObject->GetType();
attr = pvObject->GetAttributes();
I can give you idea how to achieve it..
GetAttributes() method will not give you default value of the field but it will give you info about whether field is autoincrement ,system field or fixed - variable size field.
Check out for method GetDefaultValue() of the field that will do what you want.