SQL & PL/SQL :: Fill VARRAY Using Table Fields And While Loop?

Jun 13, 2011

I am using arrays on this procedure but would like to use a WHILE LOOP to fill the array. The first element uses a balance forward amount unlike the next 11 elements so I would think I have no other choice for the first element.

jde_account_balances is the table name that stores the amounts.

Here is what I currently have coded:

X INTEGER;
Y INTEGER;
Z INTEGER;

[code]...

View 7 Replies


ADVERTISEMENT

SQL & PL/SQL :: Table And VArray

Aug 23, 2011

i have a doubt in plsql table and varray.. is this two things data will write on disc or it will perform through ly a memory level? if its in memory level i need a document about that.

View 14 Replies View Related

SQL & PL/SQL :: Move Data From Varray Column To A Table

Mar 28, 2013

I have to move the data from a Varray column to a table.

Lets say I have created a Varray as described below,

create or replace TYPE "BT_TYPE" AS OBJECT (
R_ID NUMBER,
P_EVENT VARCHAR2(100))
/

create or replace TYPE "BT_VR" AS varray(20) of BT_TYPE
/

And I have a used this Varray as the column datatype in table

Create table BT_MASTER(
BT_ID_SEQNUMBER(5),
BT_DETAILBT_VR);

And this table contains data.

I want to move the data in the VARRAY column BT_DETAIL to another table. I have create a staging table BT_STG which contains a surrogate key column and the columns from the VARRAY. I am creating this staging table at run time.

Create Table BT_STG(
BT_STG_ID NUMBER(5),
R_ID NUMBER(5),
P_EVENT VARCHAR2(100)
);

One way to create this staging table is to query the data dictionary views to get the VARRAY object's columns, datatyeps and create it.

Is there any other simpler way by which I could create a table similar to a VARRAY/Object?

Something similar to,

create table test as select * from BT_VR

View 4 Replies View Related

PL/SQL :: Uses And Advantages - Associative Array / Nested Table And Varray?

Jun 4, 2013

What is the real time uses for Associative array, nested table and varray ?

View 2 Replies View Related

How To Right Justify And Zero Fill In Oracle

Dec 9, 2008

How to right justify and zero fill in oracle ?

as example input data is '1' and i want to insert '0' in front of the input data and the output will be 01 .

View 2 Replies View Related

SQL & PL/SQL :: Assigning ID (Fill SID Column)

Feb 4, 2013

I have a table with 200k entries, which has ~12k unique combination of columns that I wish to assign an ID to. My real world problem is with addresses and street components (of which nulls are allowed); but this should be a reasonable example.

DROP TABLE tt;

CREATE TABLE tt AS
SELECT ROWNUM id,
CASE
WHEN MOD(ROWNUM, 107) = 0 THEN NULL
ELSE MOD(ROWNUM, 101)
END
c1,
CASE

[Code]...

Now I have 3 ways to assigned an ID (fill the SID column).

The first is congruent with the method most commonly used, but seems especially slow in this case. I think this is due to the COALESCE/TO_CHAR usage. Can this be optimized?

DECLARE
CURSOR c1 IS
SELECT a.*, sid_seq.NEXTVAL sid
FROM (SELECT DISTINCT c1, c2 FROM tt) a;
BEGIN
FOR s IN c1 LOOP
UPDATE tt d

[Code]...

The second I've made relies on the usage of a temp table, which I really don't like, but it is faster; so that is something at least.

CREATE TABLE ttt AS
SELECT a.*, sid_seq.NEXTVAL sid
FROM (SELECT DISTINCT c1, c2 FROM tt) a;

[Code]...

The third discards the sequence, and uses dense_rank. This allows us to use the ID (which might have an index, whereas c1 and c2 will not).

MERGE INTO tt d
USING (SELECT id, (SELECT COALESCE(MAX(sid), 317) FROM tt) + DENSE_RANK() OVER (ORDER BY c1, c2) sid FROM tt) s
ON (d.id = s.id)
WHEN MATCHED THEN
UPDATE SET d.sid = s.sid

