PL/SQL :: Data Transformation Query

Jun 10, 2013

newish to Oracle from an and am trying to do the following...  if mytable.col1 is not blank, then copy mytable.col1 to mytable.col2 BUT, it needs reformatting during the copy.  Both columns are varchar2 col1 being 15 wide and col2 being 20 wide.  I need to transform from 'PACKAGEabcde001' to 'PACKAGEabcde 00001'  so yes, those 5 extra characters are indeed 3 spaces and 2 extra zero's. 

View 2 Replies


ADVERTISEMENT

Quick Data Transformation

Jun 10, 2013

if mytable.col1 is not blank, then copy mytable.col1 to mytable.col2 BUT, it needs reformatting during the copy. Both columns are varchar2 col1 being 15 wide and col2 being 20 wide.

I need to transform from 'PACKAGEabcde001' to 'PACKAGEabcde 00001'

so yes, those 5 extra characters are indeed 3 spaces and 2 extra zero's.

View 1 Replies View Related

SQL & PL/SQL :: Data Transformation / Remodel Some Data For Processing

Feb 6, 2011

I am trying to remodel some data for processing, as unfortunately the original data structure is unsuitable.

My requirements are to recreate the data as a view which can then be query'd directly by the client, and therefore would like to encapsulate all the required transformation within one SQL query.Here is a sample of the table structure i'm faced with:

SQL>
SQL> l
1 create table insane
2 (
3 dept number not null,
4 firstname varchar2(30),
5 surname varchar2(30),
6 city varchar2(30),
[code]....

So, i'd like to be able to turn this on it's head and come out with data that looks something like this (which, for the purpose of this example, is fabricated manually):

SQL> select * from sane
2 /

DEPT_ID PERSON_ID FIRSTNAME
---------- ---------- ------------------------------
SURNAME CITY
------------------------------ ------------------------------
1 30 Peabo
[code]....

View 11 Replies View Related

Spatial :: Parameters For 2D Affine Transformation

Jul 13, 2012

I have the following parameters for 2D affine transformation:

Two translation:
tx=2754.3661 and ty = -237.0731
and rotation in radians: -.001016214498072193185827329

Is this specification correct:

SDO_UTIL.TO_WKTGEOMETRY(SDO_UTIL.AffineTransforms (
geometry =>myGeometry,
translation => 'TRUE', tx => 2754.3661, ty => -237.0731, tz => 0.0,
scaling => 'FALSE', psc1 => NULL, sx => 0.0, sy => 0.0, sz => 0.0,
rotation => 'TRUE',
p1 => MDSYS.SDO_GEOMETRY(2001, NULL, MDSYS.SDO_POINT_TYPE(0, 0, NULL), NULL, NULL), line1 => NULL,
angle => -.001016214498072193185827329,
dir => -1,
shearing => 'FALSE', shxy => 0.0, shyx => 0.0, shxz => 0.0, shzx => 0.0, shyz => 0.0, shzy => 0.0,
reflection => 'FALSE', pref => NULL, lineR => NULL, dirR => -1, planeR => 'FALSE', n => NULL, bigD => NULL
))

BTW, in PostGIS it works correctly: ST_Affine (myGeometry, cos(rotation), sin(rotation), -sin(rotation), cos(rotation), tx, ty));

View 6 Replies View Related

Reports & Discoverer :: Excluding SQL Query Data When Linked With XML Query?

Apr 26, 2013

I have data in a table and another in XML file,I used SQL query to retrive the data placed on the table, and link this query with XML query that retrieves the data stored in the xml file. The data stored in the table and xml file sharing a key field, but the xml contents are less than what in the table.I want to show only the data shared between the two queries, how can I do that?

e.g.:

Table emp:

e_id | e_name | e_sal
023 | John | 6000
143 | Tom | 9000
876 | Chi | 4000
987 | Alen | 7800

XML File

<e_id>
143
876

So, I want the output to be:

e_id | e_name | e_sal | e_fee
143 | Tom | 9000 | 300
876 | Chi | 4000 | 100

