a few fields in double writing to another table with separate records
I have a requirement to write a few fields in duplicate a table and writes the separate records to another table. Please find the script below and share your ideas
TableName: EMP_DETAIL
EMPNO | Date of birth | CITY | STATE | GRADE |
---|---|---|---|---|
123 | 05051982 | FREMONT | CA | A |
456 | 05051982 | FREMONT | CA | B |
789 | 05051982 | FREMONT | CA | C |
222 | 02021975 | SANJOSE | CA | D |
(1) in table EMP_DETAIL, if we have duplicate fields date of birth, CITY AND STATE and take everything save random duplicates of this field and write in another table EMP_DETAILS_DISTINCT
EXPECTED RESULTS: EMP_DETAILS_DISTINCT
EMPNO | Date of birth | CITY | STATE | GRADE |
---|---|---|---|---|
123 | 05051982 | FREMONT | CA | A |
222 | 02021975 | SANJOSE | CA | D |
(2) in the EMP_DETAIL table, I want to search only duplicates of birth date, CITY AND STATE fields and write only duplicate in another EMP_DETAILS_DUPLICATE table records
EXPECTED RESULTS: EMP_DETAILS_DUPLICATE
EMPNO | Date of birth | CITY | STATE | GRADE |
---|---|---|---|---|
123 | 05051982 | FREMONT | CA | A |
456 | 05051982 | FREMONT | CA | B |
789 | 05051982 | FREMONT | CA | C |
Thank you!
For the first query
1) insert into EMP_DETAILS_DISTINCT select * from EMP_DETAIL where rowid in (select min (rowid) of the EMP_DETAIL group by date of birth, CITY, STATE);
For the second query
(2) insert into select EMP_DETAILS_DUPLICATE * from EMP_DETAIL where rowid not in (select min (rowid) of the Group EMP_DETAIL by DOD, CITY, STATE)
Hope this will help you.
Good day.
Tags: Database
Similar Questions
-
Not how to show a part of online data in a table in another table with even no column?
I need to display the data from certain rows in a table in another table with the same numbers of columns and main table must be disabled. Could someone advice how to do this? Data in the table are from the microprocessor and is intended the user can see and edit only some data.
If someone can show me some advice, it will be a great help.
Kind regards
Annemariehoeven
Disable a table: SetInputMode (panelHandle, controlID, 0); ('1' to re - activate).
Hide a table: SetCtrlAttribute (panelHandle, controlID, ATTR_VISIBLE, 0); ('1' to show it again).
These commands are valid for each type of control.
To extract values from the table, you can just use GetTableCellVal or GetTableCellRangeVals: If the range of cells has the same data type, you can use the second command which is faster; If the cells are different (for example digital and channels) you must solve each of them individually. The use of the Clipboard doesn't have this limitation.
-
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 -
inserting multiple rows of another table with incremented recordid
Hi all
I HAVE TWO TABLES:
CREATE TABLE TEMP_TEST1)
NUMBER OF RECID,
TESTCHAR VARCHAR2 (500)
)
AND
CREATE TABLE TEMP_TEST2)
TESTCHAR VARCHAR2 (500)
)
Both the table contains data in it. I want to insert data from TEMP_TEST2 in TEMP_TEST1 with RECID incremented for each record, which must be greater than max (RECID) of TEMP_TEST1.
PS: I have to query insert only, I cannot make changes in the structure of table or RECID of TEMP_TEST1 is not automatically incremented.
Please suggest a query that selects the record of TEMP_TEST2 and TEMP_TEST1 insert with recid incremented for each record.
Thank you.SQL> insert into TEMP_TEST2(TESTCHAR) 2 select 'Test'||level from dual connect by level < 10 3 / 9 rows created. SQL> SQL> SQL> insert into TEMP_TEST1(RECID,TESTCHAR) 2 select (select nvl(max(RECID),0) from TEMP_TEST1) + rownum, t2.TESTCHAR 3 from TEMP_TEST2 t2 4 / 9 rows created. SQL> SQL> select * from TEMP_TEST1 2 / RECID TESTCHAR ---------- ---------- 1 Test1 2 Test2 3 Test3 4 Test4 5 Test5 6 Test6 7 Test7 8 Test8 9 Test9 9 rows selected. SQL> insert into TEMP_TEST1(RECID,TESTCHAR) 2 select (select nvl(max(RECID),0) from TEMP_TEST1) + rownum, t2.TESTCHAR 3 from TEMP_TEST2 t2 4 / 9 rows created. SQL> SQL> select * from TEMP_TEST1 2 / RECID TESTCHAR ---------- ---------- 1 Test1 2 Test2 3 Test3 4 Test4 5 Test5 6 Test6 7 Test7 8 Test8 9 Test9 10 Test1 11 Test2 RECID TESTCHAR ---------- ---------- 12 Test3 13 Test4 14 Test5 15 Test6 16 Test7 17 Test8 18 Test9 18 rows selected. SQL>
Good bye
DPT -
best way to create a table based on another table
Hello
I am trying to create a table based on another table with all the data in it. It contains important data.
create table < tablename > select * from table1.
Is the best way to do it, or is there another way. Please advice.
Thank youInsert / * + append * / in
as select * from ; It should be->
insert /*+ append */ into
select * from ; Kind regards.
LOULOU.
-
When I open a program that takes a few seconds to load and open another program while I'm waiting, it will automatically put the first window on top when it has finished loading. How do I not do?
Hello
Unfortunately, it is not possible to change that outside of the modification of the order in which the programs open.
If you have feedback or suggestions, you can express their opinion on this at:
It will be useful.
-
Select a number of fields between one area and another
Hello
Is it possible to do a SELECT to show a number of fields of one field on the other.
without writing all the fields one by one?
For example, I have a table with the fields:
EMPLOYEE TABLE:
ID_EMPLOYEE NAME PHONE CAR AGE MARRIED
and I want to just do a SELECT that shows only the NAME to the AGE fields, but I don't want to
write to SELECT it all the fields one by one.
Is this possible?
Thank you very much.
Sorry for my English is not very good.Selim wrote:
HI, use the function below to get a list of the names of columns between 2 columns in a tableOr something similar to SQL...
SQL> ed Wrote file afiedt.buf 1 with t as (select '&table_name' as tn, '&min_col_name' as min_col_name, '&max_col_name' as max_col_name from dual) 2 ,cid as (select min(column_id) as min_col, max(column_id) as max_col 3 from user_tab_columns, t 4 where upper(table_name)=upper(tn) 5 and upper(column_name) in (upper(min_col_name),upper(max_col_name)) 6 ) 7 -- 8 select ltrim(sys_connect_by_path(c, ','),',') as cols 9 from ( 10 select row_number() over (order by column_id) as i 11 ,column_name as c 12 from user_tab_columns, t, cid 13 where upper(table_name)=upper(tn) 14 and column_id between min_col and max_col 15 ) 16 where connect_by_isleaf = 1 17 connect by i = prior i + 1 18* start with i = 1 SQL> / Enter value for table_name: emp Enter value for min_col_name: job Enter value for max_col_name: comm old 1: with t as (select '&table_name' as tn, '&min_col_name' as min_col_name, '&max_col_name' as max_col_name from dual) new 1: with t as (select 'emp' as tn, 'job' as min_col_name, 'comm' as max_col_name from dual) COLS ------------------------------------------------------------------------------------------------------------------------------- JOB,MGR,HIREDATE,SAL,COMM SQL>
which could just as easily be turned into a function.
Of course, it is usually fast enough just to do a describe on the table statement in SQL * more and use the copy/paste and a quick insertion of «,»
-
The default value based on the field from another table to a custom object
I'm trying to set the default value to a field in the custom object to the value of a field of account. I tried the syntax 50 ways different and just don't get the case. The label for the account field displays the form of s/n, the integration of the tag is ltDBA_ACCT and it appears in the fx reports area as Account.Text_22.
The field of custom object that I am triying update is also called s/n, which was originally the required field 'NAME '. The name of the table, account, should it be included? Do I need a function to the field?
I've updated the external ID using the line with syntex < ID > ID (at least higher ID) so I know that it is possible to define a default value, but s / < n >, < ltDBA_ACCT >, 'account '. "" S/n "and so on are simply not working.
If anyone knows how to get into what I would be really grateful for the help.OK, so if you default a field to the value of another object, you must use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure you do.
Then this won't work by default if the folder is created from the object that you want to join the because a default works in record creation and the ID must be available so that it works correctly. It will not work if you choose the record of the related object after that registration of the custom object is created. You can set the default after, but that does not meet your requirements.
The syntax of the default are the following: JoinFieldValue (ref_record_type, foreign_key, field_name).
In your case, ref_record_type is '
', foreign_key is [ ] and field_name is ' '. The best way is to determine what is the name of the field to create a new workflow for the account and use the Workflow Rule Condition expression builder to choose your field ("DBA") in the list. The value returned by the expression builder must be placed in the field_name variable in the function JoinFieldValue (minus the parentheses and quotes). Give it a shot and let me know how you do.
Thom -
Disqualification: Compare the value list in another Table
I'm relatively new to the Disqualification.
I use the 11.1.1.7 version.
I have 2 tables Oracle. Table1.FieldA does not have a foreign key constraint (but should be) at Table2.FieldB.
I created a snapshot for Table1 that includes FieldA.
I created another cliché to Table2 which includes FieldB.
I am trying to compare the Table1.FieldA with Table2.FieldB value to make sure that there is.
I can think of a few processors that I could, but they seem to compare a value with another value in the same snapshot (table).
Any advice would be helpful.
Thank you.Ray
Hello
Use the search check if you want to just check between the tables. According to the reference database, you need create a list of choices on the table (can be either staged as you, or just a list of external choice provided the lookup columns are indexed). Use Lookup and return if you want to import data in the other table in your process. You can control if you want a 1:1 or from a 1:M relationship, and if you go back several records, you can use split chronogram: table with all the paintings of entry to create an intermediate join process.
Mike
-
. Duplicate another document with position [0,0]
Hello
I'm working on a script of jsx Illustrator to automate my process of creating print file and get a few terabytes of valuable data accordingly.
The idea is that the script:
(1) open a psd from photoshop with graphics to raster
(2) opens a file with vector graphics that are all grouped illustrator
(3) selects everything on the illustrator file
(4) duplicates the selection of the folder of photoshop
(5) change certain text fields and
eps file and a file with updated work plan to be nested and printed a day 5) exports
The problem is with the part of duplication, the double function sets the vector graphics not aligned on the artboard (the square on the psd file is not in line with the outer vector line which is duplicated) by sometimes simple milimeters from where it is supposed to be and sometimes even so far as the so-called place that I might have to zoom out to see the vector graphics duplicated.
I am currently using
app.activeDocument.selection [0] .duplicate (app.documents.getByName (thePsdFileNameGoesHere). layers.add (), ElementPlacement.PLACEATBEGINNING);
I thought that I could select all on the newly created layer and all with .position move to the upper left corner giving him the point from coordinates [0,0], but apparently it can be done so that the selection is a table with many objects, lines, text, etc.
How do I align the newly duplicated content properly with the work on a document?
Thank you in advance!
I thought about it, if someone needs help with this issue:
App.Selection [0] .position = Array (.artboardRect app.activeDocument.artboards [0] [0], app.activeDocument.artboards [0] .art boardRect [1]);
what he does - correct selection (group with lots of elements) and sets of values provided by artboard upper left corner first two numbers.
-
Double click on af:table
On the same JSF page, I have two tables: master and detail. In detail the added table a listener client and the server with the following properties: because the double click can be made to the row. Also, I added a resource (type java script) function doDbClick (event) {var source = event.getSource ();} AdfCustomEvent.queue (source, 'doDbClick', {}, false); } The problem is when I try to add a client and listener server from the main table, due to the double click on the table and the fields in the header are all overlapping. This behavior occurs because? I avoid? Help me please. my version of jdev is 11.2.4.0
I solved the problem by putting the client and the server listener at the beginning of the table and not at the end. There is no XML no error or on the console when you run the application, but with this change all the information correctly
-
Relations reapper after adding another table
Hello
I have a problem that after using the option to hide some of the stranger, they keys reapper after making a few changes on the diagram (addition of a new table). More specific: on the schema relationship, there are many references to the table T1, I don't want to not show them in the because there are too many lines and it is not necessary to indicate all the. But when I hide them (objects-> show/hide foreign keys) and add another table to the diagram, all relationships are back. Can this be prevented somehow? DM, Version 4.1.0.881
Hello
Thanks for reporting the problem. I logged a bug.
Can this be prevented somehow?
You can add new tables to the diagram using drag & drop from the browser - then only FKs associated that tables appear on the diagram.
Philippe
-
[I ask nicely for a few comments for this question.
Someone else can reproduce it with the test below?
Is my code invalid or false?
Or what is the problem here?
-Thank you
Frank
]
Hello
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Trigger Before Insert or Update to a table, I invoke a PL/SQL package function to check the size of an xmltype column (passing as IN OUT NOCOPY).
PL/SQL functions retrieves the xmltype. GetClobVal(), check its size, and when it is beyond a limit, he tries to insert the data into another table (GTT - global temporary table).
Finally, it changes the value of the value of the column of xmltype to the shorter XML (just by referring to the corresponding record in the TWG).
But the Insert SQL in the TWG operation strike ORA-22993: specified input is greater than the amount actual source.
I don't know why this happens. In the internet I only find references on importing files in lob/clob.
Anyone have the same problem?
I know that you prefer to have a sample program to demonstrate the problem - I'll try to post one, but it will take time.
But maybe someone can help me based on the information above already.
-Thanks a lot!
Best regards
Frank
I have reproduced the issue.
It must be a bug.
-
Validation form column against the value of another Table
Hello
I'm new to this forum, so please bear with me a bit! I only have a small amount of writing PL/SQL experience, and I've never written Javascript or JQuery before. I am an Oracle DBA and I coding experience C and PERL, so I have a strong technical background. But I need some advice on the best way to approach a problem.
I have an application of data base in Oracle Apex (version 4.2) with a tabular form on a table: Let's say that #1 with the conditions of licence 1 a, 1 b, and1C. I have to make sure that the value entered in col B is not greater than the value of a column in another table (for example table #2 pass 2 (a). From a conceptual point of view, the amount of money available is in the #2 table, and my tabular form lines are an act of spending money (such as orders or invoices), so I have to make sure that we spend more that we have. Who is?
Does anyone have tips for the best way to do it? I'm figuring that the biggest problem here is perhaps to account for people who enter multiple lines in the form of tables at the same time, right? So, if a person is entered 3/invoices, I need a total to ensure that they do not have spend more than we have in the #2 table.
I really appreciate your help!
Best regards
Laurie Baublitz
Ah, I was not totally with you on this charge then. My validation works overall, but it totals the amount for each line, regardless of the task. Okay - who was not totally my solution but more a demonstration of the technique that you can use to validate your tabular presentation in this way.
You could solve this issue with a safe collection, or with a table plsql where you add an entry for each task name and keep the amount stored in there.
Anyway, it would be better for you to spend a little time on playback on the plsql collections or collections apex!
Remember, this is a sample and you will need to take stock of it. The best solutions are those where you need to experiment with 8)
DECLARE TYPE tt_taskamount IS TABLE OF NUMBER INDEX BY VARCHAR2(20); t_taskamount tt_taskamount; l_task VARCHAR2(20); l_amount NUMBER; l_max NUMBER; BEGIN -- F02 is the taskname -- F03 is the amount -- adapt to your situation! FOR i IN 1..apex_application.g_f02.count LOOP l_task := apex_application.g_f02(i); l_amount := apex_application.g_f03(i); IF NOT t_taskamount.exists(l_task) THEN t_taskamount(l_task) := l_amount; ELSE t_taskamount(l_task) := t_taskamount(l_task) + l_amount; END IF; -- it's not the best idea to perform a select each time and could be -- done better but for the sake of the example it's fine -- not too bad either if the rowcount is small. SELECT maxamount INTO l_max FROM table2 WHERE taskname = l_task; IF t_taskamount(l_task) > l_max THEN -- returning will stop further processing and throw an error message as soon as a budget has been overrun -- it might or might not be required behaviour but that's up to you RETURN 'The max amount ('||l_max||') for task ' || l_task ||' has been exceeded. Reduce the total amount on associated tasks!'; END IF; END LOOP; END;
-
Insert values from another table
Hello I have a table:
T1
---
ID
user
and another table:
T2
---
intellectual property
Mac
So I modified T1:
ALTER table T1 add ip number (20);
ALTER table T1 add mac number (20);
So I have:
T1
---
ID
user
intellectual property
Mac
T1 and T2 are the same number of lines.
Now, I want to insert the values of IP and mac of T2 in the fields ip address and mac of T1.
IP and mac of T2 fields can be "not null".
How can I do?
Thanks in advanceand what do you think about something like this:
UPDATE t1 SET t1.mac = (SELECT t2.mac FROM t2 WHERE t2.id = t1.id), t1.ip = (SELECT t2.ip FROM t2 WHERE t2.id = t1.id)
Give it a shot... validate the results before stolen.
HTH,
Thierry
Maybe you are looking for
-
used to synchronize calendars purchased at the office
I have two calendars, I subscribed to on my iphone, but they don't synchronize or show up on my other devices. On my phone, they appear under "Subscriber calendars" but they don't appear anywhere on any of my desk calendars. Any help appreciated.
-
Return complete my album option?
Instead of buying the whole album first, I started to buy individual songs to it. The album was £12.99 and without realizing, now I bought so many songs on the album, I lost the complete my album option (which I had) and the album is just returned to
-
If this happened at least a year. Whenever I have a connection, I can send a message, then it stops working. I can still view previous messages to my contacts, but I can no longer send messages or change my status. So I disconnect then it crashes and
-
Hi all I have labview 8.6 installed on my laptop. currently of the problems with the DAQ assistant. When it initializes the host of assistant OR no longer works and an unknown error message is given. Don't know where to get corrupted files etc my daq
-
Why can't I access My Documents & Settings folder?
I understand from reading some of the forum messages that Documents & Settings (as well as a few other folders) are now the junction points. However, according to the instructions of a program plug-ins for Photoshop, I bought, I have to install some