Separate a string in a field and insert it into 3 fields in another table
I tried to do this with many examples in the forum using REGEXP_REPLACE and REGEXP_SUBSTR but nothing seems to work properly for me.I have this column in the t3_one table
mergecode
A8846
A8847
I need to use this mergecode to insert some values into the following three columns in the table t3_two
dataCode mcprefix mcsuffix
A A-8846, 8846
A A-8847, 8847
create table t3_one (mergecode varchar2 (10));
create table t3_two (datacode varchar2 (10), mcprefix varchar2 (2), mcsuffic varchar (10));
Insert into t3_one
(mergecode)
VALUES
("A8946");
Insert into t3_one
(mergecode)
VALUES
('A8947");
Tags: Database
Similar Questions
-
Get the date value. MinValue and insert it into the DB
Hello
I'm developing an adf application using jdev11g.
I need to recover the 3 values of page jsf (inputText 2 + 1 date. MinValue) and insert them into DB
so I create a method in appModuleImpl:
{public createAffAgVehNewRow (Date date, around km, veh Integer) Sub
Get the id of the current user
String ag = ADFContext.getCurrent () .getSessionScope ().get("idAg").toString ();
getSequenceNumber
oracle.jbo.domain.Number seq = new oracle.jbo.domain.Number (0);
SequenceImpl seqImpl = new SequenceImpl ("AFF_AV_SEQ", getDBTransaction());
SEQ = seqImpl.getSequenceNumber ();
Insert values into the DB table
Line r = getAffAgVehView1 () .createRow ();
ViewObjectImpl vo = this.getAffAgVehView1 ();
r.setAttribute ("IdAg", Integer.parseInt (ag.toString ()) ");
r.setAttribute ("IdAffAv", seq);
r.setAttribute ("KmDep", km);
r.setAttribute ("IdVeh", veh);
r.setAttribute ("DateAff", date);
r.setAttribute ("KmArriv", null);
r.setAttribute ("ConsoCarb", null);
vo.insertRow (r);
this.getDBTransaction () .commit ();
}
also, I changed the default value of the EO (AffAgVeh) to adf.currentDate () and the user interface as simpleDate format: "MM/DD/YYYY.
the problem as whene I enter 3 inputValues and click on the button I get this message:
Timestamp format must be yyyy-mm-dd hh: mm: [.fffffffff]
someone knows how to solve this problem
Thank you
Mark
Hi Dev
Please pass.
java.sql.SQLException: column type invalid in the adf
Thank you
Subramanian M
-
Read the BLOB and insert data into a table
Hi all
Let us examine below on Oracle DB 12 c:
create table xx_test3 (c blob); insert into xx_test3 (c) values (utl_raw.cast_to_raw( 'azertyuiop,qsdfghjklm,wxcvbn')); create table xx_target (col1 varchar2(50));
Can someone guide me how to read the data and insert it into the xx_target table?
Necessary result is:
select * from xx_target; COL1 -------------------------------------------------- azertyuiop qsdfghjklm wxcvbn 3 rows selected.
Thanks in advance,
Stoyanov.
insert into xx_target (col1)
with the data as)
Select utl_raw.cast_to_varchar2 (dbms_lob.substr (c, 32000, 1)) CBC
of xx_test3
)
Select regexp_substr (CBC, ' [^,] +', 1, level)
from the data
connect by level<= regexp_count(src,="" ',')="" +="">=>
-
Remove all lines and insert them into Oracle can make performance worse?
I m working in a project that I need to make a batch update regularly (every 4 months) of excel files. These files have doesn´t excellent key in their ranks.
The development of a code that deletes all lines and inserts the entire base again is easier than one who checks in all the ranks of its primary key and if necessary update. (sometimes may be a key to 5 columns).
My question is: if I delete all the rows in the tables of the insert it again, it will cause tablespace fragmentation and in a future loss of performance?
Is there a way to avoid this?
Thanks in advance
Alexander
This response helped me a lot.
Thank you all
Remove all lines and insert them into Oracle can make performance worse? -Stack overflow
-
I need help (I have not the slightest idea) with a java script to program a button to retrieve an image from a user base and insert into a form field. To go to the menu select icon.
[edited by moderator - he had no body to the post office and it was while heading a long title.] [Shorten the title and pasted the original title, plenty of length as the message body]
Okay, that's actually quite easily. As the l' evenement event MouseUp button, select "Execute JavaScript" and enter this code:
event.target.buttonImportIcon ();
When you click the button it will open a file selection dialog and the selected file is displayed under the icon of the button.
-
Insert data from a field in another field in another table
I am trying to copy the records from the source tablein the dgpercentagedatachart table
the domain name is feederid
So that's what I came:
INSERT INTO dgpercentagedatachart (feederid)
Select source.feederid
Of the source;
This is the error I get
Error from the 1 in the command line:
INSERT INTO dgpercentagedatachart (feederid)
Select feederid
Source
Error report:
SQL error: ORA-01400: cannot insert NULL into ("GISELECTRIC". "" "" DGPERCENTAGEDATACHART '. "" OBJECTID')
01400 00000 - "impossible to insert a NULL value in (%s)."
I check that the two fields accept the NULL value, and they both said YES.
What can I do?
Excellent example. I get it.
But, how can I put the id of object with it?
Object_Id is the feeder_id # unique
You can question him in the same table:
INSERT INTO dgpercentagedatachart (feederid, objectid)
Select source.feederid, source.objectid
Of the source;
-
get the name of a directory file and insert it into a table
Hello
I have a requirement, I need to read the name of a Linux directory file and enter the file name in a variable,
After that, I need to insert this file name in a table.
EX: is it a file1.txt in Yearbook of the CBA, and I read that 'file name' in the v_file_name variable and I'm going to insert this file name in a table.Hello
I think you've got your request of replied by Chantal.
Shoul you have a kind of intelience in the name of the file itself so that ODI retrieves the correct file and insert into the table.Thank you
Fati -
divide a column value and insert it into several columns
Hello
am new to plsql.
I want to divide a characters in a column and insert into multiple columns
I tried the function substr used the symbol ',' vary its place dynamically, so I can't apply the substr function.
for example: before split
col1:
col2:
COL3:
COL4:
colu5: adsdf, fgrty, erfth, oiunth, okujt
after separation
col1: adsd
col2: fgrty
COL3: erfth
COL4: oiunth
col5: adsdf, fgrty, erfth, oiunth, okujt
can someone help me
Thank you
Published by: 800324 on December 23, 2010 08:28
Published by: 800324 on December 23, 2010 08:36What:
SQL> create table t 2 (col1 varchar2(30) 3 ,col2 varchar2(30) 4 ,col3 varchar2(30) 5 ,col4 varchar2(30) 6 ,col5 varchar2(30) 7 ); Table created. SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt'); 1 row created. SQL> insert into t (col5) values ('x,y'); 1 row created. SQL> insert into t (col5) values ('a,b,c,d'); 1 row created. SQL> select * from t; COL1 COL2 COL3 COL4 COL5 ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ adsdf,fgrty,erfth,oiunth,okujt x,y a,b,c,d 3 rows selected. SQL> SQL> merge into t a 2 using ( with t1 as ( select col5||',' col5 3 from t 4 ) 5 select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1 6 , substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2 7 , substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3 8 , substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4 9 , rtrim(col5, ',') col5 10 from t1 11 ) b 12 on ( a.col5 = b.col5 ) 13 when matched then update set a.col1 = b.col1 14 , a.col2 = b.col2 15 , a.col3 = b.col3 16 , a.col4 = b.col4 17 when not matched then insert (a.col1) values (null); 3 rows merged. SQL> select * from t; COL1 COL2 COL3 COL4 COL5 ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ adsdf fgrty erfth oiunth adsdf,fgrty,erfth,oiunth,okujt x y x,y a b c d a,b,c,d 3 rows selected. SQL>
Assuming you're on 9i...
-
Insert data into the source of destinator Table
Hi all
Need to insert data in sample_table1 table xxc_source_table sample_table2
create table xxc_source_table (DESCRIPTION varchar2 (10));
Insert the table xxc_source_table values('A201.) ABC.4084.GR');
create table sample_table1 (col_1 varchar2 (10), col_2 varchar2 (10), col_3 varchar2 (10), col_4 varchar2 (10));
create table sample_table2 (col_1 varchar2 (10), col_2 varchar2 (10), col_3 varchar2 (10), col_4 varchar2 (10), moved_flag varchar2 (2));
col_1 = A201
col_2 = ABC
col_3 = 4084
col_4 = GR
Note: Insert data into the col_1, the col_3, the col_4 of the xxc_source_table sample_table1
(2) if the next (form xxc_source_table) data is exist in the sample_table2, and then set the moved_flag as Y in this column
3) xxc_source_table has 17000 lines
Thank you.
Post edited by: Rajesh123 please do not consider cross the line message
Hi Renon,
Why you don't want substr and instr? For best performance, you should go with substr and instr instead of regexp_substr. However you asked me to provide the code instead of substr and InStr. Then try the below...
INSERT ALL
IN VALUES sample_table1 (col1, col2, col3, col4)
IN sample_table2 VALUES (col1, col2, col3, col4, 'Y')
SELECT REGEXP_SUBSTR (DESCRIPTION,'[^.] +', 1, 1) col1,.
REGEXP_SUBSTR (DESCRIPTION,'[^.] +', 1, 2) col2.
REGEXP_SUBSTR (DESCRIPTION,'[^.] +' 1, 3) col3.
REGEXP_SUBSTR (DESCRIPTION,'[^.] +' 1, 4) col4
OF xxc_source_table;
Thank you
Ann
-
Look for patterns in a string and insert it into a new table
I need to write a query that finds a number of location of employees that has been changed from old to new
EMPLOYEE_DESC
Description of the ID
1 employee location was change from 877-287-8765 to 876-876-0976
2 location of employee was passing of 877-287-8766 at 876-879-0976
slot 3 is passed under NONE FOUND TO577-75-5951
Once I get the identifier for the old and the new, I need to insert into the new table
INSERT INTO TABLE_B
(OLD_LOC_ID, NEW_LOC_ID)
VALUES (OLD_LOC_ID, NEW_LOC_ID);
TABLE_B
ID OLD_LOC_ID NEW_LOC_ID
1 287-877-8765 876-876-0976
2 287-877-8766 879-876-0976
3. NONE FOUND 577-75-5951
The problem is that there is no fixed model for these records. I guess I have to insert the records that correspond to a fixed patten and snoop then through other manually. Is there a REGULAR expression feature that can help me grep values old and new location for the employee_desc number?
Thank you
Kevin
Hello
Kevin_K wrote:
... The problem is that there is no fixed model for these records. I guess I have to insert the records that correspond to a fixed patten and snoop then through other manually. Is there a REGULAR expression feature that can help me grep values old and new location for the employee_desc number?
Thank you
Kevin
Yes, you can do something like this:
REGEXP_SUBSTR (description
, ' ((NONE FOUND) |) (\d+-\d+-\d+)) * To * \d+-\d+-\d+'
1
1
'i' - case-insensitive
)
It looks like for
- a "phone number" or the words "NOTHING FOUND", followed immediately by
- 0 or more spaces followed immediately by
- the word "TO", followed immediately
- 0 or more spaces followed immediately by
- a "phone number".
where a "phone number" is defined as
- 1 or more digits, followed immediately
- a hyphen, immediately followed by
- 1 or more digits, followed immediately
- a hyphen, immediately followed by
- 1 or more digits
- You can also get the parts before and after 'TO' separately.
-
Hi, please help me whit this query
Im trying to extrate the data in a file csv and im using the ULT_FILE package
I have this query that read the file and the first field, but if the field has a different length does not work as it shouldFor example if I had this .csv file:
1, book, laptop
2, pen, Eraser
3, notebook, paper
And in the table, I had to insert like this
ID descrption1 description2
laptop 1 book
Eraser pen 2
paper laptop 3
For now, I have this query, which displays only with DBMS:
Declare
-Variables
Cadena VARCHAR2 (32767).
Vfile UTL_FILE. TYPE_DE_FICHIER;
Dato varchar2 (200); -Date
dato1 varchar2 (200);
dato2 varchar2 (200);
Identifier varchar2 (5): = ', '; -Identifier (en)
v_ManejadorFichero UTL_FILE. TYPE_DE_FICHIER; -For exceptions
-Table variables
I_STATUS GL_INTERFACE. % OF STATUS TYPE.
I_LEDGER_ID GL_INTERFACE. TYPE % LEDGER_ID;
I_USER_JE_SOURCE_NAME GL_INTERFACE. TYPE % USER_JE_SOURCE_NAME;
I_ACCOUNTING_DATE GL_INTERFACE. TYPE % ACCOUNTING_DATE;
I_PERIOD_NAME GL_INTERFACE. TYPE % PERIOD_NAME;
I_CURRENCY_CODE GL_INTERFACE. CURRENCY_CODE % TYPE;
I_DATE_CREATED GL_INTERFACE. DATE_CREATED % TYPE;
I_CREATED_BY GL_INTERFACE. CREATED_BY % TYPE;
I_ACTUAL_FLAG GL_INTERFACE. TYPE % ACTUAL_FLAG;
I_CODE_COMBINATION_ID GL_INTERFACE. TYPE % CODE_COMBINATION_ID;
I_ENTERED_DR GL_INTERFACE. TYPE % ENTERED_DR;
I_ENTERED_CR GL_INTERFACE. TYPE % ENTERED_CR;
I_ACCOUNTED_DR GL_INTERFACE. TYPE % ACCOUNTED_DR;
I_ACCOUNTED_CR GL_INTERFACE. TYPE % ACCOUNTED_CR;
I_TRANSACTION_DATE GL_INTERFACE. TRANSACTION_DATE % TYPE;
I_REFERENCE1 GL_INTERFACE. REFERENCE1% TYPE;
I_REFERENCE2 GL_INTERFACE. REFERENCE2% TYPE;
I_REFERENCE3 GL_INTERFACE. REFERENCE3% TYPE;
I_REFERENCE4 GL_INTERFACE. REFERENCE4% TYPE;
I_REFERENCE5 GL_INTERFACE. REFERENCE5% TYPE;
I_REFERENCE10 GL_INTERFACE. REFERENCE10% TYPE;
I_GROUP_ID GL_INTERFACE. GROUP_ID % TYPE;
BEGIN
Vfile: = UTL_FILE. FOPEN ('CAPEX_ENVIO', 'comas.csv', 'R');
loop
UTL_FILE. GET_LINE(Vfile,Cadena,32767);
dato1: = substr (cadena, instr(cadena, identificador,1,1)-1, instr(cadena, identificador,1,1)-1);
dato2: = substr (cadena, instr (cadena, identifier, 1, 1) + 1, instr(cadena, identificador,3,1)-3);
dbms_output.put_line (dato1);
dbms_output.put_line (dato2);
-The evidence
-dbms_output.put_line (cadena);
-dbms_output.put_line (substr (dato, 3, instr(dato, identificador,1,1)-1));
-dbms_output.put_line (substr (dato, instr (dato, identifier, 1, 2) + 1, instr(dato, identificador,1,1)-1));
-dbms_output.put_line (substr (cadena, 1, length (cadena)-1));
end loop;
UTL_FILE. FCLOSE (Vfile);
-----------------------------------------------------------------------------------EXCEPTIONS------------------------------------------------------------------------------------------------------------------------------------------------------------
EXCEPTION
When no_data_found then
dbms_output.put_line ('Todo Correcto');
When utl_file.invalid_path then
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20060,'RUTA DEL ARCHIVO NULLIFIED: (');)
WHEN UTL_FILE. INVALID_OPERATION THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR ('-20061,'EL ARCHIVO NO PUDO SER ABIERTO ");
WHEN UTL_FILE. INVALID_FILEHANDLE THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20062, 'INVALIDO MANAGER');
WHEN UTL_FILE. WRITE_ERROR THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20063, 'ESCRITURA ERROR');
WHEN UTL_FILE. INVALID_MODE THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20064, 'MODO INVALIDO');
WHEN UTL_FILE. INTERNAL_ERROR THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20065, 'ERROR INTERNO');
WHEN UTL_FILE. READ_ERROR THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20066, 'LECTURA ERORR');
WHEN UTL_FILE. FILE_OPEN THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR ('-20067,'EL ARCHIVO ARE ESTA ABIERTO ");
WHEN UTL_FILE. THEN ACCESS_DENIED
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20068, 'REFUSED ACCESS');
WHEN UTL_FILE. DELETE_FAILED THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20069, 'OPERACIÓN BORRADO FALLO');
WHEN UTL_FILE. RENAME_FAILED THEN
UTL_FILE. FCLOSE (V_ManejadorFichero);
RAISE_APPLICATION_ERROR (-20070, 'OPERATION SOBREESCRITURA FALLO');
END;
Hello
Try something like this:
POS1: = INSTR (cadena, idntificador, 1, 1);
POS2: = INSTR (cadena, idntificador, 1, 2);ID: = SUBSTR (cadena, 1, pos1 - 1);
description1: = SUBSTR (cadena, pos1 + 1, (pos2 - pos1)-1);
Description2: = SUBSTR (cadena, pos2 + 1);where pos1 and pos2 are numbers.
Rather than use UTL_FILE, consider creating an external table. You won't have to write any PL/SQL, and this means that you won't be tempted to write a bad article of EXCEPTION.
-
Generate the command Id and insert data into two different tables: oracle apex 5.0
I have three tables. name of the tables: PRODUCT, ORDER_HEADER, ORDER_DETAIL. I took REPORT inter ASSETS in which the VALUES from TABLE product. I need to use the trigger here, there is a TEXT ARTICLE called ORDER ID: it will generate through trigger. so whenever new order placed order id must be unique. There is a button when this button is clicked, the VALUES of REPORT must be inserted in to ORDER_HEADER , ORDER_DETAIL (in fact, I am in confusion is it even possible).
I tried to create the trigger: not work if
CREATE OR REPLACE TRIGGER "EMP_TRG1".
Before Insert on order_header
for each line
Start
If: new. Order_ID is null
then
Select lpad (demo_seq.nextval, 8, '0'): new. Order_ID order_header;
end if;
end;
SQL:
Select
apex_item. Text(1,p.PRODUCT_ID) PID.
PN.product_name,
apex_item. Text(2,p.PRODUCT_QTY) qt.
apex_item. Text(3,p.unit_price) upward,
apex_item. Text(4,p.TOTAL_AMOUNT) am
OMS_SHIP_CART_DETAIL p, pn OMS_PRODUCT
where p.product_id = pn.product_id
DA:
var arr_f01 = [];
var arr_f02 = [];
var arr_f03 = [];
var arr_f04 = [];
var arr_f05 = [];
product_id var;
unit_price var;
Var Qty;
var total_1;
() $("input[name='f01']").each
function() {}
product_id = $(this).closest('tr') .children ('td [headers = 'PID']') .text ();
unit_price = $(this).closest('tr') .children ('td [headers = "Uprice"]') .text ();
Qty = $(this).closest('tr') .children ('td [headers = "Qty"]') .text ();
total_1 = $(this). Closest ('tr'). Children ('td [headers = "total"]'). Text();
arr_f01.push ($(this).) Val());
arr_f02.push (product_id);
arr_f03.push (total_1);
arr_f04.push (unit_price);
arr_f05.push (Qty);
} );
(apex). Server.Process
"Insert a command."
, {f01: arr_f01, f02: arr_f02, f03: arr_f03, f04: arr_f04, f05: arr_f05}
}
, {dataType: "text", success: function (pData) {alert ('added product') ;}}
);
Ajax callback:
declare
l_count number;
Start
-insert into OMS_ORDER_HEADER (USER_ID, TOTAL_AMOUNT, batch, ORDER_DATE) values(:P1_USER_ID,:P42_TOTAL,'PENDING',SYSDATE);
I'm looping 1.apex_application.g_f01.count
insert into OMS_ORDER_DETAIL (PRODUCT_ID, UNIT_QTY, UNIT_PRICE, TOTAL_AMOUNT)
values (APEX_APPLICATION. G_F01 (i), APEX_APPLICATION. G_F03 (i), APEX_APPLICATION. G_F04 (i), APEX_APPLICATION. G_F05 (i));
commit;
end loop;
end;
Hi Dominique,.
I create a process page away present in your application
declare l_order_id varchar2(8); begin insert into order_header(ORDER_ID , STATUS , ORDER_DATE) values(lpad(demo_seq.nextval,8,'0') , 'Pending' , sysdate) returning ORDER_ID into l_order_id; for rec in(select ID , QTY , PRICE from product) loop Insert Into Order_Detail ( ORDER_ID , PRODUCT_ID , QTY , UNIT_PRICE) Values(l_order_id , rec.id , rec.qty , rec.price); commit; end loop; end;
Please check and let me know.
Kind regards
Jitendra
-
updated line and insert them into another table with trigger.
Hi guys I have a table that looks like this.
I'm going to insert the col1 and col2 values, but I need to get the value of column 3 of table 2 and then insert the complete record in table 3. I love doing that with a trigger. I get an error message and I can't for the life of me figuere out what im doing wrong.CREATE TABLE TEST ( "COL1" VARCHAR2(20 BYTE), "COL2" VARCHAR2(20 BYTE), "COL3" VARCHAR2(20 BYTE) )
So here is my nonfunctional trigger.
Here are the two table
HERE IS THE CODE OF THE TRIGGERCREATE TABLE TESTTABLE ( "COLUMN1" NUMBER(15,0), "COLUMN2" NUMBER(15,0) ) Insert into TESTTABLE (COLUMN1,COLUMN2) values (1,5);
I get an error of trigger mutation that I tried the other iterations of the above but I'm not getting anywhere. I have dumb down my problem at these 3 table.CREATE OR REPLACE TRIGGER TRIGGER1 AFTER INSERT ON TEST FOR EACH ROW BEGIN update TEST SET COL3 = (SELECT COLUMN2 FROM TEST, TESTTABLE WHERE COLUMN1 = :new.COL1); END
Can someone point me in the right direction.You'll have to do some reading, but it comes down to process the data on education instead of line level.
You may even be not at all a trigger.
See:
http://www.Oracle-base.com/articles/9i/mutating-table-exceptions.php
http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551198119097816936 -
Is it to extract data from a database and insert it into a session variable?
$_SESSION ['Stud_FirstName'] = $row_rs_Login ["Stud_FirstName"];
because it is not work. I swear to you that the more I learn, the less I know.
What to do to change?
Thank you!
Yes. However, the recordset must exist before you can assign value to another variable. The last line of code that creates a recordset object looks like this:
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
If you attempt to create the variable session before this line, as you are, I suspect, is not really surprising that it does not work.
Even if you don't want to write all the code yourself, you must understand the code that Dreamweaver is written for you. Otherwise you will be constantly bumping your head on the keyboard. A PHP script is executed from top to bottom, and the flow of the script is controlled by loops and conditional statements. Get your head around these concepts, and you can find customizing Dreamweaver code much easier.
-
trigger for update field in a table with the sum of the fields to another table
My experience in creation of triggers and pl/sql in general can be described in terms of oracle with the null value. I practiced by creating arrays and applications on my personal server at home to help me with some of my work related tasks. Right now I am creating a trigger which will, after insert, update, delete on the update of the table assignment_time_track the area of the time_spent on the table of assignments with the sum of the time_spent on the assignment_time_track table fields. I hope that run on the sentence it is clear to the people other than me. I tried this script on my own using the tool of creation of trigger for Oracle Database Express Edition, but I get the following error:
Create a trigger failed, for the following reason:
ORA-06552: PL/SQL: ORA-06553 finished Compilation unit analysis: PLS-320: the declaration of the type of the expression is incomplete or incorrect
Here is my attempt to create the trigger on my own.
create or replace trigger "ASSIGNMENT_TIME_TRACK_T1".
AFTER
INSERT or update or delete on 'ASSIGNMENT_TIME_TRACK '.
for each line
Start
update assignments
Set time_spent = (select sum (time_spent)
of assignment_time_track
where assignment_time_track.name = assignments.name);
end;
/
If what I posted is not clear or more detail is needed, let me know and I will respond with a full description of tables and my goals for each table. Thanks in advance for any help. I also gladly accepts links to tutorials or lessons that explain how to do this kind of thing.
Published by: bobonthenet on March 9, 2009 14:01I think I understand what you mean :)
Rather than use a trigger to keep the master table (assignments) in sync with the time spent on the details, it would be much easier to use a query to do this, maybe creating a view.
Something along the lines of
SQL> create table assignments 2 (id number primary key 3 ,name varchar2(10) 4 ); Table created. SQL> SQL> create table assignment_time_tbl 2 (id number primary key 3 ,assid number references assignments 4 ,time_spent number 5 ); Table created. SQL> SQL> insert into assignments 2 select rownum 3 , 'a' 4 from all_objects 5 where rownum < 5 6 / 4 rows created. SQL> SQL> insert into assignment_time_tbl 2 select rownum 3 , rownum 4 , rownum * 3 5 from all_objects 6 where rownum < 5 7 / 4 rows created. SQL> SQL> commit; Commit complete. SQL> SQL> SQL> select a.id 2 , a.name 3 , (select sum (time_spent) 4 from assignment_time_tbl 5 where assid = a.id 6 ) 7 from assignments a 8 / ID NAME (SELECTSUM(TIME_SPENT)FROMASSIGNMENT_TIME_TBLWHEREASSID=A.ID) ---------- ---------- ------------------------------------------------------------- 1 a 3 2 a 6 3 a 9 4 a 12
Maybe you are looking for
-
I lost the my computer icon on my screen.
My computer icon disappeared from my office. I used the time capsule to try back-up at an earlier date and perhaps recover it, without success. I can always find my applications... I tried to copy the icon in the finder and paste them into a folder
-
Satellite A205 - LCD backlight issue
My laptop LCD screen backlight seems well until recently have been the subject of a cutting.Every few minutes (though sometimes if I leave it alone, it stays on for a long time) the light goes out leaving just a small picture of what I was doing on m
-
List of hp equipment Envy 4-1255er
Hello, I want to know what (wifi & Ethernet) network modules included in hp Envy 4-1255erI'd appreciate any help in this topicPS Ce would be very kind of you if you post Fri and Dev id for network card Thank you in advcance
-
I am trying to determine the operating system on my cell phone and its level. I was told to go to settings > system > all but which results in the text that is much too small to read. Is there another method? Thank you, Bob
-
por mi cuenta hotmail than no Habré los don't email por favor ayudenme
Hola por mi cuenta hotmail than no Habré los don't email por favor ayudenme