View 2 Replies View Related

SQL Query To Club Data If Range Data Is Continuous

Nov 26, 2006

For e.g.

if my data is as follows

EX_START_DATE EX_END_DATE EX_CHARGE

5/1/2005 5/5/2005 11:59:59 PM 10
5/6/2005 5/7/2005 11:59:59 PM 10
5/10/2005 5/15/2005 11:59:59 PM 10
5/17/2005 5/19/2005 11:59:59 PM 10
5/20/2005 5/25/2005 11:59:59 PM 20

the record
5/6/2005 5/7/2005 11:59:59 PM 10
is in continuation for
5/1/2005 5/5/2005 11:59:59 PM 10 with the same ex_charge
so i need the output as

5/1/2005 5/7/2005 11:59:59 PM 10
5/10/2005 5/15/2005 11:59:59 PM 10
5/17/2005 5/19/2005 11:59:59 PM 10
5/20/2005 5/25/2005 11:59:59 PM 20

and the remaining rows as it is
(Note :date in mm/dd/yyyy format)

View 6 Replies View Related

SQL & PL/SQL :: Query Which Gives Data

Jun 4, 2013

I actually have a query which gives me the data I need. I try to get the same data with the same logic but with using JOIN so that I can have a proper code.I am pasting you first the bad one which works and then the one that I did which does not work..I am also attaching the file where you can see both of queries easier.

------------------------------------------------------
OLD BAD QUERY - WORKING
-------------------------------------------------------
SELECT
NAMEINDIVIDUAL.FIRSTNAME PRENOM_CORRESP,
CORRESP.NAME NOM_CORRESP,
NAMETELECOM.TELECOMNUMBER TEL_CORRESP
FROM
NAME APPLICANT,
, CASENAME CNAPPLICANT,
, NAME CORRESP,
, GLOBALRELATION RELCORRESP,
[code]....

View 19 Replies View Related

SQL & PL/SQL :: Return Only One Row Of Data On Query?

Nov 28, 2012

work_order unitid frommi tomi frompm topm
2666054111 06-154 77.000 85.000 77.370 null
2666054111 06-154 77.000 85.000 null 85.370
2666054111 06-154 77.000 85.000 null null

I used select distinct(work_order) to come up with the three different possible scenarios the problem is that i need all this information on a single row

work_order unitid frommi tomi frompm topm
2666054111 06-154 77.000 85.000 77.370 85.370

this is a conversion for distance. when i get this to work properly, it will generate reports on thousands of work orders with their converted distance markers.

View 3 Replies View Related

PL/SQL :: Test Data In Query?

May 29, 2013

I suspect it uses TABLE, CAST and/or MULTISET functions in a query .. but reading the docs on those, I can't seem to piece together how to do it.

When I piece together a sample/test query, I usually do something like this:

WITH data AS
( SELECT 123  id,  'abc'  col1  FROM dual UNION ALL
SELECT 234, 'def' FROM dual UNION ALL
SELECT 345, 'xyz' FROM dual
)
SELECT *
FROM data -- usually more complex query here

However, I saw somebody do this without using the UNION ALL .. they did something with TABLE ( ... ) ? it seemed "simpler" than the UNION ALL method I've used previously

View 10 Replies View Related

SQL & PL/SQL :: Query To Delete Two Weeks Old Data?

Sep 12, 2013

I want to delete the records grater than two weeks old.From Saturday to Friday we are considering as Week.

P_ID CREATED_DT
105 28/AUG/2013
106 29/AUG/2013
107 30/AUG/2013
108 31/AUG/2013
109 01/SEP/2013
110 02/SEP/2013

[code]....

From 28/AUG/2013 to 30/AUG/2013 records has to be deleted becuase thease records are two weeks old.

From 31/AUG/2013 to 06/SEP/2013 records belongs to one week and from 07/SEP/2013 to 13/SEP/2013 belongs to another week.Today is 12/SEP/2013 so from 06/SEP/2013 to 12/SEP/2013 should be existed in the table.Once date changed to 13/SEP/2013 then from 31/AUG/2013 to 06/SEP/2013 records has to be deleted.