The ideal solution would use the SEQUENCE, not use a temporary table and match/merge/update based on ID, and be 'fast'; but I cannot conceive of such a solution; does one exist? What would you do?

View 2 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

SQL & PL/SQL :: Using Optional Parameters To Fill Update Statement?

Jul 17, 2011

I need to use funtion optional parameters to construct an update statement in the funtion body. I have two scenarios, either both parameters are not null or the 2nd is null. Do I have to use

IF
(param2 is null)
THEN
udpate using param1 only
ELSE
update using both param1 and param2
END IF;
or is there a shortcut to do this?

View 15 Replies View Related

SQL & PL/SQL :: How Does Oracle Fill Missing Date Parts

Oct 10, 2010

What happens when I enter date with missing parts ? for example if there is a field of type Date and I inserted the value To_Date ('12/3/2005', 'dd/mm /yyyy') what will the values of the missing date parts be ? hh and mi and ss .so how does Oracle completes the missing parts of the date.

View 6 Replies View Related

SQL & PL/SQL :: Updating Fields Of History Table

Aug 25, 2011

pgit_policy is transaction table having producer code field.

pgith_policy is history table, on that table if any endorsement passed new records created with same polh_sys_id and increment on POLH_END_NO_IDX.

I am trying to update all records of the history table but its updating only higest POLH_END_NO_IDX only. i need to update all producer code.

update pgith_policy a
set a.polh_producer_code= (select b.pol_producer_code
from pgit_policy b
where b.pol_no=a.polh_no
--and b.POL_END_NO_IDX= a.POLH_END_NO_IDX and b.POL_END_SR_NO = a.POLH_END_SR_NO
and b.pol_producer_code is NOT NULL
and b.pol_class_code='10')
where a.polh_class_code='10'
and a.polh_producer_code is null
and a.polh_appr_dt between to_date('01-06-2011', 'dd-mm-yyyy') and to_date('30-06-2011', 'dd-mm-yyyy')

View 4 Replies View Related

SQL & PL/SQL :: Update Two Table Using For Loop?

Feb 19, 2010

I want to update column in table 1 based on a substraction of two column, one from the same table and the other from different table. Then update the result of substraction in table 1. Number of rows in two tables are different.

--for r in (( select (table2.y - table1.y as x from table1, table2 where table1.x = c and table2,.x = m))
declare
i number := 1;
c number ;
m number;

[Code]....

View 8 Replies View Related

SQL & PL/SQL :: Update Table Using Loop

Apr 7, 2010

a project I'm working on. I normally work in SQL Server, so I'm a little stuck on this one.

I have a temp table (tmp_stack) with four columns:

Floor [varchar]
Unit [varchar]
Block [number]
BlockStart [number]
BlockEnd [number]

BlockStart and BlockEnd are currently NULL. What I need to do is loop through the table for each Floor and update BlockStart and BlockEnd for each Unit depending on how many blocks they use and how many have been used by prior units on that floor.

For example:

There are three units on Floor #1: 1A, 1B, and 1C.
1A = 5 blocks
1B = 3 blocks
1C = 2 blocks

For 1A, BlockStart should = 1 and BlockEnd should = 5
For 1B, BlockStart should = 6 and BlockEnd should = 8
For 1C, BlockStart should = 9 and BlockEnd should = 10

And everything should reset back to the beginning on successive floors.

In T-SQL, I would use a cursor, and I assume I need to do the same kind of thing in Oracle, but I can't figure out the syntax.

View 8 Replies View Related

SQL & PL/SQL :: Procedure Containing Select Statement To Fill Page Items

Oct 24, 2011

I would like to fill items :P200_A and :P200_B and so on with the result of a SELECT which depends on the different values of many select lists.

E.G. :P200_list_alpha with the list of values
STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff

:P200_list_beta with the list of values
STATIC:active;active,passiv;passiv,excluded;excluded

How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).

What is a convenient way to write the select statement ? I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.

