How can i capture data change of one table in oracle and post changed information to one web service intermediately - oracle

I have an account table in oracle, in this table has balance column, how can i capture a change of this column and post new value to one endpoint ws intermediately
Thanks a lot

Have you tried doing this with an AFTER UPDATE TRIGGER?
Oracle has a UTL_HTTP package which you can use within the trigger to make a webservice call.
The code here can be a good starting point

Related

Is there a way to check what oracle stored procdure is loading while running

I have a stored procedure which has been running for a long time and I don't find any entry for that in v$session_longops. Is there a way to check on the current status of that?
Also, am pretty new to oracle. So is there a way to check on the amount of data the proc is trying to load into a table just like work flow monitor in informatica?
I am a dev and am using Oracle 12c.
Check with a view called gv$session. Column sql_text should let you identify your session and column rows_processed should tell you how many rows, if any, have been processed.
You may need to ask your DBA to grant you access to that view.

Can we pass parameters in triggers in Oracle?

Like in procedures and Functions can we pass parameters to triggers? Can A trigger can be explicitly called?
An object based trigger is raised by an event's occurence(as update,insert,select)on a specific object of the database. There is also system triggers, fired by system specific events(as shutdown,startup database, user connection etc..).
This is the main purpose of a trigger in databases, you can't raise it explicitly, if you want it to run the only way is to raise the event. Also passing parameters isn't part of trigger definition, but you can handle the event attributes,(which can be passed to the trigger body that may can contain functions or procedures).
I hope that i've responded to your question, can i know what is your need for trying to do that.?
What you can do is to create a table that will store temporarily the data that you want to access in your trigger.
1-Create a table "tmp_data" for instance.
2-Before running the event that will fire the trigger (stored procedure, insert, update...) insert into tmp_data the data that you want to use in the trigger.
3-In the trigger, to access the data you needed, you make a query on the table tmp_data.
4-After have been done with the data, you clean the table tmp_data for the next use.
Hope has been helpful!

Is it possible in oracle to trigger a SAS program after an insert or update on oracle table?

I'm new to oracle and I saw Oracle triggers can trigger some action after an update or insert is done on oracle table.
Is it possible to trigger a SAS program after every update or insert on Oracle table.
There's a few different ways to do this but a problem like this is an example of the saying "Just because you can, doesn't mean you should".
So sure, your trigger can be fired on update or insert and that can call a stored procedure in a package which can use the oracle host command to call an operating system command which can call SAS.
Here are some questions:
do you really want to install SAS on the same machine as your Oracle database?
do you really want every transaction that inserts or updates to have to wait until the host command completes? What if SAS is down? Do you want the transaction to complete or.....?
do you really want the account that runs the database to have privileges to start up or send information to other executables? Think security risks.
if an insert does one record the action is clear. What if an update affects a thousand records? What message do you want to send to SAS? One thousand update statements? One update statement?
There are better ways to do this but a complete answer needs more details from you as to the end goal and business logic involved. Some ways I have used include:
trigger inserts data into an Oracle advanced queue. At predetermined intervals take the changes off the queue and write them to a flat file. Write a file watcher to look for the files and send the info to SAS.
write a Java program to take the changes and ship them
use the APEX web service and expose the changes as a series of JSON or REST packets.

Suggest Event pattern design in database

Can anyone suggest a good event pattern design or framework for changes in table in oracle.
Changes are not just the based on the column value change,but also the business driven logic .All the logging should be driven by some event setup.
At the end we track the changes and drive the business logic based on the changes .
I might be talking too high level,sorry for that :)
Assume TableA needs to be tracked for ColumnA.
Create AUDIT_TRAIL Table with columns TABLENAME, COLUMNNAME, OLDVALUE,NEWVALUE, DATEANDTIME, PK_SEQ
Create a Trigger to poll TableA for any change in ColumnA, and insert them into AUDIT_TRAIL (PK_SEQ should be a Oracle Sequence Number, DATEANDTIME should be from sysdate)
Something like this for trigger
CREATE OR REPLACE TRIGGER trg_table_audit
before insert or update or delete on tableA REFERENCING NEW AS NEW OLD AS OLD
for each row
begin
if inserting or deleting then
insert into audittrail (....)
Reading the fine manual: Using Triggers to Write Audit Data to a Separate Table:
You can use triggers to supplement the built-in auditing features of Oracle Database. The trigger that you create records user actions to a separate database table. When an activity fires the trigger, the trigger records the action in this table. Triggers are useful when you want to record customized information such as before-and-after changes to a table.
Reading even more the fine manual: PL/SQL Triggers:
A trigger is like a stored procedure that Oracle Database invokes automatically whenever a specified event occurs.
On top of that you can build a setup engine that turns triggers on and off. The "business logic" can later read the data recorded by the triggers.
I assume you're not interested in auditing. For the details see e.g. Verifying Security Access with Auditing.
How about you start with using TRIGGERS? And then from there, you could call procedures/functions from a package body for tracking the changes on the table/s.

Update actions from one sql table to another using Message Broker

i wanna use Wepshoere Message Broker to get the actions that any user perform on any table to be applied on another table
Example
1- User insert a record on Table x in TestDB
2- Message broker take this newly added record and add it to Table y in TestDB
could you support me with detailed information. and thanks in advance
I suggest you instead add an insert trigger to Table x, this is a normal function for database triggers.
It would help if you update your question with the DBMS and OS you are using.
You could approach this using a dbInput node to fire a message when the table is updated and then use normal ESQL or the mapping node to do the insert in the target table.
The key thing is going to be configuring your db input node correctly, you can get more info on how to do that here:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/bc34041_.htm

Resources