I am posting table and insert scripts.

CREATE TABLE process_data(p_id NUMBER,CREATED_DT DATE);
INSERT INTO process_data VALUES(TO_DATE('28/AUG/2013','DD/MON/YYYY');
INSERT INTO process_data VALUES(TO_DATE('29/AUG/2013','DD/MON/YYYY');
INSERT INTO process_data VALUES(TO_DATE('30/AUG/2013','DD/MON/YYYY');
INSERT INTO process_data VALUES(TO_DATE('31/AUG/2013','DD/MON/YYYY');
INSERT INTO process_data VALUES(TO_DATE('01/SEP/2013','DD/MON/YYYY');

[code]....

View 3 Replies View Related

SQL & PL/SQL :: Query To Fill Data From Top Records

Mar 5, 2010

I want to fill data from the above records in the same column. How to do that by use SQL command ?

from
Invoice_No.Line_Item
000011
2
3
000021
2
000031
000041
2
000051

to
Invoice_No.Line_Item
000011
000012
000013
000021
000022
000031
000041
000042
000051

View 10 Replies View Related

Forms :: How To Generate XML Data Of SQL Query Through 10g

Jul 19, 2013

I have got requirement to generate a .XML format of a select query in a particular folder in server. The XML coding of a select query i got through DBMS_XMLGEN.getXML package.

SELECT DBMS_XMLGEN.getXML('SELECT * FROM EMPL_NEW') FROM dual

but through forms i am unable to create it!! and the result output should be saved as .xml in a particular folder in server.

View 3 Replies View Related

SQL & PL/SQL :: Query To Retrieve The Data Without Iteration?

Dec 27, 2010

I have one table as shown below,

CREATE TABLE MAT
(matrl varchar2(100),
date_man date,
weight number(10)
);

INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat1','12-DEC-10',100);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat2','13-DEC-10',200);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat3','21-DEC-10',300);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat4','26-DEC-10',400);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat5','22-DEC-10',500);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat6','02-DEC-10',600);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat7','23-DEC-10',700);
INSERT INTO MAT(Matrl,DATE_MAN,WEIGHT) VALUES ('mat8','07-DEC-10',800);

The data will look like this .

matrldate_manWeight
mat112-Dec-10100
mat213-Dec-10200
mat321-Dec-10300
mat426-Dec-10400
mat522-Dec-10500
mat602-Dec-10600
mat723-Dec-10700
mat807-Dec-10800

I need to order by this data in terms of date and need to get the data as shown below. Acc_wt is accumulated weight till the material.

Date Weightacc_wt
mat602-Dec-106000
mat807-Dec-10800600
mat112-Dec-101001400
mat213-Dec-102001500
mat321-Dec-103001700
mat522-Dec-105002000
mat723-Dec-107002500
mat426-Dec-104003200

Can we make use of oracle lag and lead functions here?Or some other methods?

View 6 Replies View Related

SQL & PL/SQL :: Query To Get Data In Desired Format?

May 29, 2012

CREATE TABLE DATA1
(
ID NUMBER(6),
DAT_ID NUMBER(6),
RNK NUMBER(2)
);
Insert into DATA1
(ID, DAT_ID, RNK)

[code]....

now after having this data from "data1" table , we need to get the row from "data2" table.in "data2" table there are total 6 combination on basis of "POS,ORDER" [ there are only 2 "ORDER" i.e. 'F' and 'S' , where as POS value can be changed, BUT THE "POS,ORDER" COMBINATION WILL HAVE ONLY 6 UNIQUE COMBINATION. ] so, for "POS and DAT_ID" combination we need to get the lowest rank data first, if that is not present then get the other rank given in "DATA1" table and so on and if no rank is present then select the NULL row row data from "DATA2" table for ex: in DATA1 table for count(*)>1 and id=1, we have data as

--------------
IDDAT_IDRNK

11231
11242
11253
--------------

so, in "DATA2" table, first we will see for "POS and ORDR" combination which DAT_ID is present, i.e. in case od POS=11 and ordr=F, we will select

111231FD1

as it is having lowest rank in "DATA1" table and it is present in "DATA2" table,

for POS=12 and ordr=F, we will select

121242FD1

as we don't have "123 and 1" in "DATA2" table so we will select the next rank given in "DATA1" ( i.e. 124 and 2 ), similarly , for POs=31 and ordr=S, we will select, as this is the next available rank and DAT_ID present in "DATA2" table

1D131S1253

and if there is no rank present from "DATA1" table in "DATA2" table then we will select the NULL row, i.e. for POS=21 and ordr=F, we need to select :

1D121F

"there will be 6 row for each id"

the output we want is :
-----------------------------------------
IDNAMEPOSORDER DAT_IDRNK
1D111F1231
1D112F1242
1D121F
1D12321S1231
1D2322S1242

[code]....

View 4 Replies View Related

Forms :: Data Block Using Query?

Mar 1, 2010

I wanna to load data in a data block using sql which using multiple table, views based on condition

View 7 Replies View Related

PL/SQL :: Query Pull Only Fields That Contain Data

Aug 9, 2012

In the database we use for transfer articulation, there are numerous tables delivered with the product. The institution decided not to use certain fields, and all instances of those fields have no data. In other words, there might be a field in the table called INSTCD, but no records in the table have ever inserted any data into that particular field. In the table there are thousands of records, and we don't necessarily know which of the fields have never been used (no list has been retained and no one who initially was involved in the decisions is available to ask), as there are multiple fields in each table. How can I write a query that pulls only the fields in the table that contain data. In the example below, the SHRTRIT table contains a field called ACTIVITY_DATE, but there is no data in any record in that particular field, so I don't want it to show up on the output. In this particular case, I KNOW not to pull this field in a SELECT, but in a case where there might be 130,000 records and I DON'T know if a field has records in it, how could I do that?

if the question I'm asking doesn't make sense and I'll attempt to word it better.

create table SHRTRIT
(
SBGI_CODE     VARCHAR2(6)     NOT NULL,
SBGI_DESC     VARCHAR2(10),
ACTIVITY_DATE     VARCHAR2(10)
)

[Code]....                                                                                                                                                                            

View 9 Replies View Related

PL/SQL :: How To Use Materialized View And Its Data From A Query

Nov 15, 2012

I have got a simple materialized view question.

I have a view which is taking long time to get back results and this view is being used in various user queries. I noticed that the SQL of the view access some tables, data of them changes rarely. So it makes sense to retrieve that data in a materialized view and somehow re-use it.

My question is how can I use the materialized view and it's data from a query.

View 2 Replies View Related

PL/SQL :: Query To Identify Delimiter From Data?

Sep 2, 2012

I am trying to write a code to identify the delimiter in the file ( which is in the form of table(id, raw) in system)then I take this delimiter and pass it as a parameter to SP which perform cleaning of this file(table) and creates another clean table.

The problem I am facing is until now the file was coming with one fixed (TAB) delimiter, but now it has come with different (SPACE), now here I want to develop the code to identify the delimiter place it in a variable an pass this as parameter to cleaning SP.

--here i want to develop code to identify delimiter from hosts_equiv file which has data as below

select * from hosts_equiv where left(raw,1) not in ('#','*') and isnull(raw,'')<>''

Raw                  id
----------------        ---
hiper USER1        1
hiper2 USER1      2 
APX    user2       3

Need to identify delimiter between e.g. hiper USER1  and pass it as a parameter to the raw_parse sp

declare Tab  varchar(10)
set Tab = char(9)
exec raw_Parse
'hosts_equiv',   -- From table ( entire file content is stored as table with Id record no sequence generated)
'CleanedHosts_Equiv', -- To table name, when passed it will clean the from table and places the cleaned data in to_table

[code]....

View 3 Replies View Related

XML Type Column Data XML Query?

Mar 16, 2013

I have extracted in the following XML document some Mpeg7 visual descriptors from an image and I saved it in an XMLType column. I would like to use XMLQuery to extract the data from the Value node. how write such a query. I could not get the proper Xpath to any node.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Mpeg7 xmlns="http://www.mpeg7.org/2001/MPEG-7_Schema" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<DescriptionUnit xsi:type="DescriptorCollectionType">

[code]...

View 1 Replies View Related

Query On Formatting Data In A Specific Way In Oracle

Apr 25, 2010

I am currently doing a project where i need to write a stored procedure which will be doing the following-

i)it will retrieve multiple columns from multiple tables in a single database(through join) based on certain conditions
II)then it will store the entire data in a certain field(File_data) of staging table

