Showing posts with label Oracle Concpets. Show all posts
Showing posts with label Oracle Concpets. Show all posts

Thursday, February 23, 2017

Selecting Multiple Values in Concurrent Program Paramater

Requirement:
To have a concurrent program parameter where he can select multiple value from the value set. Solution: Create 2 parameter, first one with the value set which will have the values from which the values need to be selected. The second parameter will be a free text field which will hold the selected values from the first value set.

Steps to achieve the desired solution 
1) Create a value set which will hold the values. Let say the name is “XXTK_MULTIPLE_VALUE_SET”
Explanation This value set will be holding the values from which the user will be selecting the values into the second parameter.
2) Create a concurrent program program and create PARAMETER-1 and assign the above value set to it.



3) Create second parameter and do the following setup
3.1) Value Set: 240 Characters
3.2) Default Type: SQL Statement
3.3) Default Value: SELECT xxoa_multiple_parameter.return_value(:$FLEX$.XXTK_MULTIPLE_VALUE_SET) FROM DUAL







ExplanationThe select statement will take the input as the selected value from the first parameter and will return the concatenated values.
4) In the Default value we have used a function, so now we have to create that function.


CREATE OR REPLACE PACKAGE xxoa_multiple_parameter
AS
g_var VARCHAR2 (3200) := NULL;
g_time DATE;
 
FUNCTION return_value (i_para VARCHAR2)
RETURN VARCHAR2;
END;
/
 
CREATE OR REPLACE PACKAGE BODY xxoa_multiple_parameter
AS
FUNCTION return_value (I_para VARCHAR2)
RETURN VARCHAR2
AS
l_len NUMBER := LENGTH (I_para);
BEGIN
IF g_time IS NULL
THEN
g_time := SYSDATE;
g_var := i_para;
ELSE
IF (((SYSDATE - g_time) * 60 * 60 * 24) > 30)
THEN
g_time := SYSDATE;
g_var := i_para;
ELSE
IF ( NVL (LENGTH (g_var), 0)
- NVL (LENGTH (REPLACE (g_var, i_para, NULL)), 0)
- l_len != 0
)
THEN
IF g_var IS NULL
THEN
g_var := i_para;
ELSE
g_var := i_para || ',' || g_var;
END IF;
ELSE
g_var := REPLACE (g_var, i_para);
END IF;
END IF;
END IF;
 
g_var := REGEXP_REPLACE (REGEXP_REPLACE (g_var, '^,|,$', ''), ',,', ',');
RETURN g_var;
END return_value;
END xxoa_multiple_parameter;



Explanation This function takes the input from the first parameter (Value Set) and initialize the GLOBAL PARAMETER of TIME and parameter. It checks whether the initialize is done before 90 sec or not. If no, then it will concatenate the values and will return the new string of values. If the user wants to remove selected value value then he has to select the value again and the function will remove the value. Also before returning the final string of values the function will remove the comma from starting or at the end of the string.



Explanation The reason for creating 2 parameters are that the first parameter will be holding the parameter from the value set which is of no use. The second parameter is of use as that will hold the selected values.
Steps to Use
1) Select the concurrent program and select the Value from the Value set



After selecting the first value


2) Selecting the second value from the value set
3) Now Select a value to remove it from selected list. Selecting EMP

4) Once the value is selected, that value will be removed from the list

Limitations 
1) After submitting the values, user has to close the form of concurrent program and again has to open it. To Avoid this a time frame of 90 second is given. After 90 seconds the values will be reset to null.

Wednesday, August 05, 2015

Oracle Materialized View

What are Materialized Views ?
Materialized views are local copies of remote tables. Seems quite confusing. In today's distributed world, data resides on a central database server. The data is used by local users. In this kind of scenario, replicating data on local server can be helpful for gaining performance. Materialized views serve the same purpose. Materialized views contain data, same as if they were a table. These Materialized Views ( MV ) reside on local machines. Local users can query these MVs to get desired results. MVs can be complete replica of a table, or it can be a result of a query fired on multiple tables.
What is the difference between Tables / Views and Materialized Views ?
There must be some difference between Views and MVs. One can point a difference from the above discussion that views do not contain any data, but MVs do contain data. This difference can be easily pointed out from the definition of MVs itself. But then, what is the difference between Tables and MVs? The difference is that, MVs can refresh data from the Master tables after a specified time interval. I used a term Master tables. What are these Master tables? Master tables are the base for MV. As specified above MV can be an exact replica or result of a query. These tables on which query is fired on the server side are Master tables.
Types of Materialized Views
1) Read-Only : This type of MVs cannot send data back to the server Master tables. These server only one way communication i.e. from server to the client.
2) Updatable : This type of MVs can send the data, changed locally, back to the server.


Syntax ( Oracle ): -
1) create materialized view LOCAL_BOOKSHELF
    2) refresh force
       start with SysDate next SysDate + 7
       as
    3) select * from BOOKSHELF@REMOTE_CONNECT;




Explanation : In the above example some lines are numbered. These are different parts of create statement, also these will be used to reference exactly one part at a time.
1) The first part is the create statement itself with the MV name to be created. In this case MV name is "LOCAL_BOOKSHELF". Note that some parts are purposefully ignored here to avoid complexity. If no tablespace is provided then the MV is created in the current tablespace.
2) The 'refresh' part has some options. a. Fast b. Complete c. Force 

A)-Fast refreshes are only available if Oracle can match rows in the MV directly to rows in the base tables. They use tables called Materialized View Logs to send specific rows from the master table to the MV. 
B)-Complete refreshes completely re-create the MV. 
C)-The force option for refreshes tells Oracle to use a fast refresh if it is available; otherwise, a complete refresh will be used.
3) This part is the query. Note that the MV created in the above example is a Read-Only MV. If you want to create an updatable query, then 'for update' can be specified. Then syntax will be -

create materialized view LOCAL_BOOKSHELF
             refresh force
             start with SysDate next SysDate + 7
             for update as
             select * from BOOKSHELF@REMOTE_CONNECT;


Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...