How to solve this problem in an elegant way ? In my opinion the CASE statement could be useful, but how to use it in the WHERE clause with this nested conditions ?

View 1 Replies View Related

Forms :: Fields Not Writing To Database Table

Jul 27, 2010

I have an Oracle Form 6i. There are two blocks. One is a database block called CUSTOMER and the other is a non-database block called CONTROL.

In the PRE-INSERT trigger of the database block, values from the non-database table block are passed to the database table block. When I pass values I use the :BLOCK_NAME.field_name eg. :CUSTOMER.scale_code := :CONTROL.scale.

In this form the values passed to the database block from the non-database block in the PRE-INSERT trigger do not use the block name e.g. :-

:warehouse := :global.default_warehouse;
:capturer :=captured
:scale_code := scale;
:date_captured := sysdate;
insert into dd_audit(cus_id,cap_date) values(:CONTROL.cus_id,SYSDATE);

This application used to work fine for months, last week when writing the values in the PRE-INSERT trigger, just the warehouse field had a value. The remaining fields after the warehouse did not pass any values, although it was verified that values would have been present in the non-database block. The date_captured field should have at least had the system date. The last insert into dd_audit was successful.

I have done numerous tests on our test database and could not replicate the problem. Would passing the values from the non-database block to the database block without the :BLOCK_name preceding the field name cause this problem.

View 4 Replies View Related

PL/SQL :: Get Junk Fields - Inappropriate Length - Table?

Jul 3, 2012

SELECT     COUNT ( * ) FROM mtl_system_items_b;
-> 664072 records

Actually the value of the segment1 should be 9. But it has some junk characters and some extra characters.So I am using the following query to get all the error segment values.

confirm is this query rite?
SELECT     segment1
FROM          mtl_system_items_b
WHERE      LENGTH (segment1)  != 9;

View 5 Replies View Related

Loop Through Records In A Table And Update?

Feb 2, 2012

I'm working with Oracle 10g.

I have a table like this;

ID Amount Date
123 5000 Oct-07-2011
123 null Oct-09-2011
124 7000 Oct-14-2011
124 null Oct-17-2011
124 null Oct-24-2011

What I'm trying to do here is loop thruogh the records and update the amount that's null with the previous amount with the same ID.

View 3 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

Fetching Data From Table In A Loop From Range Of Row?

Mar 23, 2012

I have dcs_sku table .The record count is 50 thousand in that table.My requirement is to fech every row,create an xml out of it and post the data to some third party.As the count is very huge,I can't select the entire record and do the operation at a time.way which I will run the sql query in a loop,which will fetch 1st from rown 1 to row 1000,next 1001 to 2000,2000 no 'n' row...

I tried the below query:

select * from dcs_sku where rownum between 1 and 200...This gave me the 1st 200 rows and worked fine.

but the moment I changed the query to :

select * from dcs_sku where rownum between 201 and 300:::No result was coming up.

View 1 Replies View Related

Application Express :: On Button Click To Fill Out Form On Same Page As Report

Jun 27, 2012

I have a report that contains a name that I want to pass in to a field in a form on a different region on the same page. My button located on the report is has its own column called ADD_LINK. Here is the button.

<button id="apexir_btn_ADD" class="apexir-button" type="button" value="Add" onclick=""><span>Add</span></button>

Once that button is clicked, I have the form region fade in. The region is called Add Tag to Employee, which has P4_ROWID, P4_EMPLOYEE_ID, and P4_TAG_ID. Once the region is displayed, I want the #NAME# to show in the P4_EMPLOYEE_ID.

I did copy this form from another page, where I had it working before. It made more sense to move it to this page for interface purposes, so maybe that tidbit will work as well.

View 15 Replies View Related

SQL & PL/SQL :: Updating Table For Different Number Of Fields Via Single Stored Procedure?

Jun 14, 2012

I've a table with fields:

create table test
( f1 varchar2(10),
f2 varchar2(10),
f3 varchar3(10)
)
insert into test values ('d1','d2','d3');
insert into test values ('d10','d20','d30');

