Automatically updating table column in OBIEE
Hi folks,
I have a requirement for say i have to update a table column based on a condition, but this update should happen on daily basis (i mean it should be scheduled once daily) by checking if any records in that column meets the condition then update it
example :- column='Pending' then update it with 'Approved' . As transactions records comes on daily into the table.OBIEE should check and update the row so next time it doesnt show this row as 'Pending' .
I have thought of 2 approaches for this
1) Through writeback it is possible to update but manually ( the issue is it cant be automated or scheduled on daily basis and update multiple records on a go)
2) Writing a stored procedure or function for update, but how can i accomplish this procedure to be scheduled or run once daily.how to use it?
Any thoughts on the above two points or any method you guys can think off.
Any help is appreciated !
Cheers,
KK
Kranthi,
This shud be easy...
- Create a direct database request...with Update Statement
eg: Update table set col = 'Approved' where col = 'Pending'
- Create an ibot using the above DDR and schedule it on daily basis.
This will update the full table with new value on daily basis based on the condition
Similar Messages
-
Updating Table Columns Dynamically
Hi Everybody,
I have created the following procedure to update table columns, which are having 'N/A' to Null.
PROCEDURE PRC_UPDATE_NA_TO_NULL (p_owner all_tables.owner%TYPE, p_table_name all_tables.table_name%TYPE DEFAULT NULL)
IS
TYPE tc_ref_cursor IS REF CURSOR;
v_tc_ref_cursor tc_ref_cursor;
TYPE nt_column_name IS TABLE OF all_tab_cols.column_name%TYPE;
v_nt_column_name nt_column_name;
v_table_name all_tables.table_name%TYPE;
v_set_str VARCHAR2(4000);
v_where_str VARCHAR2(4000);
v_sql_stmt VARCHAR2(4000);
BEGIN
IF p_table_name IS NOT NULL THEN
OPEN v_tc_ref_cursor FOR
SELECT a.table_name
FROM all_tables a
WHERE a.owner = UPPER(p_owner)
AND a.table_name = UPPER(p_table_name)
ORDER BY a.table_name;
ELSE
OPEN v_tc_ref_cursor FOR
SELECT a.table_name
FROM all_tables a
WHERE a.owner = UPPER(p_owner)
ORDER BY a.table_name;
END IF;
LOOP
DBMS_OUTPUT.PUT_LINE('Processing Owner : '||UPPER(p_owner)||'....');
FETCH v_tc_ref_cursor INTO v_table_name;
EXIT WHEN v_tc_ref_cursor%NOTFOUND;
SELECT b.column_name
BULK COLLECT INTO v_nt_column_name
FROM all_tab_cols b
WHERE b.owner = UPPER(p_owner)
AND b.table_name = UPPER(v_table_name)
AND b.nullable = 'Y'
ORDER BY b.column_id;
IF v_nt_column_name.LAST > 0 THEN
DBMS_OUTPUT.PUT_LINE('Updating '||v_table_name||'....');
FOR i IN v_nt_column_name.FIRST .. v_nt_column_name.LAST
LOOP
v_set_str := v_set_str||v_nt_column_name(i)||' := NULL, ';
v_where_str := v_where_str||v_nt_column_name(i)||' = '||'''N/A'''||' OR ';
END LOOP;
v_set_str := RTRIM(TRIM(v_set_str),',');
v_where_str := RTRIM(TRIM(v_where_str),'OR');
v_sql_stmt := 'UPDATE '||v_table_name||' SET '||v_set_str||' WHERE '||v_where_str;
EXECUTE IMMEDIATE v_sql_stmt;
-- EXECUTE IMMEDIATE 'UPDATE '||v_table_name||' SET '||v_set_str||' WHERE '||v_where_str;
-- EXECUTE IMMEDIATE 'UPDATE :1 SET :2 WHERE :3' USING v_table_name, v_set_str, v_where_str;
COMMIT;
v_set_str := NULL;
v_where_str := NULL;
DBMS_OUTPUT.PUT_LINE('Finished Updating '||v_table_name||'....');
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Process Over....');
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
DBMS_OUTPUT.PUT_LINE(SQLCODE||':'||SQLERRM);
END;
The problem I am facing is that the Execute Immediate statement is not working. I have used the Execute Immediate statement in 3 different ways given in the above procedure, but none of them works and the error comes to the Exception section.
Kindly let me have your solutions.
Thanks in advance,
MAKThis approach can be dangerous. You are currently trying to update all columns in the tables to null if any of the columns are 'N/A'. Your query does not exclude external tables which may not be updatable. Your other query does not exclude data types that can not include 'N/A' such as number. You might want to move your commit outside the loop as you may end up committing partial updates.
You might try to capture the SQL that you are generating;
create table t(col2 varchar2(4000));Then in your package;
insert into t values(v_sql_stmt);
-- EXECUTE IMMEDIATE v_sql_stmt; -
Hi All,
How can I update the column of a table?
More precisely, I am having a table with five rows and five columns and I already put values
in all by using the program.When user clicks a button, I have to show different values in
each cells of my last column.
Thanks
priya.Hi Priya,
Lets say that you have a view controller's context structure as follows...
YBAPI_INPUT
|_OUTPUT
|_TABLE_NODE
|_COLUMN1
|_COLUMN2
|_COLUMN3
|_COLUMN4
|_COLUMN5
The follwoing code will help you in accessing values in the last row.
for (int i = 0; i < wdContext.nodeYBAPI_INPUT().nodeOUTPUT().nodeTABLE_NODE().size(); i++) {
wdComponentAPI.getMessageManager().reportSuccess(wdContext.nodeYBAPI_INPUT().nodeOUTPUT().nodeTABLE_NODE().getTABLE_NODEElementAt(i).setCOLUMN5("SET NEW VALUE HERE"));
Hope this helps.
Regards,
Rekha Malavathu -
Update table column with same auto-increment value, via T-SQL stored procedure
Good Evening to every one,
I have a table 'Contracts' as we can see in the picture below (I exported my data on An Excel Spreadsheet). Table's primary key is 'ID' column.
I am trying to create a stored procedure (i.e. updContractNum), through which I am going to update the 'Contract_Num' column, in every row where the values on Property_Code, Customer, Cust_Category and Amnt ARE EQUAL, as we can see in the schema above.
The value of Contract_Num is a combination of varchar and auto_increment (integer). For example, the next value on 'Contract number' column will be 'CN0005' for the combination of 11032-14503-02-1450,00
I' m trying to use CURSORS for this update but I am new in using cursors and I am stuck in whole process. I atttach my code below:
CREATE PROCEDURE updContractNum
AS
--declare the variables
DECLARE @CONTRACT_NUM VARCHAR(10); -- Contract Number. The value that will be updated on the table.
DECLARE @CONTRACT INTEGER; -- Contract number, the auto increment section on contract number
DECLARE @CONTR_ROW VARCHAR(200); -- Contract row. The row elements that will be using on cursor
DECLARE CONTRACT_CURSOR CURSOR FOR -- Get the necessary fields from table
SELECT PROPERTY_CODE, CUSTOMER, CUST_CATEGORY, AMNT
FROM CONTRACTS;
OPEN CONTRACT_CURSOR -- open a cursor
FETCH NEXT FROM CONTRACT_CURSOR INTO @CONTR_ROW
WHILE @@FETCH_STATUS = 0 -- execute the update, for every row of the tabl
BEGIN
--update Contract_Num, using the format coding : contract_number = 'CN' + 0001
UPDATE CONTRACTS
SET CONTRACT_NUM = 'CN'+@CONTRACT_NUM+1
END
CLOSE CONTRACT_CURSOR
Thank you in advance!You dont need cursor
You can simply use an update statement like this
UPDATE t
SET Contract_Num = 'CN' + RIGHT('00000' + CAST(Rnk AS varchar(5)),5)
FROM
SELECT Contract_Num,
DENSE_RANK() OVER (ORDER BY Property_Code,Customer,Cust_category,Amnt) AS Rnk
FROM table
)t
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Automatically update table when database make any changes
Hi Experts,
I want to create one table in the database that table
but values get inserted into that table automatically when the database make any changes (i.e if you insert/update/delete any values in any table in the database)
how should i create this type of table into my oracle database
please give me some script to create it
reg,
jelWhy not simply enable audit? Then you can query SYS.AUD table to track inserts/updates/deletes and even selects. Other than that, you would have to create a trigger on every existing and newly created table.
SY. -
Can I auto update table column??
Hi,there,
I have a table, need to update one field at the specified time every night,how can I achieve that
using trigger or PL/SQL?
Thanks a lot!!!
A GreenHi,
You can schedule routines (jobs) to be run periodically using the job queue. For more details on creating jobs, here is the documentation link:
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96521/jobq.htm#1079
Hope that helps.
Savitha. -
Update table column from another
Hi,
I´m having trouble updating data from one table to another. I wish to syncronize the geometry field of the table FAROLFAROLIM from FAROLFAROLIM_OUT. By standard SQL I've tried this:
update FAROLFAROLIM f, FAROLFAROLIM_OUT ff set f.GEOM = ff.GEOMETRY
where f.IDFAROLFAROLIM = ff.IDFAROLFAROLIM
Can you help me figuring out what is wrong???
Thanks in advance
Operatordude you are doing wrong thing...
please use following command.
UPDATE FAROLFAROLIM f
SET (f.GEOM) =
( SELECT ff.GEOMETRY
FROM FAROLFAROLIM_OUT ff
WHERE f.IDFAROLFAROLIM = ff.IDFAROLFAROLIM );
cheers,
Sandy -
Automatically update Data Flow when table column is added
Hi, I have identical SQL Server databases on Server A and Server B, and I'm trying to create an SSIS package that will update its own Data Flow task when I've added a new column.
When I open the SSIS package up in Data Tools after adding the column, I get the following warning: 'The external columns for OLE DB Destination are out of synchronization with the data source columns. The column "TestColumn" needs to be added to
the external columns.' So the package know when it's out of sync with the db.
Is there a way to automatically update the external columns?
Thank you!There is a Dynamic DTS task commercial product of CozyRock
Another possibility is to generate an updated version of the package programmatically either with BIML http://www.mssqltips.com/sqlservertip/3124/generate-multiple-ssis-packages-using-biml-and-metadata/
or via .net code http://msdn.microsoft.com/en-ca/library/ms345167.aspx
Arthur
MyBlog
Twitter -
Automatic updation of WHO columns in Oracle forms 6i
Hi,
I am using Forms 6i Version. I have developed a simple form with one database block. The form should display the colums in the table and should allow insert/update/delete operations on the form.
I am able to update and delete the data through the foem. However my form doesn't allow me to insert data. This is because the creation_date and created_by columns in the table cannot be null.(custom table).
And I dont want to have these fields in the form.
I want the who colums to be automatically updated in the custom table through form, which is not happening currently.
Pls help.
Thanks
DeeptiDeepti,
I have called the FND_STANDARD.SET_WHO in pre-insert /pre-update triggers. Still I could not get the who columns updated in my custom table.
Was this done at the block level? -- Custom Oracle Form Fails when User Looks at the 'About This Record' Information (Doc ID 236642.1)
Thanks,
Hussein -
Update table from SM30 with automatic Time Stamp
Hi,
I have created a table maintenance generator for updating table from SM30.
Now there are fields in my table which are CRETING TIME and CHANGING TIME. Both being TIMESTAMP field (datatype: RSDDTZNTSTMPS).
Is it possible while user updates records/create new record in the table from SM30, these time stamp field to automatically get populated.
Also is there any F4 help available for TIMESTAMP field?
ags.Hi,
You need to do two things inorder to get the desired results.
1) Go to Screen Layout of the Screen created by table maintenance generator and make the date/time columns to DISPLAY ONLY. This will ensure that user is not able to modify the values at runtime
2) Write the code in PAI of the Module pool program to populate the values at runtime using Sy-datum/sy-uzeit. (Hint : Search for INSERT/MODIFY statements which will show the location before which you need to write your logic)
Regards,
Kshitija -
Guys,
I need to update table A columns col3, col4, col5 and col6 by table b columns col3, col4, col5 and col6 however table b col5 and col6 values need to come from table c col1.
Means table b col5 and col6 have values in it however i need to replace them with value from table c col1 and need to update table a col5 and col6 accordingly.
table a and table b has col1 and col2 in common.
i am trying something like this.
Update a
a.col3 = b.col3,
a.col4 = b.col4,
a.col5 = (select col1 from table_c c where c.col2=b.col5),
a.col6 = (select col1 from table_c c where c.col2=b.col6)
from table_A a inner join table_b
on a.col1=b.col1 and a.col2=b.col2
can someone help me reframe above update query?
thanks in advance for your help.Try the below:(If you have multiple values, then you may need to use TOP 1 as commented code in the below script)
create Table tableA(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableA values(1,2,3,4,5,6)
create Table tableB(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableB values(1,2,30,40,50,60)
create Table tableC(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableC values(100,50,30,40,2,2)
--Insert into tableC values(200,50,30,40,2,2)
Insert into tableC values(100,60,30,40,2,2)
Select * From tablea
Update a Set
a.col3 = b.col3,
a.col4 = b.col4,
a.col5 = (select col1 from tablec c where c.col2=b.col5 ),
a.col6 = (select col1 from tablec c where c.col2=b.col6 )
from tableA a inner join tableb b
on a.col1=b.col1 and a.col2=b.col2
--Update a Set
--a.col3 = b.col3,
--a.col4 = b.col4,
--a.col5 = (select Top 1 col1 from tablec c where c.col2=b.col5 Order by c.Col1 asc),
--a.col6 = (select Top 1 col1 from tablec c where c.col2=b.col6 Order by c.Col1 asc)
--from tableA a inner join tableb b
--on a.col1=b.col1 and a.col2=b.col2
Select * From tablea
Drop table tablea,Tableb,TableC -
Getting errors when updating a column on a table having a primary key
Hi,
I have an application on Oracle APEX that raises the following error after an attempt (through the application) to update a column with no specific constraint on it:
ORA-06550: line 1, column 17: PL/SQL: ORA-00936: missing expression ORA-06550: line 1, column 9: PL/SQL: SQL Statement ignoredUnable to fetch row.
The involved table has a primary key conatraint and the corresponding column can be populated by a sequence (but there is no trigger to manipulate the sequence).
The sequence is mentioned in the involved page definition for populating the primary key.
If I disable the primry key and set to null the corresponding value for the primary of the record to be updated, then it is possible to update that record (thus the above column) through the application.
Did someone encountered this situation before?
If yes, what was then your workaround/solution?
Kind Regards.Dear user8058501 ,
Firstly) Did you check
Auto Row Fetch (After upgrade to 4.0.1)
Automated Row Fetch on Table with Synonym causes ORA-00936: missing expr.
Secondly) If the problem is not resolved, Would you provide a sample on apex.oracle.com with workspace/developer account to be able to help you
Please, if this solves your question, mark it as Correct. Otherwise as helpful.
Best Regards
Mahmoud -
Update table based on ID reference comparing each column and value
Hi,
Through UI user can update any information and click save. In backend i will be receiving only ID as reference . Based on the ID value i should update multiple tables wherever i have the reference tables. Here i will not get the values or column name updated.
I just get a ID to find which row is updated.
I should do a comparision now.
I have a history table where i get the row before updation. and i get a row after updation from current data i.e. from ssdb_Railroad[This will be updated by java after updation we will get the ID inorder to update remaining tables]. Now i need to compare
both the table column values and know which column is updated and after getting the value i should update reference tables.
Below is the structure for comparision table , History table and Main table.
Create table Comparision_History (
ID int IDENTITY(1,1) PRIMARY KEY,
InsertUser_UpdateUser varchar(50),
Old_ColVal varchar(100),
New_ColVal varchar(100),
TableName varchar(100),
[Action] varchar(50),
InsertDate_UpdateDate Datetime NOT NULL DEFAULT getdate()
CREATE TABLE SSDB_Railroad_History (
ID int IDENTITY PRIMARY KEY,
SCAC varchar(4) ,
Name varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
varchar(50),
NOTES varchar(1000),
[Action] varchar(50),
InsertDate_UpdateDate Datetime NOT NULL DEFAULT getdate(),
InsertUser_UpdateUser varchar(50),
CREATE TABLE SSDB_Railroad (
ID int IDENTITY(1,1)PRIMARY KEY,
SCAC varchar(4) UNIQUE,
Name varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
varchar(50),
InsertDate Datetime NOT NULL DEFAULT getdate(),
UpdateDate Datetime,
InsertUser varchar(50),
UpdateUser varchar(50)
Here SSDB_Railroad table and History table needs to be compared and get a updated value and it should be inserted in a comparision table. as well as it should be updated in reference tables.
Please help me with the code.
Thanks in Advance
DeepaHi Deepa_Deepu,
According to your description, personally, the merge function can meet your requirements. Usually, we can synchronize two tables by updating or inserting rows in a target table based on differences found in the source tables. Just as your description, when
the value of ID and InsertDate_UpdateDate in the source table matches a value, update them in the target table. When the values does not match, the source row is inserted into the target table.
For more information, see: using MERGE to perform UPDATE and INSERT operations on a target table by using a derived source table.
http://msdn.microsoft.com/zh-cn/library/bb510625.aspx
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
Hello -
New user to BO Data Services Designer. Company is using Data Services Version 12.2.
I have many tables that all need the same transformation- converting varchars fields to upper(varchar) fields
Example:
I have a table called Items. It has 40 columns, 25 of which are of type varchar.
What I have been doing is ....
I make the Item table as the source table then create a Query transform that is then attached to a new target table called - ITEMS_Production.
I can manually drag and drop columns from the source table to the query and then in the mapping area I can manually type in upper(table_name.column_name) or select the upper function and then select the table.column name from the function drop down list.
Obviously, I want to do this quicker as I have to do this for lots and lots of tables.
How can set up Data Services so that I can drag and drop an upper transform quickly and easily or automate this process.
I also know Python-Java so am happy to script something if need be.
the logic would be something like -
if there is a column with a type varchar, add the upper() transformation to column. Go to next column.
Excited to be using this new tool-
Thanks in advance.
RayUse the DS Workbench.
-
Update SAME column name in two tables from ONE query
Dear All Seniors
Please tell me is it possible to update a same column name in two tables.
I have two tables in same schema
(1)table name
pem.igp_parent
column name
igp_no.
igp_type
(2)table name
pem.igp_child
column name
igp_no.
igp_type
i want to update igp_no column in one query please tell me how it would be possible.
thanks
yassenYou want to update the data from what to what? Where is the new data coming from?
If you are trying to put the same data in two different tables, that strongly implies that you have a normalization problem that needs to be addressed.
Why do you want a single query rather than updating each table in turn? Can you join the two target tables to produce a key-preserved view?
Justin
Maybe you are looking for
-
Error while doing MR11 as enter Profitability segmet as Cost object
Hi All, While doing MR11, we noticed a error message (ZC - 001) as "Enter Profitability segment as Cost object for Revenue and COGS posting". The specified Material account is created as Cost element (CE Category 11) and in OKB9 configuration this co
-
How to use a query in Web template
Hello i have really a very silly question. How can i use a Query that is already defined by BEX into a Web template so that i can set up simple properties like changing colours of Row as well as avoid Tab pages. I logged into a Web template. Can any
-
Moving Library from one computer to another
Hi, I know I can share my library from one computer to another via a network, which I am doing. My issue is that I cannot do anything with the music on the computer that is sharing. I am wondering if there is a way to get the entire library from one
-
Hi, JTable offers the possibility to move columns via dnd. Is there a possibility to do the same with rows?
-
Using APIs with Edge (JQuery and JSON)
Hi I am very new to APIs but I have a pretty basic understanding and I want to figure out how I could use them in Edge. I following the following tutorial and have tried to modify it for my liking: http://www.gotoandlearn.com/play.php?id=168 Essentia