Function and triggers and procedures
sorry to asking this question,
In oracle. we use the function and triggers and procedure.
for eg:
if we wrote an trigger for a table. it fires at a time manipulating table. (database contains table contains datas and database also contains triggers likewise function,procedure).
but my questions?: is
In my database I kept only tables. no triggers,no function,no procedures. and
i dont want to kept this triggers, function, procedures in database Instead of i want to kept this triggers, function, procedures in business logic layers(middle tier)
is it possible? .
if yes means, how to write or where to write? please help me, or else send the guidance documents or blog releated to it.
Subu123,
the +1 related to Would be great if you can take step back and see the implementation from another angle. First see why do you need DB trigger/function etc.Then check whether it is possible to implement the functionality using ADF BC + feasibility study between 2 approaches(I didn't mean to invoke DB objects from business components, instead checking the feasibility of implement the same functionality in your EntityObj/ViewObj/Service calls )Before making a decision for or against holding fuctions, triggers and procedures in the DB, you have to get the whole picture.
Think about a trigger outside the DB. What could this be and why or for what is it used?
All the answers are pointing to 'lets keep them in the DB'. Now there are situation where you don't have a DB or are not allows to use it. Still there can be triggers, only they are implemented in a different way.
The same can be said for procedures and functions.
So you have to think about the whole problem and how each sub problem you have to solve work together to resolve the whole problem.
I'm personally tend to keep the business logic the the DB if the business logic is already there (e.g. I have to migrate an old forms app).
If I design a new app I tend to keep the logic in java. Only sequences (for generating ids) and some other stuff which is purely db related like cleaning up tables I keep in the DB.
Timo
Similar Messages
-
Read access to procedures,function,packages and triggers
Hi,
I created a user with CREATE SESSION,SELECT ANY TABLE privilege. My objective is to create a user with read only access to other schemas. But the newly created user is not able to read procedures,function,packages and triggers. The new user need read access to procedures,function,packages and triggers. What is the priviege required for this access? Please help me to resolve this issue.
Regards,
Mat.Hi,
Grant select all will give select privileges to all schema level objects except procedures,function,packages and triggers. But I need to grant read privileges on these objects to newly created user.
Regards,
Mat. -
Stored Procedures, Triggers and Functions
Can someone tell me the name of the table(s) in which procedures, functions and triggers are stored?
Procedure and function in USER_SOURCE
triggers in USER_TRIGGERS
Can someone tell me the name of the table(s) in which procedures, functions and triggers are stored? -
Java stored procedures and triggers in lite
Hi
We are using java stored procedures and java triggers in our application for oracle lite database 5.1.
We would like to know whether these procedures and triggers are uploaded or associated with tables or not because triggers are not being fired for the tables.
The question is - how to find the uploaded procedures and triggers in system tables.
We dont find any tables like (all_objects, user_objects) for this in oracle lite system catalogs given in the documentation.
thanks in advance
yugandharI don't have much experience with Lite, but I'm running 9i Personal Edition. Any information about triggers can be found in the "ALL_TRIGGERS" view. You will want to filter out any rows where OWNER = 'SYS' unless you created your triggers as SYS. As for procedures and functions, you can see what you have created in the "ALL_OBJECTS" view where OBJECT_TYPE = 'PROCEDURE' or 'FUNCTION', once again filtering out rows where OWNER = 'SYS'. To see the code of any procedure or function, select substr(text,1,80) from ALL_SOURCE where NAME = 'function name' ORDER BY LINE.
Hope this helps! -
Calculate the total value of payments with the procedures and triggers?
Hello!
I work for a college project and I have a big problem because professor requires to do it by the examples he gives during the lecture. Here's an example that should be applied to its base, so please help!
I have three table with that should work:
Invoice (#number_of_invoices, date, comm, total_payment, number_of_customer, number_of_dispatch)
where:
number_of_invoices primary key (number),
date (date),
comm (var2),
total_payment is UDT (din - currency in my country) - in this field should be entered value is calculated
number_of_customer and number_of_dispatch (number) are foreign keys and they are not relevant for this example
Invoice_items (#serial_number, #number_of_invoices, quantity, pin)
serial_number primary key (number),
number_of_invoices primary key (number),
quantity (number),
pin foreign keys (number)
Item (#pin, name, price, tax, price_plus_tax)
pin primary key (number),
name (var2),
price, tax, UDT (din) not relevant for this example
price_plus_tax UDT (din)
These are the triggers and procedures with my calculation should be done:
trigger1:
CREATE OR REPLACE TRIGGER "trg1"
BEFORE INSERT OR UPDATE OR DELETE ON Invoice_items
FOR EACH ROW
BEGIN
IF (INSERTING OR UPDATING)
THEN
BEGIN Invoice_items.number_of_invoices := :NEW.number_of_invoices; END;
ELSE
BEGIN Invoice_items.number_of_invoices :=: OLD.number_of_invoices; END;
END IF;
END;trigger2:
CREATE OR REPLACE TRIGGER "trg2"
AFTER INSERT OR UPDATE OR DELETE ON Invoice_items
DECLARE
doc NUMBER := Invoice_items.number_of_invoices;
BEGIN
entire_payment (doc);
END;procedure
CREATE OR REPLACE PROCEDURE "entire_payment" (code_of_doc IN NUMBER) AS
entire NUMBER := 0;
BEGIN
SELECT SUM (a.price_plus_tax * i.quantity) INTO entire
FROM Item a join Invoice_items i on (a.pin = i.pin)
WHERE number_of_invoices = code_of_doc;
UPDATE Invoice
SET total_payment = entire
WHERE number_of_invoices = code_of_doc;
END;As you can see the procedure is called from the triggers, I have a problem at the first trigger, and I think it will be even higher in procedure because UDT, field "total_payment".I was not here a few days because I was trying to get additional information related to this problem. Professor gave me the information that I need to introduce a package and variable to get this thing work. But including that I still have problem. I hope that this time is less of a problem and that someone will be able to help me.
I also noticed that it was not a smart idea to try to translate the names of tables and attributes. That make trouble for me, especially you who are trying to understand and to help me, and absolutely nothing that will change the attribute and the table name will be. So this time I will set out the problem with the original name again to avoid confusion.
So, I try to base Implement optimization technique called: Repeating Single Detail with Master (so writes the slides that I received from professor, I hope that will mean something to you)
These are the lines of code that we get on the slides and should implement in the base, again I remind you that at this time in its original form, without translation.
- First create the package variable:
create or replace
package paket
AS
sifra number(10):=0;
end;This part is ok and it works.
- Secondly, it is necessary to create the first trigger:
create or replace
TRIGGER aktuelna_cena1
BEFORE INSERT OR UPDATE OR DELETE ON cena_artikla
FOR EACH ROW
BEGIN
IF (INSERTING OR UPDATING)
THEN
BEGIN paket.sifra := :NEW.sifra_artikla; END;
ELSE
BEGIN paket.sifra := :OLD.sifra_artikla; END;
END IF;
END;This part is ok and working.
Now the problems begin.
- It is necessary to create another trigger that will call the procedure:
create or replace
TRIGGER aktuelna_cena2
AFTER INSERT OR UPDATE OR DELETE ON cena_artikla
DECLARE
s NUMBER := paket.sifra;
BEGIN
aktuelnacena (s);
END;I suppose the trigger have problem because procedure is not ok.
I will copy error that I get from the compiler:
Error(7,2): PL/SQL: Statement ignored
Error(7,2): PLS-00905: object NUMBER6.AKTUELNACENA is invalid
And finally, it is necessary to create the procedure:
create or replace
PROCEDURE aktuelnacena (SifraPro IN NUMBER) AS
aktCena artikal.aktuelna_cena%type;
BEGIN aktCena:=0;
SELECT cena INTO aktCena
FROM cena_artikla
WHERE sifra_artikla=SifraPro and datum_od=
(select max(datum_od)
from cena_artikla
where sifra_artikla = SifraPro and datum_od<=sysdate);
UPDATE artikal
SET aktuelna_cena = aktCena
WHERE sifra_artikla = SifraPro;
END;I will copy error that I get from the compiler:
Error(10,57): PLS-00103: Encountered the symbol " " when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge The symbol " " was ignored.
Tables I work with are:
Artikal (sifra_artikla, naziv, aktuelna_cena),
Cena_artikla (sifra_artikla, datum_od, cena)
You will notice that this differs from the first problem, but my task is to implement the two optimization techniques and my base. Both techniques are quite similar and I hope that I now have enough information to help me. I suppose that when this problem is solved the othet one will too!
Thank in advance! -
Wrapped in a function and/or stored procedure, recursive CTE stops working
This query builds an hierarchical tree from a single table with the typical
value/reports_to_value columns.
When running in SQL manager returns like 7 records (note i'm avoiding infinite
loop by blocking top level value)
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = '18538'
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
where t.deptid <> '00001'
SELECT deptid
FROM c
However, the exact same query, if wrapped in a function and/or stored procedure,
returns 0 records (no error message whatsoever)
CREATE FUNCTION [dbo].[checkDept] (@deptid varchar(16))
RETURNS TABLE
AS
RETURN
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = @deptid
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
SELECT deptid
FROM c
GO
CREATE PROCEDURE [dbo].[getDept] (@deptid varchar(16))
AS
SELECT deptid
FROM dbo.checkDept(@deptid)
Then call them like:
select * FROM checkDept('18538')exec getDept @deptid='18538'
Both return nothingThanks Patrick, i don't think it can do that, i call it like:
select * FROM checkDept('18538')exec getDept @deptid='18538'Just to make sure, i've changed the function like:WHERE ltrim(rtrim(deptid)) = @deptidStill the same thing -
Java Stored Procedures and Triggers
I want to to use Java stored procedures and triggers within the Oracle 11g XE
So please , someone can help me because i tried but it didn't work
I don't know where is the problem
Thanks !!WRONG FORUM!
Welcome to the forum but this forum is for Java JDBC questions and issues. Your question should be posted in the SQL and PL/SQL forum
PL/SQL
>
I want to to use Java stored procedures and triggers within the Oracle 11g XE
So please , someone can help me because i tried but it didn't work
I don't know where is the problem
>
Mark this question ANSWERED and repost the question in the other forum
Before you post review the Oracle Database Java Developer's Guide - it shows how to create Java stored procedures and has example code
http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
And in the new post don't just say "I tried but it didn't work". You need to post the code that you tried and what you mean by "didn't work".
If you got any exceptions or errors you need to post a copy of the exact message or error that you are getting. -
Can i use Stored procedures and triggers with SDK
hi all
How to use the stored procedure and Triggers with SDK, can i get a sample code
Regards
SalahHi, Salah.
Use "Exec" in your query to run procedures.
SAPbobsCOM.Recordset oRS;
oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
oRS.DoQuery ("EXEC YourStoredProcName");
Triggers are not supported in SDK.
Regards,
Aleksey -
AS EXPORT TABLES, PROCEDURES, AND TRIGGERS MORE?
Hi,
I've finished my application on Oracle XE, and make the export of Workspace, the Scheme, then
and export tables, procedures, triggers, etc, from Oracle XE to install on another computer?
I appreciate your partnership and Attention ...
Reynel Salazar Martinez ...por la parte de utilidades se genera la opcion
ddl...
y listo -
Triggers, Stored Procedures and Java
Hi all.
I started developing some useful (at least for me) Java Package, and I'm wondering if I'm doing the right thing.
Let's say that I have a trigger that calls a Stored Procedure that calls a Java Package.
Let's say that the Java Package can be used by more than one Oracle Schema.
So, my question is:
Should I load the package in every Schema ? Or should I load the package in the System (for instance) schema, creating synonyms for it (if possible) ? Or should I create both the package and the Stored Procedure in System, creating synonyms for the procedure ?
I'm a little stuck in this....
Another question : when my trigger fires, it launch the Stored Procedure and, consequently, my Java Package.... At this point, am I in the same transaction of the trigger ? Or the Java Package start a new "subtransaction" ?
Thanks in advance for Your help.
Best Regards
Fabio GRANDEDo not create anything in the System schema. Create the package and procedure in one schema and create a public synonym that the other schemas can use to access it.
And yes the trigger and anything it executes are all part of the same transaction. As long as none of the procedures are declared as an autonomous transaction, in which case that procedure would be a separate transaction. -
Restrictive and non-restrictive procedures!
Hi all,
Wanted to knwo what are restrictive and non-restrictive procedures in oracle forms.
Thanks and RegardsI think where Frank said "one-time triggers" he meant "non_repeating TIMERS".
Here is an alternative way to get around the restricted built-in problem which does not seem to be widely known:
Create two numeric control fields, say TRIGGERING_FIELD and TRIGGERED_FIELD.
TRIGGERED_FIELD has a formula calculation property of
MY_FUNCTION(:TRIGGERING_FIELD)
MY_FUNCTION is created in the form program units and can do anything you want, including restricted built-ins. The value it actually returns is irrelevant (although you could use it as a return code if you want).
Then all you need to do is modify the value of TRIGGERING_FIELD (perhaps multiply it by -1 ) which you can do in a trigger that does not allow restricted built-ins. The calculation will see that its input parameter has changed and will recalculate, thus running the function and doing all the restricted stuff. -
Difference between IS and AS in procedure?
difference between IS and AS in procedure?
prakash wrote:
hi,
http://www.oracle.com/pls/db111/portal.portal_db?selected=5&frame=#sql_and_pl_sql_languages
Here you get everything ..
functionality wise there is no difference between IS , AS of a procedure .
Thanks,
P PrakashI think oracle document do not talk about the Difference or No Difference between IS and AS. So i feel this is not a question that need to be pointed to the document.
To OP
Basically as others said there is no difference between them. They are just gramatical representation.
For example when i create a standalone stored procedure i tend to use AS and when i create a procedure inside a package i tend to use IS. Its just the choice you can make. -
Every time I try to upload a video to youtube or a pictures to a blog service, such as tumblr, I am unable to do so with the default uploading options (usually something that allows multiple uploads, etc). Instead, I can upload these media using their "basic upload" functions. Why and what can be done?
== URL of affected sites ==
http://www.youtube.com; http://www.tumblr.comPlease read this whole message before doing anything.
This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
Test while in safe mode. Same problem?
After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test. -
Problem using TAPI triggers and merge statement
Hi,
I use Designer tapi triggers on a table. When I try to execute a merge statement, I get the following error:
ORA-06502: PL/SQL: numeric or value error: NULL index table key value.
Is there a restriction when using TAPI triggers and merge statements that anyone is aware of?No restrictions on MERGE commands that I know of. I have, however, seen the TAPI give inexplicable ORA-06502 errors. It would help to know what line in which procedure or trigger gave the error. That information should have been in the error stack.
-
Data logging optimization function in LabVIEW and SignalExpress
Hello, everyone! I and a colleague have assembled the attached VI,
which is used to control a plant growth chamber, and I could use some advice.
I would like to add data logging capabilities, ideally to note (1)
environmental conditions, such as temp and CO2 level and (2) when certain
situations occur, such as high CO2 or low pressure (which results in a change
to the “Case Structure for CO2 and Pressure”).
The chamber runs for weeks at a time, though, so I have a constraint.
Instead of continuously logging all the environmental data (which would yield
giant file sizes), I want to be able to take “snapshots”, say every 5 minutes,
so I can examine the chamber’s condition over a long period of time.
I attempted to use the Time Delay function to control the Write Measurements
function (as in LabVIEW’s Cycle Analysis example, which I’ve also attached),
but Time Delay halted my entire program.
I also tried the Wait (ms) function, but had no success.
I recently discovered the powerful data review and reporting tools that
SignalExpress has to offer. Ideally, I
would like to use a SignalExpress express VI to record the measurements instead of the more primative Write Measurements, but, I’m not sure how to implement this in my VI. For example, would I make a data acquisition VI in SignalExpress for all my sensors, export to LabVIEW, and use that to replace the current DAQ structure in my VI? (Because the chamber VI is interactive, I'm pretty sure that porting the LabVIEW VI to SignalExpress wouldn't work out well.) And I’m
still not sure how to control how often it records measurements.
Any advice would be much appreciated!
Attachments:
Chamber VI.vi 789 KB
Cycle Analysis.vi 300 KBHi, Sarah. Yes I definitely plan to use LabVIEW for the majority of my data acquisition and logging. I apologize, I think I probably should have broken my post into two separate posts for clarity, as my major concern is being able to set how often LabVIEW logs the environmental data (viewing the logged data in SignalExpress would be nice, but not a requirement).
As I explained before, I'd really like to be able to set up a system that records the environmental condtions at regular time intervals, say every 30 minutes, or if my "Case Structure for CO2 and Pressure" status changes (such as from "Normal Conditions" to "High CO2".
As an example, attached is a boolean structure (TimedWritedMeasurements.vi) that I came up with to record a simulated signal every 5 seconds (5000 ms). Once I can get it to work, I would connect the boolean to my environmental sensor outputs and CO2 and Pressure case structure in my Chamber VI.vi that I attached in my first post.
My problem is I can't seem to get the Trigger and Gate function to work the way I'd like. I'd like the Wait (ms) function to trigger the Trigger and Gate function every 5 seconds to change the case structure in the TimedWriteMeasurements.vi to "True", thereby causing the Write Measurement function to record the environmental conditions. Then I'd like the case structure reset to false, until it's triggered to true in another five seconds. Can anyone point me in the right direction?
Attachments:
TimedWriteMeasurements.vi 84 KB
Maybe you are looking for
-
Java with Derby embedded and threads - problem?
Hello, been developing java app and recently switched to derby database. At first i insert some data into derby and my app populates fine. However when my app creates a new thread (to do something in background and then updates the derby database) it
-
Everytime I hook my Iphone 5 to itunes it wants me to restore the phone. I got a new phone two days ago because of this and other issues came home and went to put my music on it and it wanted me to restore which it resulted in a frozen screen with th
-
New and need HELP!!!
I bought my daughter a Nano for Christmas. I plugged it into my itunes for my shuffle. I cannot get her's to do anything. I can't get the setup assistant to work for hers. Can someone please walk me through this? Thanks.
-
Re: Battery Drains Faster in iOS 5 ?
Hello, I have marked that Battery drain faster if using apps in iOS 5 then the previous version, but the idle time is better in iOS 5. In my case after fully charged, my phone show 100% if its in idle mode for 7 hours, but as soon as i start some ap
-
system gets hanged always. Shifted from pc to apple because of this reason and same happens.