I want to update the fields of the table as per need i.e update only one field leaving all the data of the fields as it is. Suppose I want to update only f1 (from d1 to x1) field leaving f2, and f3 as it is. I've written stored procedure to update all the fields but do not know how to do it?

Quote:CREATE OR REPLACE PROCEDURE UPDATE_TEST
( U_F1 TEST.F1%TYPE,
U_F2 TEST.F2%TYPE,

[Code]....

View 7 Replies View Related

PL/SQL :: How To Insert Null Record (some Column) In Table Using Loop

Jul 5, 2012

How to insert null record (for some columns) in table using loop.

sample data of x_tab

order_id order_name

231 xxx
123
345
111 vvvv

View 5 Replies View Related

SQL & PL/SQL :: Dynamic Cursor / Loop Will Accept Table Name From Parameter

Oct 11, 2013

I have a plsql block construct where i want to use for loop dynamically , the query which for cursor for for loop will accept the table name from parameter and join them to return the result. the resultant data will iterate in loop and do the execution.

DECLARE
--initialize variables here
v_date varchar2(10);
v_rebuild_index varchar2(250);
v_sql VARCHAR2(250);
p_table_name varchar2(250) := 'DS_ABSENCE';
p_source_table varchar2(30) := 'STG_ABSENCE';
p_source_owner varchar2(30) := 'STG_SAP';
v_for_sql varchar2(1000);
[code]....

View 7 Replies View Related

PL/SQL :: Insert Values Into A Nested Table Or Array With A Loop

Oct 8, 2013

How to create this pl/sql process to add elements to a nested table or varray within a loop. Here's the scenario: I have an apex package that has some pl/sql processes and some stored procedures. I am dealing with Inspection Areas. An Inspection Area has several sectors. I already have the loop that lists all the Inspection Areas and a loop inside that loop that lists all the sectors. There is an if statement that determines whether or not the sector name gets stored in the varray or table. I am not sure how to correctly do this and am not sure whether to use a nested table or varray. I've posted somewhat of a pseudo coded example below  

If  (you_belong_in_table)  then
variable := store_me_in_varray      /* OR */
variable := array_type(sector.sector_name)
i := i + 1;
end if;

/* Now we output our varray or table */
start loop
output(sector names one by one)

end loop I hope this makes sense. I more so just need the syntax to be able to continually added values to a table or varray while I'm already inside a loop; and also how to output those values end the end as well. 

View 7 Replies View Related

PL/SQL :: How To Do A Loop On Table And Export Data In Excel Format

Dec 13, 2012

i need to do a loop on a table and export the data in Excel format (so i need a procedure to do it).

write a java class that build this Excel.. oracle procedure loop around the data and every step my Java class write on Excel file.

So, for this i should initialize my java class for example

public class ExcelExporter{
private String fileName;
public ExcelExporter(String fileName){
this.fileName = fileName;
}
}

So, for this issuse i should call the ExcelExporter costructor from my PL/SQL so i can create an object of it and next i use this to populate my Excel.

How its possible to create Java object from PLSQL ? I've seen on the net all procedure call only Java static methods...

View 5 Replies View Related

Forms :: How To Find Table Names For The Fields In A Horizontal Form Of ASCP

Jun 25, 2013

I have a requirement of pulling the data from a field in horizontal form of Advanced Supply Chain Planning responsibility(ASCP). When I go into help-> Diagnostics, it shows the block name of the form as 'Horizontal Plan' and field name as 'Pivot Table'. Not pretty sure on how to pull the data source into horizontal form with the info I have.

View 3 Replies View Related

JDeveloper, Java & XML :: Generating Document That Include Fields Provided In Table

Nov 27, 2011

I need to generate a document that include fields provided in following.

CREATE TABLE t
(x_customer_po VARCHAR2(20 BYTE),
x_accessory_code VARCHAR2(3 BYTE),
x_install_loc HAR(3 BYTE));
INSERT INTO apps.T
VALUES('N45882','D0C','MFG');
INSERT INTO apps.T

[code]...

How can I get the output as formated XML?

--output:

<OrderAcknowledgments><Sender ID="999999999" Name="Cars"></Sender><DateTime>2011-11-27T22:00:14.3</DateTime><Acknowledgments><Acknowledgment><Vehicle><CustomerPONum>N45882 </CustomerPONum><Options><Option><Code>D0C</Code><InstallLocation>MFG</InstallLocation></Option><Option><Code>R0B</Code> <InstallLocation>MFG</InstallLocation></Option><Option><Code>LK2</Code><InstallLocation>MFG</InstallLocation></Option><Option ><Code>K0B</Code><InstallLocation>MFG</InstallLocation></Option></Options></Vehicle></Acknowledgment><Acknowledgment><Vehicle ><CustomerPONum>N45883</CustomerPONum>

[code]...

View 5 Replies View Related

Server Utilities :: SQL Loader Loads All Fields With Double Quotes Into Staging Table

Aug 25, 2010

I am having a similar problem like above ONLY in UNIX box where my datafile is delimited by "|". The last field is ITM_CMNT declared as VARCHAR2(60) in Oracle. When I have exactly 60bytes in the last field it rejects the record saying actual 61 and max allowed is 60. If i reduce it to < 60bytes then it is stored as a value enclosed with double quotes. The enclosing double quote is on the next line.

"PROC,RAM,FLPY,HD,ACT MTX CLR DSP,D/PCMCIA,TRKBAL,LIT ION BA"

Expected: the one below is exactly 60bytes.

PROC,RAM,FLPY,HD,ACT MTX CLR DSP,D/PCMCIA,TRKBAL,LIT ION BAT
LOAD DATA
INFILE *
INTO TABLE TMPTLI_LAWSON_ITM_MST
TRUNCATE
FIELDS TERMINATED BY "|"
(ITM_NO, HAZ_MAT_CD, ITM_SHRT_DS, ITM_SON "TRIM(:ITM_SON)", ADDED_DT DATE "YYYY-MM-DD",
AVL_CD , ITM_CST_AMT, ITM_SLL_AMT,
EXCHG_PRC_AMT , ITM_UOM "TRIM(:ITM_UOM)",
PCK_QTY INTEGER EXTERNAL, SPC_HNDL_CD "TRIM(:SPC_HNDL_CD)", EFF_DT DATE "YYYY-MM-DD",
ITM_CMNT "TRIM(:ITM_CMNT)")

View 4 Replies View Related

SQL & PL/SQL :: Distinct Value From VARRAY?

Feb 21, 2012

I need to take the distinct values from VARRAY.. I have wrote following simple example. But it does not work. how to get the distinct value from VARRAY.

declare
type t is varray(10) of varchar2(10);
t1 t;
type r is table of varchar2(10) index by binary_integer;
r1 r;
begin
t1 := t('A','B','A','B','A','B','C');
select distinct * into r1 from table(select * from t1);
END;

View 1 Replies View Related

SQL & PL/SQL :: Varray To Cursor

Mar 31, 2011

Iam passing the varray to cursor as show below.

type t is varray(50) of number;
t1 t;
cursor c1(t3 t) is select name from temp2 where id in(t3(1),t3(2));
name1 varchar2(20);
begin
t1 :=t(501,384,3242,106);
[code]......

my question varray size is 50, while creating the cursor i have to pass the 50 values like t3(1),t3(2).....t3(50). I have tried to use t3.first..t3.last in IN condition but throwing some error, any other method/hints to pass the values dynamically to cursor IN condition.

View 5 Replies View Related

PL/SQL :: Selecting Into A Varray?

Mar 29, 2013

BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE     11.2.0.3.0     Production
TNS for HPUX: Version 11.2.0.3.0 - Production

[code]...

SELECT job_request_id,
         CAST (COLLECT (USER_ID) AS SYS.OdcinumberList) user_ids
    FROM mytable
GROUP BY job_request_id;

ORA-22814: attribute or element value is larger than specified in type

View 6 Replies View Related







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