inside file_data a header and a trailer will be present with the records.also the field values will be pipe separated and a new record will start in a new line.

So,the data inside the file_data of staging table will look like this-

H|v1000
transdate|ordnmb|deposite_amt|order_status....
12-nov-09|123456|23.8|C...
4-dec-07|234567|67.7|R...
..........
7-jan-04|567890|54.7|x.....
T|234(record count)

i did this formatting using java, but my project leader wants me to do the formatting using SP,and wants me to use staging table.

View 7 Replies View Related

PL/SQL Hierarchical Query - Select Data In Specific Way

Apr 19, 2013

I have a table that has hierarchical data within it. I need to select this data in a specific way, showing the hierarchy.

E.g. Data in table (Key is unique)

Lvl KeyParKey HasChild
1k101
1k200
1k301
1k401
2k34k10
2k22k11
2k24k10
2k13k30
2k52k30
2k35k30
2k13k30
2k11k40
3k56k220
3k109k221
3k67k220
4k61 k1090
Etc etc....

That�s generally the format the values would appear in the table if I just did a standard select. I want it displayed in a more hierarchical Parent � child way.

The format I need to get out is as follows:
Lvl KeyParKey hasCh
1k101
2k34k10
2k22k11
3k56k220
3k109k221
4k61 k1090
3k67k220
2k24k10
1k200
1k301
2k13k30
2k52k30
2k35k30
2k13k30
1k401
2k11k40

