PL/SQL :: Dump Values From One Table1 To Table2

Sep 14, 2012

table1-- EMPLOYEE
empno          ename        dept
001            david             20
002            thomas         30

I need query to dump all the values to below table as show below

table2 -- DEPT
empno      info
001          david
001          20
002          thomas
002          30

View 10 Replies


ADVERTISEMENT

SQL & PL/SQL :: Trigger To Update Table1 Based On Condition Of Values In Table2

Feb 20, 2012

I have two tables as

Table LEAVE
Column Type Null Description
APP_NO Number(6,0) Not Null PK Leave Application Number
ECN Number(6,0) Not Null FK Employee Code Number
APP_Date Date Not Null Date of Application
From_Date Date Not Null Date from which the leave starts
TO_Date Date Not Null Date upto which the current application leave remains i.e. end of leave applied for date
NO_OF_Days Number(2,0) Not Null Difference between TO_Date and From_date
LEAVE_TYPE VARCHAR2(3) Not Null Can be one of SL, CL, LWP or LTA
Status VARCHAR2(25) Not Null Can be one of Saved, Rejected or Approved
Remark VARCHAR2(100) Nullable Reason to be put if status is rejected
[code]....

What I really want to do is that when a record is inserted in the LEAVES table (an application for leave is submitted by any employee and if it is approved) then I want to update the _USED values of the corresponding LEAVE_TYPE in the LEAVEENTITLE table which holds values of types of leaves entitled to employee.

For example if 3 rows are inserted in the LEAVES table as
INSERT INTO LEAVES (APP_NO,ECN,FROM_DATE,TO_DATE,APP_DATE,NO_OF_DAYS,LEAVE_TYPE,STATUS,REMARK)
(1,1234,'2012-01-01','2012-01-05','2012- 01-01',5,'SL','APPROVED',null);
INSERT INTO LEAVES (APP_NO,ECN,FROM_DATE,TO_DATE,APP_DATE,NO_OF_DAYS,LEAVE_TYPE,STATUS,REMARK)
(2,1235,'2012-01-01','2012-01-05','2012- 01-01',5,'CL','SAVED',null);
INSERT INTO LEAVES (APP_NO,ECN,FROM_DATE,TO_DATE,APP_DATE,NO_OF_DAYS,LEAVE_TYPE,STATUS,REMARK)
(3,1236,'2012-01-01','2012-01-05','2012- 01-01',5,'LTA','REJECTED','Clash with the annual meet, revise dates');

Then the value of SL_USED in the LEAVEENTITLE table of record corresponding to the ECN = 1234 should be updated with +5 and naturally the SL_ UNUSED value of the record should be updated as SL_ENTITLED - SL_USED. For the APP_NO 2 and 3 none of the values in LEAVEENTITLE should be updated as the STATUS is not 'APPROVED'

I tried with the following trigger, but is compiling with a warning (not showing what the warning is)

CREATE OR REPLACE TRIGGER leaveentitle
AFTER INSERT ON LEAVES
FOR EACH ROW
BEGIN
UPDATE LEAVEENTITLE LVE
SET LVE.SL_USED = SL_USED+(CASE
WHEN :NEW.LEAVE_TYPE = 'SL'&& NEW.STATUS='APPROVED'
THEN :NEW.NO_OF_DAYS
SL_UNUSED=SL_ENTITLED - SL_USED
ELSE 0
END),
[code]....

View 9 Replies View Related

SQL & PL/SQL :: Inserting Row From Table1 To Duplicate Table2

Aug 3, 2010

there are a number of ways I can do this, but I'm just posting this here incase any of you plsql experts know of the best way to program this.

Basically I have 2 tables

INT_CASH_RECORDS

TMP_CASH_RECORDS

Both these tables have exactly the same number of fields and field types - both tables are literally the same. The primary key in both tables is a field called 'cash_id'

How can I transfer a record from INT_CASH_RECORDS into TMP_CASH_RECORDS based in a cash_id, I'm looking for the query string, something like

insert into tmp_cash_records (select * from int_cash_records where cash_id='3342' ...)

