Creating a trigger in Portal
I'm trying to create a trigger in Portal using the Wizard with the code below. It will not compile. Any ideas on why?
Thank you,
Sam
DECLARE
next_chemical_id msds.chemicals.id%TYPE;
BEGIN
SELECT chem_id.NEXTVAL
INTO next_chemical_id
FROM dual;
:chemicals.id := next_chemical_id;
END;
null
try creating the same trigger through SQL Plus. If you are able to create and not able to create through portal them pls post the correct error message with portal version.
Thanx,
Chetan.
Similar Messages
-
How do we create a vendor using portal?
how do we create a vendor using portal.
creation process needs to trigger workflow.
SonaliYou need to use WLST online. I am not sure what your exact requirements are but one good way of working this is to have a WLST script that deletes all your WL customisations, like connection pools, JMS Servers etc and then creates it. That way you can run the same script repeatedly and it will get everything up to date for you. However you have to remember that everytime you add something new you need to update your delete section. Also your deleting should not fail if the item does not exist. I hope that makes sense!
As to the specifics of WLST examples to do this then check out the WLST examples in CodeShare.
If you are still having issues then post another message.
Geoff -
Create a trigger to check inserted date is before or after SYSDATE
Hi,
I am trying to create a trigger that will check an inserted date against SYSDATE and alter the value (i.e. make it SYSDATE) when the entered date is incorrect.
For example, I have a Customer table with a record named MemberDate which, when a date is entered to it, will be checked by the trigger to ensure it is not before the current date.
My code so far;
CREATE OR REPLACE TRIGGER Customer
BEFORE INSERT ON
Customer
FOR EACH ROW
DECLARE
e_invaliddate_ud EXCEPTION;
BEGIN
IF :NEW.MemberDate < SYSDATE THEN
RAISE e_invaliddate_ud;
END IF;
EXCEPTION
WHEN e_invaliddate_ud THEN
DBMS_OUTPUT.PUT_LINE('The date entered for MemberDate is invalid. The
MemberDate has been set to the current date');
END;
So far, this trigger only returns an error message but allows the date to be entered even if it is incorrect. I have tried a few ways of altering the entered date to SYSDATE but to no avail.
I am running scripts using SQL PLUS and inserting data using
INSERT INTO Customer
VALUES(CustomerID, ..., MemberDate);
Where the values entered will be checked to ensure the MemberDate is not before SYSDATE.
The MemberDate data-type is DATE and has a rule that it must not be before the current date. I am aware that a constraint may not be used to perform a check using SYSDATE, this is why I am trying to make a trigger.
However, my knowledge of triggers is limited
If anyone can help, I will be very Happy.
Thank you in advance.Use this if you want an error message that halts the execution:
create or replace trigger customer
before insert on customer
for each row
begin
if :new.memberdate < sysdate
then
raise_application_error(-20000,'The date entered for MemberDate is invalid.');
end if;
end;Use this if you want to automatically to overwrite the MemberDate with sysdate without an error message:
create or replace trigger customer
before insert on customer
for each row
begin
:new.memberdate := greatest(sysdate,:new.memberdate);
end;Note: untested
Regards,
Rob. -
i am creating a trigger i am getting an error
create or replace TRIGGER INS_Discharge
AFTER INSERT
ON Discharge
FOR EACH ROW
AS
declare
vr_DischargeType INT ;
vr_Visit_ID INT ;
vr_Discharge_Date DATE;
vr_VisitDate DATE;
vr_AdmTime varchar(5) ;
vr_TransferID INT ;
vr_BedID AS INT ;
BEGIN
select :NEW.DischargeType into vr_DischargeType
from dual;
select :NEW.Discharge_Date into vr_Discharge_Date
from dual;
select :NEW.VisitDate into vr_VisitDate
from dual;
SELECT VisitDate into vr_VisitDate FROM Visit WHERE Visit_ID = vr_Visit_ID ;
UPDATE Visit SET DischargeType = vr_DischargeType, DischargeDate = vr_Discharge_Date
WHERE Visit_ID = vr_Visit_ID ;
SELECT MAX(Transfer_ID)into vr_TransferID FROM BedSchedule WHERE VisitID = vr_Visit_ID ;
IF vr_DischargeType = 2 then
SELECT Bed_ID into vr_BedID FROM BedSchedule WHERE Transfer_ID = vr_TransferID ;
UPDATE Bed_Mst SET Bed_Status_ID = 1 WHERE Bed_ID = vr_BedID ;
:NEW.Bed_ID :=vr_BedID;
end if;
END ;
Error report:
ORA-04079: invalid trigger specification
04079. 00000 - "invalid trigger specification"
*Cause: The create TRIGGER statement is invalid.
*Action: Check the statement for correct syntax.i have done you said .... i have oracle version 10g
create or replace TRIGGER trUPD_Discharge
AFTER UPDATE
ON Discharge
for each row
AS
declare
vr_DischargeType INT ;
vr_Discharge_Date DATE;
vr_Visit_ID INT ;
vr_CancelStatus INt;
BEGIN
/*select :NEW.DischargeType into vr_DischargeType from dual;
select :NEW.Visit_ID into vr_Visit_ID from dual;
select :NEW.Discharge_Date into vr_Discharge_Date from dual;
select nvl((select :NEW.CancelStatus from dual),0)
into vr_CancelStatus from dual;
If vr_CancelStatus = 0 then
UPDATE Visit SET DischargeType = :NEW.DischargeType,
DischargeDate =:NEW.Discharge_Date WHERE Visit_ID = :NEW.Visit_ID ;
end if;
END;
but still getting same error
Error report:
ORA-04079: invalid trigger specification
04079. 00000 - "invalid trigger specification"
*Cause: The create TRIGGER statement is invalid.
*Action: Check the statement for correct syntax. -
Creating users in enterprise portals with CUA as userbase
Hi All,
we are using CUA system for maintaining the users and we want this users to be used in enterprise portals. So while installing WebAs itself, we specified the connection details to this CUA system. then we installed portal and we were able to view the users of CUA in portal.
now i am creating a user from portal, create user option in UserManagement. but i just get an error like, could not create a user.
i checked out in system administration->umconfiguration-> sap system. all the details that we specified during the webas installation appear there by default.
so could you please let me know what the problem could be
thank youRaj,
I know that your problem was solved, but I've come across following SAP link. Hope, it helps other ppl..
TITLE: Requirements for Service User Used to Connect to SAP Systems
http://help.sap.com/saphelp_ep60sp2/helpdata/en/8f/67d27676ace84080964d4c4223bb3c/content.htm
Thanks,
Pritesh. -
Attribute error while creating shopping cart in portal
Hi,
We are using SRM 7.0 . While creating shopping cart in portal , I am getting error " the attribute of the user are inconsistent or not defined. See transaction ppoma_bbp "
I have maintained attributes of ACS,BSA,BUK,BWA,CUR,KNT,WGR & WRK . Done attribute check in BBP_ATTR_CHECK, it issued warning message for CAT attribute. All other attributes are Ok.
Could anybody help to resolve this.
Regards
AyyappanHI
Step 1: Check the consistency of the User for Shopping Cart using Transaction BBP_CHECK_CONSISTENCY. THis will give you a snapshot of what is missing in user's attributes for creating a SC.
Step 2. Go to PPOMA_BBP and note down the Position id and CP id of the user. Then check the consistency of these objects using BBP_BP_OM_INTEGRATE.
It seems the combination of attributes is not in right place for this user
Regards
Virender Singh -
How to create a trigger for particular value insertion?
If I have a Table T, which has columns as A,B,C,D. I want to create a trigger to give an error message if someone inserts or updates T with values in A as '001' AND value in B as '99'
Please reply soon....
Thanksuser8560155 wrote:
I need a trigger only not a constraint...
Why? Is there any valid reason for that?
I tried the above trigger but it was not successful :(
Can I use 'If statements' as well???The below will work..
create table t
a varchar2(10),
b varchar2(10),
c varchar2(10),
d varchar2(10)
create or replace trigger trig1
after insert or update on t
for each row
--"trigger will be fired only when below condition is satisfied"
when ( new.a = '001' or new.b = '99' )
begin
raise_application_error(-20000, 'Invalid value in A or B');
end;
insert into t(a) values('001');
SQL Error: ORA-20000: Invalid value in A or B
ORA-06512: at "SCOTT.TRIG1", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRIG1'
insert into t(a) values('002');
1 rows inserted. -
Whats this error while creating a trigger
HI ,
I was creating a trigger and getting the following Error . What is this
1 CREATE OR REPLACE TRIGGER TRG_AUDIT_LOGON AFTER
2 LOGON ON DATABASE
3 Declare
4 v_sid v$session.sid%type ;
5 v_serial v$session.serial# %type;
6 v_username v$session.username%type;
7 v_osuserid v$session.osuser%type;
8 v_machinename v$session.machine%type;
9 v_PROGRAM v$session.program%type;
10 v_TERMINAL v$session.terminal%type;
11 v_hostname v$instance.host_name%type;
12 v_instance_name v$instance.instance_name%type;
13 v_application_id v$database.dbid%type;
14 v_logon_time date;
15 v_Audit_tab_check varchar2(30);
16 v_system_users_tab_check varchar2(30);
17 v_sql_Audit_upload varchar2(1000) := 'INSERT INTO dbaoper.T_AUDIT (HOST_NAME, APPLICATION_ID, INSTANCE_NAME, SID, SERIAL#, USERNAME, OSUSERID, MACHINENAME, PROGRAM, TERMINAL, LOGON_TIME) VALUES (:v_hostname,:v_application_id,:v_instance_name, :v_sid, :v_serial, :v_username ,:v_osuserid,: v_machinename, :v_program,:v_TERMINAL,:v_logon_time ) ';
18 type c_audit_cur_typ is ref cursor;
19 C_Audit c_audit_cur_typ ;
20 V_system_users_tab := 'T_SYSTEM_USERS';
21 No_Audit_records Exception;
22 Begin
23 Select table_name into v_Audit_tab_check from dba_tables where owner='DBAOPER' and table_name='T_AUDIT';
24 Select table_name into v_system_users_tab_check from dba_tables where owner='DBAOPER' and table_name='T_SYSTEM_USERS';
25 Open c_Audit for ' SELECT sid, serial#, username, osuser, machine, program, terminal FROM v$session WHERE audsid = userenv (''''sessionid'''') and program not like ''''oracle@%J0%'''' and username not in (select * from dbaoper.' || V_system_users_tab||' ) and type!=''''BACKGROUND'''' ' ;
26 Fetch c_Audit into v_sid, v_serial, v_username, v_osuserid, v_machinename,v_program,v_TERMINAL ;
27 If c_Audit%Notfound then
28 Raise No_Audit_records ;
29 Else
30 Select host_name, instance_name into v_hostname, v_instance_name from v$instance;
31 select dbid into v_application_id from v$database;
32 select sysdate into v_logon_time from dual;
33 execute immediate v_sql_Audit_upload using v_hostname,v_application_id,v_instance_name,v_sid,v_serial,v_username,v_osuserid,v_machinename,v_program,v_TERMINAL,v_logon_time;
34 end if;
35 close C_Audit;
36 exception
37 when no_data_found then
38 dbms_system.ksdwrt(2, ' ORA-20001 Audit tables T_AUDIT or T_SYSTEM_USERS not found Audit information is not being captured'
39 );
40 When No_Audit_records then
41 dbms_output.put_line ('No Audit records to insert ');
42* end;
SQL> /
Warning: Trigger created with compilation errors.
SQL> sho err
Errors for TRIGGER TRG_AUDIT_LOGON:
LINE/COL ERROR
18/20 PLS-00103: Encountered the symbol "=" when expecting one of the
following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to
continue.
Thanks
PramodHi
I am sorry...i am getting the following error once trigger is created and one of the user is trying to connect....what might be the reason ?
Enter user-name: test
Enter password:
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-00907: missing right parenthesis
ORA-06512: at line 23
Thanks
Prmaod -
Help me in creating a Trigger for Insert and Update Options
Hi
Please help me in creating a Trigger .
My requirement is that after insert or update on a Table , i want to fire an event .
I have started this way ,but doesn't know how to fully implement this .
say i have a dept table
CREATE TRIGGER DepartmentTrigger
AFTER INSERT ON Dept
BEGIN
INSERT INTO mytable VALUES("123","Kiran");
END DepartmentTrigger;
Please tell me how can i put the Update option also .
Thanks in advance .Please tell me how can i put the Update option also .Add "Or Update". ;-)
Here are a few suggestions, but you definitely need to refer to the manual page that the previous poster suggested.
CREATE OR REPLACE TRIGGER DepartmentTrigger
AFTER INSERT Or Update ON Dept
BEGIN
INSERT INTO mytable VALUES(:new.Dept,'DEPT ADDED OR CHANGED');
END DepartmentTrigger;
The "Or Replace" means you can replace the trigger while you're developing without having to type in a drop statement every time. Just change and rerun your script, over and over until you get it right.
Adding "Or Update" or "Or Delete" makes the trigger fire for those events too. Note, you may want seperate triggers in different scripts and with different names for each event. You have to decide if your design really does the same thing whether it's an insert or an update.
:new.Dept is how you would refer to the changed vale of the Dept column (:old.Dept is the prior value). I changed the double quotes on the string in the VALUES clause to single quotes.
Andy -
Help needed in creating a trigger
hi,
I am creating a Trigger which keep track of the updates of a particular table.
Whenver a col value is updated i want to insert a row into newtable, with colname,old value and new value.
How do we get to know which col value is changed in a table?
ThanksI have seen the approach you propose (1 row for each column changed) and it is tedious and prone to maintenance headaches. You have to write code for each column, doing compares (remembering to consider NULLs), dealing with different datatypes, etc. You also have to decide how to record inserts and deletes.
An easier trigger-based solution is to create a history table for the table you want to track, with all of the columns from the original, plus whatever else you need for housekeeping. Write an After Insert/Update/Delete trigger on your base table, and populate/insert rows into the history table:
- For inserts, populate and insert row from the :new. values
- For deletes, populate and insert a row from the :old. values
- For updates, popualte and insert a row from the :old. values and another from the :new. values
I would also have a column to designate whether this is an Insert, Delete, Update-Old or Update-New row.
Once you have done one example, the rest are easy. If you were sufficiently motivated (I have not yet been), you could probably write a script to query DBA_TAB_COLS and generate the code. -
Need Help in creating this trigger
I need your help to create this trigger. I need to set the default fl in this table depending on various conditions:
If there is only one indvl with end date as null then set the default_pk column for that indvl as 'Y'
ELSE
If there are multiple indvl_pks in this table with NULL end date then set the default_fl column to 'Y' for the indvl_pk with the earliest start date .
ELSE if there are multiple indvls with same start date then set the dflt_fl to 'Y' with the minimum br_pk
I am unable to get this to work due to the mutating trigger problem.
For example in this one rows with emplt_pk with 1001 and 1003 will be set to 'Y'.
create table emplt
emplt_pk number,
indvl_pk number,
start_dt date,
end_dt date,
lct_fl char(1),
sup_fl char(1),
br_pk number,
nro_pk number,
default_fl
char(1) default 'N' );
INSERT
INTO emplt
values(1001, 101, to_date ('01-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N' ,123,NULL,NULL );
INSERT INTO emplt values(
1002, 101, to_date ('02-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N' ,NULL,0001,NULL );
INSERT INTO emplt values(
1003, 102, to_date ('02-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N' ,NULL,0001,NULL );
Thanks in advancethe Easy Tabs could be useful for your requirement
http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Easy-Tabs-v5.aspx
/blog
twttr @esjord -
Creating a Trigger and some Database Design
Here is the scenario, we have the following tables
Orders, OrderDetails, Products, ProductsToInventory, Inventory, and InventoryDetails
Orders is where the orders are saved and their details are in OrderDetails (orderdetails has a column called Type and that type can either be a product, inventory, shipping, fee, so that we can distinguish what each one is in the order)
Products are the products we sell and ProductsToInventory refers each product to the inventory items required for it.
Inventory lists the the name, size, and weight of the item
then InventoryDetails stores the cost, original quantity received, and the current quantity (since the company receives different quantities of the same product at different pricing all the time) (I would appreciate all the comments on this, this is
the best way I thought of doing this but if you have another way i'd appreciate it)
So that's the design, now we created a trigger that basically does this...
When an order is created and a PRODUCT is inserted into the the orderdetails, we will, using trigger, run the following query to insert the INVENTORY into the orderdetails
INSERT INTO OrderDetails (...., OrderDetailPrice)
SELECT ..., OrderDetailPrice?
FROM inserted i INNER JOIN ProductToInventories pt
ON i.productid = pt.id
INNER JOIN Inventories inv
ON pt.InventoryID = inv.InventoryID
LEFT JOIN InventoryDetails idet
ON inv.InventoryID = idet.InventoryDetailInventoryID
WHERE OrderDetailType = "PRODUCT"
This works perfectly fine, however... for the price, we don't know what to do here, since the price is not in the inventory, the price is under the inventorydetails and we will have to look up to that table to see which one has quantity > the quantity
needed here and then grab the price for that and then we need to update the quantity on that as well.Here is the scenario, we have the following tables
Orders, OrderDetails, Products, ProductsToInventory, Inventory, and InventoryDetails
Orders is where .....
Good day TheSQLNewb,
I did not read more than I quote above... This is a starting of a nice story :-) but in the forum and in DBA's life we prefer to get DDL+DML instead of stories.
Please post queries to create the relevant tables (this is DDL by the way), and queries to insert some sample data (DML). with this information we will be able to reproduce the tables in our server and work on them.
Thanks :-)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
I have a table that consists of the following: product_id number, location number, qty number. product_id and location are primary keys.
I want to create a trigger before an update and if the record doesn't exist that is trying to be updated, then I have to create the record.
For example, if I want to do an update of the following:
update inventory set qty = 80 where product_id=13 and location=45;
Let's say that the record doesn't exist, how do I do this with a trigger.Hi,
First of all i would like to clear one thing:
IF you are trying to update any record and that record does not exist in table then trigger will not be called.
"afiedt.buf" 10 lines, 236 characters
1 CREATE OR REPLACE TRIGGER t_trig
2 BEFORE UPDATE ON t
3 FOR EACH ROW
4 BEGIN
5 DBMS_OUTPUT.PUT_LINE('Trigger has been called!!!');
6 EXCEPTION
7 WHEN OTHERS THEN
8 DBMS_OUTPUT.PUT_LINE('IN EXCEPTION:'||SQLERRM);
9* END;
SQL>/
Trigger created.
SQL>DESC t;
Name Null? Type
NAME VARCHAR2(20)
SQL>SELECT * FROM t;
NAME
BBB
1 row selected.
SQL>SET SERVEROUTPUT ON
SQL>
SQL>UPDATE t SET NAME='XXX' WHERE name='AAA';
0 rows updated.
SQL>UPDATE t SET NAME='XXX' WHERE name='BBB';
Trigger has been called!!! <-- Trigger called here
1 row updated.So to achieve your result you have to do it outside the trigger.
If you are updating trougha a procedure, after update statement you can use SQL%ROWCOUNT to get how many rows have been updated. If it zero you can insert the record.
Regards -
Problem with creating new user in portal = portlet is not visible
Hi,
I've got a problem with creating new users in portal. In the Administer tab of the builder is the user portlet not visible.
How can I make this portlet visible?
Please Help
thank you...
GilbertHi..my problem slightly similar.
I created one new user, and didn't select anything from "Public Groups Assignment" and "Privilege Assignment" for him.
I expect the user will be a public user.
But, when he try to logged in the portal,
He cannot see all the PORTLETS related to database values..
All he can see just LINKS -that all in my portal right now beside the report from database that the user cannot see :)
So, what did i do wrong?
Plz Advise, and thanks. -
Is it possible to create a trigger with a trigger?
Hi,
I'd like to create an AFTER CREATE system trigger that will create a BEFORE INSERT trigger on a certain table once it is created.
Is this possible, or is there a better way? The problem I am having is that I'm getting an error when I put a trigger body inside a trigger body; the "/" is causing problems.You could create a prcoedure that is responsible for building the trigger body in a varchar2 and then issue an execute immediate on the string....and call it from your trigger.
Maybe you are looking for
-
I lost audio thru imac speakers and mic, what should i check?
-
Product category in ad-hoc Supplier Evaluation SRM 7.0
Hello all: we are implementing the ad-hoc Supplier Evaluation in SRM 7.0 using the Supplier Evaluation cockpit. We would like to know if there is any way to include the Product Category as attribute in the ad-hoc supplier evaluation so that we can de
-
How can I do a "RANKIFS"?
I'm getting to enjoy and understand Numbers' functions. But I can't always find what I need. I need a RANKIFS function that works in the same way as SUMIFS or COUNTIFS. Alternatively I might be able to build a workaround if there were any functions t
-
Holiday Calendar Iview-Opens with Logon Page
Hi All, We were using a.abc.com domain for our portal, then we changed to d.xyz.com. Everything works fine except the Holiday Calendar iview (under ESS-Working Time). It opens up with the logon page, once we login it takes us to the calendar screen,
-
I need some help re lines on start up screen.
Hi I have a mac pro 2.8 2 x quad processor running snow leopard. When I boot up horrible lines come up and wont start my mac. I have tried booting from cd/dvd but it freezes and wont let me start up. Don't know f disk is corrupt or if another hardwar