View 1 Replies View Related

SQL & PL/SQL :: Finding Percentage Using Query From Table Data

Jun 23, 2010

SL_NoStatus
191502Implemented
191690Implemented
190998Implemented
191346Implemented
190541Implemented

[Code]..

my above table consists of two columnc sl_no and Status,col1 indicates the process no and the status indicates it is implemented or cancelled or failed during implementation.

i need to find the percentage of the implemented+cancelled process over failed..

test case:
lets consider,
A->count(Sl_NO)
B->Count(STATUS) where STATUS='Implemented'

[Code]..

i think i have satisfactorily given enough data.. make it out using sql query..

View 3 Replies View Related

SQL & PL/SQL :: Select Statement - Inner Query Returns Data

Aug 23, 2012

I am new to oracle. I am creating a view, where in the inner query returns below kind data.

column1 column2
-------------------
a y
a y
b y
b n
c y
d n

I want to extract all column1 values which always has "y" in column2.

In this case, output has to be

output
------
a
c

View 10 Replies View Related

SQL & PL/SQL :: Query To Convert Data In Single Column?

Oct 11, 2012

I have a below requirement let me know the optimized query.

Create table test_123 ( sr varchar2(1000));

Insert into test_123 values ('1,2,3,4,5');
Insert into test_123 values ('6,7,9,10,11');
Insert into test_123 values ('9,2,3,8,5');

I need output as :

Sr_output

1
2
3
4
5
6
7
8
9
10
11

I need all the values in the column sr in a single column and mutiple rows.

View 2 Replies View Related

Data Guard :: Query Regarding Standby Server

Oct 25, 2011

I want to know that what will happen when I will resize database file from 32G to 5G on primary server or add file to tablespace. Will standby server do the same automatically or I have to to something with standby server?

View 4 Replies View Related