View 10 Replies View Related

PL/SQL :: Update Two Columns In TABLE2 From TABLE1

Jan 25, 2013

I know this is a simple question for some of you, but I am new to SQLs,

I have two tables TABLE1 & TABLE2 as below, both tables contains more then 50million records:

SELECT * FROM TABLE1.
&&&&&&&&&&&&&&&&&&&&&&&&&&&
ID                        BUS_FID                WORKID                  STATIONID                 
---------------------- ---------------------- ---------------------- ----------------------
28400000117234         245                    13461428.25           16520877.8            
28400000117513         403                    13461428.25           16520877.8            
28400000117533         423                    13461428.25           16520877.8            
28400000117578         468                    13461428.25           16520877.8            
28400000117582         472                    13461428.25           16520877.8            

SELECT * FROM TABLE2.
&&&&&&&&&&&&&&&&&&&&&&&&&&&
BUS_FID                    ID                 TRPELID                RELPOS                 WORKID                 STATIONID               
---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ----------------------
114                    28400000117658         28400000035396         23.225                                                              
115                    28400000117659         28400000035396         23.225                                                              
116                    28400000117660         28400000035396         23.225                                                              
117                    28400000117661         28400000035396         23.225                                                              
118                    28400000117662         28400000035396         23.225                                                              
119                    28400000117663         28400000035396         23.225                                                              
120                    28400000117664         28400000035396         23.225                                                              

[Code]....

Now I tried to use following SQL to update WORKID & STATIONID columns in TABLE2 but failed. BUS_FID in both tables have been UNIQUE indexed and they can be used as primary keys to join these two tables.

