How to insert a value of triggers in the table?
Mr President.
I have the following trigger
CREATE OR REPLACE TRIGGER lineitem_trg BEFORE UPDATE OF lineitem ON voucherdet FOR EACH ROW BEGIN :NEW.LINEITEM := TO_CHAR ( TO_NUMBER (:OLD.LINEITEM) + 1 , 'FM00' ); END lineitem_trg; /
Now to how to add this triggers a value in the table
The value of this trigger is part of the primary key with voucher_id which is obtained by the voucher_id_seq
This is my database as below
CREATE TABLE "NOM" ( "ACCT_ID" VARCHAR2(7) NOT NULL ENABLE, "ACCT_NAME" VARCHAR2(50) NOT NULL ENABLE, "O_BAL" NUMBER(13,2), "ITAX_ID" VARCHAR2(7), "SALES_TAX_NO" VARCHAR2(20), "PL_SUPPLIER" VARCHAR2(1) DEFAULT 'N', "STOCK_REPORT" VARCHAR2(1) DEFAULT 'N', "ACCT_TYPE" VARCHAR2(4), CONSTRAINT NOM_PK PRIMARY KEY ("ACCT_ID")ENABLE, CONSTRAINT NOM_ACCT_TYPE_FK FOREIGN KEY ("ACCT_TYPE") REFERENCES "ACCT_TYPE" ("ACCT_TYPE") ENABLE ); CREATE TABLE "VOUCHER" ( "VOUCHER_ID" VARCHAR2(8) NOT NULL ENABLE, "VOUCHER_DATE" DATE DEFAULT sysdate, "POST_DATE" DATE DEFAULT sysdate, "DEBIT" VARCHAR2(7), "CREDIT" VARCHAR2(7), "VOUCHER_SOURCE" VARCHAR2(2), CONSTRAINT VOUCHER_PK PRIMARY KEY ("VOUCHER_ID")ENABLE, CONSTRAINT VOUCHER_NOM_DEBIT_FK FOREIGN KEY ("DEBIT") REFERENCES "NOM" ("ACCT_ID") ENABLE, CONSTRAINT VOUCHER_NOM_CREDIT_FK FOREIGN KEY ("CREDIT") REFERENCES "NOM" ("ACCT_ID") ENABLE ); CREATE TABLE "VOUCHERDET" ( "VOUCHER_ID" VARCHAR2(8) NOT NULL ENABLE, "DEBIT" VARCHAR2(7) NOT NULL ENABLE, "CREDIT" VARCHAR2(7) NOT NULL ENABLE, "PARTICULARS" VARCHAR2(100), "AMOUNT" NUMBER(21,2), "LINEITEM" VARCHAR2(4) DEFAULT '01', "V_ID_ITAX" VARCHAR2(11), "V_ID_PAY" VARCHAR2(11), "CHALLAN_NO" VARCHAR2(10), CONSTRAINT VOUCHERDET_PK PRIMARY KEY ("VOUCHER_ID", "LINEITEM")ENABLE, CONSTRAINT VOUCHERDET_DEBIT_FK FOREIGN KEY ("DEBIT") REFERENCES "NOM" ("ACCT_ID") ENABLE, CONSTRAINT VOUCHERDET_CREDIT_FK FOREIGN KEY ("CREDIT") REFERENCES "NOM" ("ACCT_ID") ENABLE, CONSTRAINT VOUCHERDET_VOUCHER_FK FOREIGN KEY ("VOUCHER_ID") REFERENCES "VOUCHER" ("VOUCHER_ID") ON DELETE CASCADE ENABLE );
CREATE SEQUENCE VOUCHER_ID_SEQ INCREMENT BY 1 START WITH 1; begin execute immediate 'create or replace trigger VOUCHER_ID_TRG '||chr(10)|| ' before insert on "ALIZA"."VOUCHER" '||chr(10)|| ' for each row '||chr(10)|| 'begin '||chr(10)|| ' if inserting then '||chr(10)|| ' if :NEW."VOUCHER_ID" is null then '||chr(10)|| ' select VOUCHER_ID_SEQ.nextval into :NEW."VOUCHER_ID" from dual; '||chr(10)|| ' end if; '||chr(10)|| ' end if; '||chr(10)|| 'end;'||chr(10); end; /
Concerning
And I explained to you why it is false.
Go one read what I put above, and I gave an example of (with command and control elements) in the other thread.
If you want the user a composite key as the primary key by using the primary key of the voucher and something else, do this thing, just a sequence that is obtained from a sequence value (not gapless, but always unique). And then you always build your LINEITEM values for display based on this sequence for example
LPAD (to_char (ROW_NUMBER () over (partition by order VOUCHER_ID by LINEITEM)), 2, '0') as a CONTROL element
It's when you query the data to display it, is not to store it in the database. In the database, you simply store an internal sequence number in LINEITEM.
Do not try and store a sequence for your lineitem gapless. It is false.
Tags: Database
Similar Questions
-
How can insert different types of data in the table?
Hello
How can I insert different types of data in the table, (e.g., numeric and string) in the same index of a table.example:
index0 car 10 greencar red 11 index1
Index2 car Blue 12where green car red and blue car as string and 10, 11 and 12 in the numeric form.
then I extracted 10, 11 and 12 a digital tableand, the green car, red car, blue car in a string array
Help!
Use 'Analysis of the chain' as in the picture as an attachment. This will extract the number and color that you can add tables later.
-
How to generate a value of 0 if the table does not value contain?
Hello
I have a nice select gives me these results:
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:01 36.6 01/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:02 63.4 02/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:03 73.2 03/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:04 78.6 04/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:05 98.8 05/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:06 2008-06-30.4
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:07 23.8 07/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:08 70.8 08/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:09 14 2008-09
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:10 60.4 10/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:11 46 11/2008
You see, the month 12 is missing, because no data exists in the table. OK, that's normal.
But I want to display the result 0 even if nothing in the table for the month 12. The result would be:
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:01 36.6 01/2008
etc...
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:11 46 11/2008
f? p =: 2::GET_DETAIL_REPORT:NO:P2_VALUE:12 0 2008-11
I know that I have to generate a list of values for each month and join them.
Could you please help me this?select add_months(to_date('01'||:P2_DATE_DEBUT, 'mm/yyyy'), level-1) dt from dual connect by level <= 12
It's nice select I already have.
Kind regardsSELECT 'f?p=&APP_ID.:2:&SESSION.:GET_DETAIL_REPORT:NO::P2_VALUE:' || TO_CHAR(TRUNC(date1, 'MM'), 'MM') LINK, To_CHAR(TRUNC(DATE1, 'MM'), 'MM/YYYY') valeur, sum(valeur) "Cumul" FROM PL_MF_JOUR WHERE cle = :P2_DEPT AND DATE1 BETWEEN to_date('01/01' || :P2_DATE_DEBUT || ' 00:00:00', 'DD/MM/YYYY HH24:MI:SS') AND to_date('01/01' || :P2_DATE_DEBUT || ' 23:59:59', 'DD/MM/YYYY HH24:MI:SS') +364 GROUP BY TRUNC(DATE1, 'MM') ORDER BY TRUNC(DATE1, 'MM')
Christian
PS: your help is very appreciated every time, thank you.You need to generate your calendar of 12 months and then left outer join with it.
Something like:
WITH dts as (select to_date('01/'to_char(rownum,'fm99')||'/'||:P2_DATE_DEBUT,'DD/MM/YYYY') as dt from dual connect by rownum <= 12) SELECT 'f?p=&APP_ID.:2:&SESSION.:GET_DETAIL_REPORT:NO::P2_VALUE:' || TO_CHAR(dt, 'MM') LINK, TO_CHAR(dt, 'MM/YYYY') valeur, sum(valeur) "Cumul" FROM dts LEFT OUTER JOIN PL_MF_JOUR ON (dt = TRUNC(DATE1,'MM') AND cle = :P2_DEPT AND DATE1 BETWEEN to_date('01/01' || :P2_DATE_DEBUT || ' 00:00:00', 'DD/MM/YYYY HH24:MI:SS') AND to_date('01/01' || :P2_DATE_DEBUT || ' 23:59:59', 'DD/MM/YYYY HH24:MI:SS')+364 ) GROUP BY dt ORDER BY dt
NB. Untested (obviously)
-
Please how can I insert a value of richinputtext in the database string attribute
Please how can I insert a value of richinputtext in the database string attribute
If you can get its value at the bean and then call your insert statement to put it in the DB table
and if you want to know about the execution of SQL query
then check - Ashish Awasthi (Jdev/ADF) Blog: SQL to run in an ADF Application using DataSource DBTransaction & JDBC query
Ashish
-
Hello:
How to configure contextual events publish several values of payload?
On click of a button, I'm declaritively publish a contextual event, which works very well when a single value is passed to the event handler.
My event handler method has the signature of:
eventHandler (String)
But now I also have an oracle.jbo.domain.Number, so my new eventHandler looks like this:
eventHandler (Number, String)
How to pass two values during editing of the event and how to place the payload with multiple values for the new eventHandler?
All article or code would be greatly appreciated.
Thanks for the help.You define a bean holding your values and pass an instance of the bean as a payload...
Timo
-
Hi all
Try inserting dbms_output. PUT_line ('hi') in the table.
DOF of the table is:
create table test_result (tab varchar2 (30), varchar2 (2000)) of the State;
The code is:
DECLARE
A1 VARCHAR2 (1000);
BEGIN
A1: = dbms_output. PUT_line ('hi');
INSERT INTO test_result VALUES ('PRASAD', dbms_output. PUT_line ('hi'));
END;
Get the error message like:
Error from the 1 in the command line:
DECLARE
A1 VARCHAR2 (1000);
BEGIN
A1: = dbms_output. PUT_line ('hi');
INSERT INTO test_result VALUES ('PRASAD', dbms_output. PUT_line ('hi'));
END;
Error report:
ORA-06550: line 4, column 8:
PLS-00222: no function with name 'PUT_LINE' does exist in this scope
ORA-06550: line 4, column 2:
PL/SQL: Statement ignored
ORA-06550: line 5, column 53:
PL/SQL: ORA-00904: invalid identifier
ORA-06550: line 5, column 1:
PL/SQL: SQL statement ignored
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error.
* Action:
Thanks in advance.If you try to capture the data of the output as DBMS_OUTPUT buffer. Put_line written to, then you must use the procedure GET_LINE in the same package.
for example
SQL> ed Wrote file afiedt.buf 1 DECLARE 2 A1 VARCHAR2(1000); 3 status number; 4 BEGIN 5 dbms_output.enable; 6 dbms_output.PUT_line('hi') ; 7 dbms_output.get_line(a1, status); 8 INSERT INTO test_result VALUES('PRASAD',a1); 9* END; SQL> / PL/SQL procedure successfully completed. SQL> select * from test_result; X Y ---------- ---------- PRASAD hi SQL>
-
How to insert a value obtained from pageContext.
Dear friends,
I value from URL, and I get by using pageContext.getparamter (), now, I want this value
to insert in a table attached to the same page.
How can this be achieved? Please share your ideas.
NOTE: I use insert EO.
Thanks in advance,
HadCapture the data and the attribute VO in which you want to save, and set its value. Here's the dummy code, you can refer:
String v_projNumber = pageContext.getparamter ();
OAViewObject vo = (OAViewObject) am.findViewObject ("XXViewObject");
If (vo! = null)
{
vo.getCurrentRow () .setAttribute ("projectNumber", v_projNumber);
}A question, if you want to save this value in a Table view attribute, then will fill the same value for all the lines in this region of the table.
The code above is not for the region of the table. For the table, you will need to loop through the line of VO and having to return to the selected line and setAttribute it.
Thank you
-Anil
http://oracleanil.blogspot.com/ -
How to insert duplicate values in another table.
angle of attack!
I created two tables a and b
create table one
(key primary code number);
create table b
(code number,
DAT date);
insert into the table of a (code)
values (1234);
insert into the table of a (code)
values (1235);
commit;
Select * from a;
one
-----
1234
1235
-----
insert into the table of a (code)
values (1234);
commit;
ERROR on line 1:
ORA-00001: unique constraint (GMS. SYS_C0030897) violated
{color: #ff0000} * I need, when the user inserts duplicate data, must be inserted into another table b.* {color}
How can I do in forms 6i? Help, please. Thanks in advance.
Hello
What is the relationship with the forms?
Anyway, you can create a trigger on table A that intercepts the error in an exception block, and then create a new row in table B.
If the error comes from a forms based block, intercept the error in a trigger insert.François
-
How to insert a value predetermined on a cell of a value to another cell
HI, I'm traying to set the automatic values on B1 and D1 cells by entering a value on the A1. I want to save time and work by simply entering a value on the A1 and fill of B1 and D1.
I use numbers on the airwaves of the ipad 2
passengers CG % MAC GTOW CG % MAC 44086 Example:
1 passenger 23, 4-23, 8. 25.5
2 passengers 23, 8-24, 5. 25.8
etc...
Hi gomlic,
"I'm trying to set the automatic values in cells B1 and D1 by entering a value on A1."
Is there a mathematical relationship between the value in A1 and B1 and D1 values, or these values appear on a lookup table?
In your post, what is entered in A1?
What is the result in B1?
What is the result in D1?
What numbers to get from the first to the result?
Kind regards
Barry
-
Create triggers in the table, sequence, insert and update with "model"?
It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:
1.), I add the table to the logic model
2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary
3.) then I have the new table to add
-but
I would then have auto-DDL of to be synchronized to database:
-create sequence for the id column
-create table
-create indexes for the id column pk
-Create triggers for insert and update
-l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.
-activate the triggers
Each of them following the same naming convention.
Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.
rgrds Paavo
Hi Paavo,
most of the steps can be made in one or other way
-create sequence for the id column
-create table
-create indexes for the id column pk
If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.
fields of record defined in the table, so that each table has them
You can add the same set of columns in all tables with the transformation script 'model of Table... ».
You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts
to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.
Philippe
-
Insert several values in file in database table
Hello
I have a requirement where I need the list of files (list operation) using the FTP adapter and insert all the values listed in the database file.
How to insert all the values of the file listed in the database. There are several file values listed so how insert all these values in the database?
Thank you
VivekIt is always a good practice to mark answers as correct/good
-
How can insert quary in database by using the collection.
Hi friends,
My friend advice me to insert several point with collection for the use of multiple lines. But I don't know how to use the collection. How do I create the form to insert data using the collection.
Please send me any link or example .au insert data into database by using the collection.
My problem is:-
I have a bill with several point for example. Grapes (25) with amount here and now I want to add these question with quantity in my database, Badam (145), banana (49), Apple (12)
When I finally click on submit button.
Actully I was used as a table but I am facing a problem when using tabular, tabular, I enter first item for example. Apple and there quantity for example. 12 in the textfield and after clicking on Add line enter Buttom went to the database. but I want that entry should not go the database. But only the new line should add when I click on the button Add a line.
I want all these point 4 should enter into the database when I click on Submit Final.
Maury
Published by: Ed on September 6, 2009 02:22Hello
I would do something like the code:
BEGIN DECLARE vDATE DATE; BEGIN vDATE := TO_DATE(:P1_DATE1,'DD.MM.YYYY'); WHILE vDATE <= TO_DATE(:P1_DATE2,'DD.MM.YYYY') LOOP INSERT INTO ABC (DTE, LEAVE) VALUES (vDATE, :P1_C); vDATE := vDATE + 1; END LOOP; END; END;
You must ensure that the datepicker points both use the ' JJ. MM YYYY ' date format.
Andy
-
Hello
I'm trying to achieve the following objectives:
1. in table A, select rows based on the values in column 2. something like SELECT * FROM TABLE A WHERE (COLUMN2 = 'X' or Column2 IS NULL)
2 and these values selected, I want to update Column3 from Table A if TableA.column1 = TableB.column1, but only if there is exactly one game. If there are multiple matches, column 3 of the table article updated.
That's what I've tried so far.
UPDATE TABLE_A
SET
TABLE_A.COLUMN3 = (SELECT COLUMN3 OF TABLE_B
WHERE ((TABLE_B.COLUMN1 = TABLE_A.COLUMN1) AND ( TABLE_B.COLUMN1 IN (SELECT Column1 FROM TABLE_B GROUP BY COLUMN1 , HAVING COUNT (*) = 1)))
WHERE EXISTS (SELECT * FROM TABLE_A)
WHERE ((TABLE_A.COLUMN2 = 'X' OU TABLE_A.COLUMN2 = 'Y') AND (TABLE_A.COLUMN4 IS NULL OR TABLE_A.COLUMN4 = ' ')));
More details on my DB environment:
Version Info:
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
PL/SQL Release 11.2.0.4.0 - Production
Toad, but, depending on whether the query updated all lines. I would really appreciate if someone could tell me how to fix my request.
Thanks in advance.
Exists it predicate in the block of update will be set to true if there is at least one row in table_a where column2 is X or Y and column4 is null or a space. You need to correlate exists it with the outer query query (I'm guessing on column1) to get the result I think you want. However, who would update all rows in table_a who meets the criteria, there is a corresponding row in table_b, affecting Column3 lines form null not matched or not. (Again), I'm guessing that's not your intention. If you only want to update the lines in table_a which have a corresponding line in table_b and meet the other predicate, then I think you want something more like:
Update table_a
Set table_a.column3 = (select column3 of table_b
where table_b.column1 = table_a.column1 and
Table_B.Column1 in (select column1 from table_b
Group by column1, having count (*) = 1))
where ((table_a.column2 = 'X' ou))
table_a.Column2 = 'Y') and
(table_a.column4 is null or)
table_a.column4 = ' ')) and
table_a.Column1 in (select column1 from table_b
Group by column1, having count (*) = 1)
John
-
How to call a value of preference in the XSLT file
Hi all
How to call a value preference (which is defined in bpel already) in the XSLT?
Can someone help me please
Kind regards
Villeneuve ch
Get the value of preference and and check out the post below to pass as a parameter
http://www.albinsblog.com/2012/07/passing-parameter-to-XSLT-in-SOA-11g.html#.UjfqfMZmiSo
Concerning
Albin I
-
How to compare, present value: block.text_item with the value of data
Hello
Could you please tell me
How to compare the current value: block.text_item with the corresponding database column value.
I use form 10g
It has block and there is a text element in this block.
When I run the form and query the block (in a table), the: block.text_item show me any value it in the database.
Now I add value in the: block.text_item to the existing value.
now
the: block.text_item contains the old + new added value
While
the database table contains the value 'old '.
Now, with a click of button, I want to know what value I added
Please can you me, is it possible without writing a select query?Hello
Now, with a click of button, I want to know what value I added
So you're saying always user will bring added value to the existing value. Because it will fail in a case. Let's say that
Database value is = ABCD
The user opens the form and he took the D and write E and now value is ABCE and length is always the same 4. There is therefore no need to add.In any case, you can know that the value of database at run time, there is a property for the element called DATABASE_VALUE. She gives the value that is in the database while you run the form before save. and you can use it like that...
Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level DECLARE vItemValue DATATYPE; -- Set the data type according to your desired field. vValueAdded DATATYPE; -- Set the data type according to your desired field. BEGIN vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE); -- It will return you the database value in vItemValue variable. IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN -- It mean something change or added vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1); MESSAGE('Added value is : '||vValueAdded); -- It will show you the added value. END IF; -- now suppose you want to show the old and new value in message not the added one -- Then no need of IF condition. You can just use message like this -- And i would prefer to use like this way MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME); MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME); END;
Hope that's clear.
-Clément
Maybe you are looking for
-
HP PSC 1610 all-in-one - can't sweep
When I hit SCAN on my printer, the LCD display gives me the following message"" no Scan option, you must install or run device software for feature. My CD drive is broken, so I installed the drivers from the HP website. After downloading the driver
-
RAM for Vista problem shows only 1 GB despite 2GB material
I have Windows Vista 32 bit installed in my system with 2 GB of RAM, and it worked perfectly. Yesterday my system performance show only 1 GB of RAM and the Ram usage is 60 to 90% of the capacity, I know that max support 4 GB 32-bit system, but how is
-
backup failed: 0x80070005 access denied
For the last few months when I try to save on DVD my computer is progressing well and uses 9 discs but then finally ends with "backup failed." The reason given is "0 x 8007005 access denied." Someone understands this. What can do to sort it? Mamah
-
Laptop does nothing, except for the power button / stop and the on/off button [Edit Moderator: left the community involvement Center]
-
Transparent display of Popup in Blackberry
Hello I found a work around for a transparent popup on any blackberry screen. I would like to share my code here. The PopupScreen class is as follows: /**************************************************************************************************