SQL & PL/SQL :: Getting Query For Current Year Data Up To Sysdate?

Jun 19, 2012

I have a table for exampl,

emp sal date
111 200 03-mar-2011
100 200 03-mar-2012
15 200 06-mar-2012
17 200 03-mar-2003
178 200 03-mar-2004
11 200 11-jun-2012
101 200 19-jun-2012

i need sql querry to get current year records upto sysdate.i.e for example this year 2012 so i need all the 2012 year records upto sysdate.

my output like this.....

emp sal date
100 200 03-mar-2012
15 200 06-mar-2012
11 200 11-jun-2012
101 200 19-jun-2012(upto sysdate)

View 2 Replies View Related

SQL & PL/SQL :: Creating Sequence On Duplicate Data Through Query

Nov 18, 2011

I have a table with three columns mentioned below :

Col1 Col2 Col3
121
221
331
431
531
622
722

Col1 is the primary key.I need a sql query which will show the data set mentioned below :

Col1 Col2 Col3 Seq
121 1
221 1
331 2
431 2
531 2
622 3
722 3

I need all the 7 records to be displayed.

View 16 Replies View Related

PL/SQL :: Transposing Data And Joining The Results To A Query

Apr 10, 2013

I am new to writing queries for an oracle database and I was giving a bit of challenge. Here's the situation. I have 3 tables I am using. 2 of the tables are being used to transpose people's names from rows to columns by account number (there are multiple people associated with each account). The last table is a pretty straight forward query. I can run each query by itself and I get the results I want. But when I try to compile the two together, I start getting a variety of errors. Below is the two queries:

Query 1 (returns about 1,500 rows):
SELECT DISTINCT CAST (EIS_DW.ACCTCOMMONLOAN.ACCOUNT as VARCHAR(20)) as ACCOUNT_NUM,
EIS_DW.ACCTCOMMONLOAN.ACCOUNT_STATUS,
EIS_DW.ACCTCOMMONLOAN.MINOR_DESCRIPTION,
EIS_DW.ACCTCOMMONLOAN.OWNER_NAME,
[code]......

Query 2 (returns about 570 rows):
SELECT ACCTNBR,
max(DECODE (rn , 1, FULLNAME)) GUARANTOR_1,
max(DECODE (rn , 2, FULLNAME)) GUARANTOR_2,
max(DECODE (rn , 3, FULLNAME)) GUARANTOR_3,
max(DECODE (rn , 4, FULLNAME)) GUARANTOR_4,
[code]....

Ideally, I want to join these two queries on ACCOUNT and ACCTNBR. I have tried working my first query into my second query, but the best I get with that, is the 570 or so accounts, not all the accounts.

View 4 Replies View Related

SQL & PL/SQL :: Query To Get Data For Latest Date For Some Purchases?

Mar 13, 2012

I need a query to get data for the latest date for some purchases.

My expected output would be

Date - Item - Price - Qty
10/6/2011 10129 .5 1
6/8/2011 10130 13.33 9
2/6/2011 10131 21.74 24

Below are the scripts for this.I have also attached it.

CREATE TABLE XX_PO_LINES_ALL
( CREATION_DATE DATE,
ITEM_ID NUMBER,
UNIT_PRICE NUMBER,
QUANTITY NUMBER )

[code]......

View 4 Replies View Related

Forms :: Query Data Source Columns

Jul 19, 2013

I'm new to Oracle Forms 10g.

When I create a data block based on a table using Data Block Wizard, the block's Query Data Source Columns property is automatically populated with column definition entries corresponding to the columns of the base table.

I tried making changes to these entries, for example by changing the data types to wrong data types or even deleting them, and I found that those changes had no effect on the block at all. The form was still working as I wanted.

What is exactly the role of the block's Query Data Source Columns property.

The F1 key help says "The Query Data Source Columns property is valid only when the Query Data Source Type property is set to Table, Sub-query, or Procedure". So, explain in each context of Query Data Source Type.

View 2 Replies View Related







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