UPDATE (
  SELECT  p.WORKID px,
          p.STATIONID py,
          p.BUS_FID pid,
          temp.WORKID tempx,
          temp.STATIONID tempy,
  
[Code]....

with above code, Oracle returned following errors:

SQL Error: ORA-00904: "TEMPID": invalid identifier
00904. 00000 -  "%s: invalid identifier"

BTW, both two tables contains over 50 million records. So, if you have a better SQL to perform the same task.

View 6 Replies View Related

SQL & PL/SQL :: Show Total Of Details - Table1 In Table2?

May 17, 2011

I got table alpha

CREATE TABLE alpha
(alpha_id NUMBER
alpha_cash NUMBER,
alpha_other VARCHAR2(20)
);

[Code]....

What is the best/a good way to display in alpha the total regarding the alpha_id ?

View 1 Replies View Related

SQL & PL/SQL :: Writing A Procedure For Updating Table2 Based On Table3?

Sep 14, 2011

In my application i have a requirement as follows.I have 3 tables table1,table2,table3.I have 4 tickets for one license number which is related to client table as follows.

table1
=====
license_nbr(pk) name address
=============== ===== =======
LicNo1 test testing

Table2
=====
ticket number(pk) amountto be paid balance_amount license_nbr(fk table2)
tk1 200 200 0 LicNo1
tk2 300 300 0 LicNo1
tk3 400 400 0 LicNo1
tk4 500 500 400 LicNo1

table3
=====
payment table
ticket_number(fk table2) amount paid payment status license_nbr(fk table1)
tk1 1000 excess paid. LicNo1

so now the excess paid amount to be adjusted for the remaining tickets through tk2 to tk4.and only tk4 should remain with 400 the balance amount should be updated accordinglyand i have a license number which is a foreignkey of client table. writing a procedure for updating the table2 based on the table3.

View 14 Replies View Related

PL/SQL :: ORA-00001 / Unique Constraint Because ID Is Primary Key On TABLE1

Jun 27, 2012

I have in a plsql block somewhere a statement like

INSERT INTO TABLE1( id , col)
SELECT id, col
FROM TABLE2;

This statement returns an error ORA-00001: unique constraint because id is a primary key on TABLE1. I would like to know what is the value of id that raised the exception.

View 15 Replies View Related

SQL & PL/SQL :: Delete Table1 Rows Where 3 Fields To Join With Another Table

Aug 13, 2011

I need to delete all the registers where the table 1 does join with table 2 in 3 fields... for example:

delete taba1 t1
where t1.campo1 in ( select distinct(tr.campo1)
from tabla1 tr,
tabla2 t2
where t2.error = 0
tr.campo1 = t2.campo1
and tr.campo2 = t2.campo2

[Code]...

View 4 Replies View Related

Application Express :: Assign Values In Many Rows Based On Search Values?

Jul 25, 2013

I used Region, Process by to search the report which appears as shown above. Then I use Choose Auditors column to select my Auditor and copy paste it into the report under To be Audited By col. Is there a way to automate the process. I am here using a tabular form in APEX. My main aim is to assign auditors based on Region, not equal to Processed by. 

View 4 Replies View Related

Replacing Null Values Of Outer Join With Meaningful Values

Dec 3, 2010

I have a scenario where I have to get all the available dates of a resource. I am using the below query to get it.

Select Avail_Date AS MONTH
, Resource_Id
FROM res_tsk
, (SELECT Rownum - 1 + TRUNC (sysdate) avail_date
FROM Dual
[code].......

The result of this is:

Month Dates Resource_ID
12/3/10 0:00 NULL
12/4/10 0:00 NULL
12/5/10 0:00 NULL
12/6/10 0:00 100033868

As I am doing a outer join, if the resource is not available on a particular day the resource_id is coming as NULL as it is not available. Is there any way to populate this NULL resource_id with the original resource_id as the resource_id is same for all the result set.

I need the output to be

Month Dates Resource_ID
12/3/10 0:00 100033868
12/4/10 0:00 100033868
12/5/10 0:00 100033868
12/6/10 0:00 100033868

View 3 Replies View Related

SQL & PL/SQL :: How To Insert Values Into Another Column By Comparing Values Of Two Columns Of Same Table

Dec 23, 2010

My scenario is to insert values into 'out' column by comparing 's' and 'IP' columns of temp table.The exact situation is at first need to go to ip column,take a value and then go to source column and check for the same value of ip which is taken previously.Then after corresponding ip of that source column should be inserted back in previous source column.

The situation is marked clearly in file which i am attaching with '--' comments at respective places.I am also pasting the code which i tried out,unfortunately it is giving error as exact fetch returns more than requested number of rows since there are duplicates in the table.I tried it using nested for loops.Also implemented using rowid,but it didnt work.

fixing the errors or if there is any new logic that can be implemented.

DECLARE
i_e NUMBER(10);
BEGIN
FOR cur_1 IN(SELECT IP from temp where IP IS NOT NULL)
LOOP
FOR cur_2 IN(SELECT IP from temp where s=cur_1.IP)

[Code]...

View 9 Replies View Related

Trying To Import Database Dump

Jul 26, 2010

I am trying to import database dump using the following command

CODEimpdp system/xxxx@xxxx schemas=staging
remap_schema=staging:staging directory=DUMPDIR dumpfile=staging.dmp logfile=impdpstaing.log
TRANSFORM=SEGMENT_ATTRIBUTES:n

its importing data fine upto some stage after that oracle gives the following error

CODEProcessing object type SCHEMA_EXPORT/JAVA_SOURCE/JAVA_SOURCE
ORA-39097: Data Pump job encountered unexpected error -1423
ORA-39065: unexpected master process exception in DISPATCH
ORA-01423: error encountered while checking for extra rows in exact fetch
ORA-04030: out of process memory when trying to allocate 123404 bytes (QERHJ has
h-joi,kllcqas:kllsltba)

ORA-39014: One or more workers have prematurely exited.Job "SYSTEM"."SYS_IMPORT_SCHEMA_04" stopped due to fatal error at 11:42:03

I though its due to lack of memory, so i have increased pga_aggregate_target=512MB to 600MB still i am getting a same error. System configuration:

Microsoft windows Server 2003 R2,
standard Edition
Service Pack 2

Intel® Xeon CPU 3.00GHz,
4 GB RAM
SWAP MEM: 4106 MB

View 2 Replies View Related

RMAN :: How To Do Archivelog Dump

Sep 13, 2012

how can I do an archivelog dump?

View 3 Replies View Related

Possible To Use Export Dump From Oracle

Sep 5, 2012

I want to know whether it is possible to use export dump from Oracle 11.1.0.6 WIN 2003 SP2 Server to Oracle 11.1.0.6 Windows 7 standalone Machine (Test machine).If yes how to do it as i have tried but it is returning errors.So i tried to do it by pre-creating Tablespaces but even then its failing.

Note : I am Using EXPDP and IMPDP

View 4 Replies View Related

SQL & PL/SQL :: Ad Hoc MINUS - Compare Values In Code To Values In Table

Oct 28, 2013

I am searching the simplest way for ad hoc MINUS.I do:

SELECT *
FROM uam_rss_user_XXXXXXX
WHERE host_name IN
('XXX0349',
'XXX0362',
'XXX0363',
'XXX0343',
'XXX0342',
'XXX0499',
[code]....

and look in the table which values are missing (values that are in host_name IN but not in actual table).is there a simpler way for doing an ad hoc MINUS? I know to insert values in temp. Table. How are experienced Oracle pros doing this task?

View 6 Replies View Related

Import Database Dump File?

May 28, 2011

i had import a database dump file & this database has username/password say abc/xyz. my database username/password is system/vinod. after importing i'm unable to login with system/vinod(error:invalid username/password) and one strange thing was happened;a user was created with abc/xyz(username/password). after altering my user only then i'm able to login with my original user.

View 1 Replies View Related

Error While Doing Import Using Data Dump?

Dec 8, 2012

we have a requirement to export full database dump from source database to target database.

source database - Oracle 11.2.0.1
OS version - AIX 5.3
character set: UTF8

target database - Oracle 11.2.0.3
OS version - 6.1
character set: AL32UTF8

i did export from source database and give it to DBA of target database as dump files.

when he tried to import using this dump, he got the following error for 3 tables

ORA-02374: conversion error loading table
ORA-12899: value too large for column
ORA-02372: data for row

DBA is telling there is character conversion issue and i need to change the source database character set (NLS_CHARACTERSET) and then export these 3 tables separately.

But on analysis, i found UTF8 is subset of AL32UTF8 and hence oracle would do this conversion implicitly.

My query is:

1. For this issue, only solution is to change the source database character set as same as target database, then do the export or any other way available?

2. If i need to change the source database character set, would it affect other data available there?

3. Is there any way available doing character set conversion while doing "expdp" on the fly?

4. Is this issue comes because of oracle version (11.2.0.1 to 11.2.0.3 ) or OS (AIX 5.3 to 6.1)?

View 2 Replies View Related

Server Utilities :: Importing 9i Dump Into 10g?

Jun 22, 2011

how can i import the oracle 9i dump file into 10g database, while iporting i get following error imp-00002 fail to open dump file

View 4 Replies View Related

SQL & PL/SQL :: How To Dump And Transfer Files With Same Table

Apr 6, 2011

how can i dump and transfer it to another year with the same table

View 6 Replies View Related

Import A Dump File (oracle 10g)

Mar 14, 2012

my problem is that whenever i want to import a dump file(oracle 10g) oracle just import 4 tables and then goes into hang state(not responding) i'm using old import method (not datapump).

View 1 Replies View Related

SQL & PL/SQL :: Output Of Oracle Function Dump

Oct 18, 2010

what the following output of the oracle function "dump" means?

query: select dump(:new.messaging_state) from dual

output:

Typ=2 Len=1: 193

I need this debug output because I want to know which value the program wants to write in the columns messaging_state.

The update fails because of a parent Key violation.

View 2 Replies View Related

How To Clear Audit Files In Dump In HP-UX

Mar 31, 2013

i got many audit file in a dump it is on hp-ux linux normally in linux i use to give

find -name "*.aud" -mtime +20 -exec rm {} ;

what to give in HP-UX linux ?

View 2 Replies View Related

Globalization :: Bad Character Set In Dump File?

Jul 23, 2013

IMPDP-ing a dump file that someone has handed me over into Oracle XE results in special characters, i.e. Umlauts, being messed up.  

In a hex editor, the dump file shows  a) the token WE8MSWIN1252 near the beginning, but b) Umlauts obviously being encoded in DOS 850, for example "König" is encoded as 4b 94(!) 6e 69 67. Does this prove that the dump file is badly formatted and that I have to resign myself to the complicated approach mentioned at the end of [URL]...

View 4 Replies View Related

Import Only 1 Table From Full EXP Dump File?

Jan 14, 2011

We have an old full export .dmp file from a 10g db and there are 451 records in one specific table that we need to export. Is it possible to IMP just the one specific table from a full dump? Or, another option, can we extract the records from the one table in the .dmp file into an xml file?

View 14 Replies View Related

Circular Synonym Error While Importing Dump?

Mar 5, 2011

I have a db instance in which several schemas are there. I have taken a dump of a particular schema(user) using oracle exp command

exp <username>/<passwd>@<dbname> FULL=y FILE=export.dmp LOG=exportdb.log CONSISTENT=y

Now I have another db where I wish to import the above dump. This is not a empty db, however, I have dropped the particular user from this db for which I have created a dump above. Then I have created the same user using 'create user....'.And now I am trying to import the above dump into this.

imp '<username>/<passwd>@<dbname>' FILE=C:\DUMP\Dump\export.dmp LOG=C:\DUMP\logs\imp_dmp.log FULL=Y

import goes fine but I gets the circular synonym error for some of the types.

IMP-00003: ORACLE error 4055 encountered
ORA-04055: Aborted: "O_BULK_TARGET_SELECTOR" formed a non-REF mutually-dependent cycle with "T_GENERAL_IDLIST".
ORA-06550: line 5, column 25:
PLS-00421: circular synonym 'PUBLIC.T_GENERAL_IDLIST'

The db from which I created the dmp has no errors for these objects, but while impoting it gives these errors.I have even tried taking the whole database dmp(not a particular user), and importing it into full empty database. Then also I gets the same error.

View 3 Replies View Related

Server Administration :: How To Read Dump Contents

Jan 4, 2012

How to read the treedump contents of a index IDX_TB_TEST_N1?

SQL> select object_id,object_name from dba_objects where owner='HXL';

OBJECT_ID OBJECT_NAME
---------- ---------------------------------------------
51786 IDX_TB_TEST_N1

alter session set events 'immediate trace name treedump level 51786'

/u01/app/oracle/admin/oracl/udump/oracl_ora_2679.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1

[code]...

View 6 Replies View Related

Server Utilities :: Reading From Oracle Dump

Jun 14, 2006

Is there is any way of reading from oracle dump file?

View 16 Replies View Related

Server Utilities :: Dump Table From One To Other Schema

Mar 4, 2010

i need to dump the table from A schema to B schema with different table name.

Suppose i have TABLE A IN "A" SCHEMA i need to dump the table with DATA+sTRUCTURE in " B"SCHEMA WITH TABLE NAME AS B.

View 3 Replies View Related

No Package Bodies In Full Export Dump?

Feb 2, 2011

When exporting a 11g R2 database with expdp using full=y the logfile does not show that package bodies have been exported

(DATABASE_EXPORT/SCHEMA/PACKAGE/PACKAGE_SPEC is processed but no DATABASE_EXPORT/SCHEMA/PACKAGE_BODIES/PACKAGE/PACKAGE_BODY)

When importing the dump into an empty database only package specs (besides the other objects) have been imported but all package bodies are missing.

View 5 Replies View Related

Server Utilities :: Dump File Determination

Mar 29, 2013

Is it possible to determine whether the dump file is created using data pump export or normal export method by just looking at dump file, If yes, how ?

Why i am asking such question is...normal export and data pump export would create a dump file with an same extension filename.dmp. So to avoid confusion during import, i would want to determine by what method the dump file was created.

Also this would be useful for me at the scenario when the customer sends me only the dumpfile and ask to import into target database. ( may be the customer don't know in what method the dump file was created ).

View 23 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved