Without loops how can i read data from associative Array??
Hi all,
I am facing scenario like...
i need to read data from associative array without using loops is it possible,
CREATE OR REPLACE PACKAGE BODY test_pkg IS
TYPE t1 IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
-- in array we can expect more than one row or sometimes no data also.
FUNCTION test1(vt1 T1 DEFAULT CAST(NULL AS t1)) RETURN NUMBER IS
BEGIN
-- basically in array we'll get data of column2
-- this loop should satisfies table1.colum2 = nvl(NULL, table2.colum2 )if array is null.
-- if array is not null then only compare with array values
FOR i IN (SELECT t1.colum1,t1.column2
FROM table1 t1, table1 t2
WHERE t1.colum1 = t2.column1
AND t1.colum2 = nvl(vt1, t2.colum2)
LOOP
generateTEXT(i.colum1, i.colum2);
END LOOP;
END test1;
END test_pkg;
in table1 we have date like...
colum1 column2
Jan 1
Feb 2
Mar 3
if i call select test_pkg.test1(1) from dual then output should
be Jan..
and
select test_pkg.test1(null) from dual then it should display all elements from table1.
Jan 1
Feb 2
Mar 3,
Thanks for your quick replay..
i need to read data from associative array without using loops is it possible,
No - you would need to create a SQL type and then use the TABLE operator to unnest the collection.
create or replace TYPE my_nums IS TABLE OF INTEGER;
DECLARE
-- TYPE my_nums IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
v_nums my_nums := my_nums(1, 2, 3);
v_total number;
BEGIN
select sum(column_value) into v_total from table(v_nums);
DBMS_OUTPUT.PUT_LINE
('Sum of the numbers is ' || TO_CHAR(v_total));
END;
Sum of the numbers is 6
Similar Messages
-
How Can i Read data From Maintainance View
I Want read data from Maintainance View. i written select query
SELECT *
FROM J_1yyyyV
INTO TABLE GT_BUSPLACE.
WHERE BUPLA = LV_BUPLA.
this is giving following error
"J_1yyyyV" is not defined in the ABAP Dictionary as a table,
projection view, or database view.
Can you help me Please.
Thanks in Advance.
Regards,
Raj.Hi raj,
maintainance view is a nothing but combinations of table using join on some fields..
see the relation ship between the joins..
if you want to write selection query ..go to se11 -->enter view name >and open tab>
Table/Join conditions--> see the table's involved and join conditons between tables.
and write the select query same as like the Table/Join conditions in se11..now you can acheive the
table maintainance fields..
Prabhudas -
How to insert 300 data from associative array to backend table in PL/SQL
HI ALL,
I'm posting my code here:
Creating back end table:
Create table orlando
( id number(20),
calltype number(12),
gateway_name varchar2(25),
accounting_id varchar2(18),
start_time_system_ticks number(11),
node_time_zone varchar2(25),
start_date varchar2(10),
start_time varchar2(10),
softswitch_response number(11),
alerting number(11)
Creating package:
CREATE OR REPLACE PACKAGE r IS
type apollo_rec is record(
id number(20),
calltype number(12),
gateway_name varchar2(25),
accounting_id varchar2(18),
start_time_system_ticks number(11),
node_time_zone varchar2(25),
start_date varchar2(10),
start_time varchar2(10),
softswitch_response number(11),
alerting number(11)
TYPE bin_array IS TABLE OF apollo_rec INDEX BY BINARY_INTEGER;
PROCEDURE rr (state_array bin_array);
END ;
SET SERVEROUT ON
CREATE OR REPLACE PACKAGE BODY r IS
PROCEDURE rr (state_array bin_array) IS
BEGIN
FOR i IN 1 .. state_array.COUNT LOOP
INSERT INTO orlando(id,calltype,gateway_name,accounting_id,start_time_system_ticks)VALUES(state_array(i).id,state_array(i).calltype,state_array(i).gateway_name,
state_array(i).accounting_id,state_array(i).start_time_system_ticks);
COMMIT;
END LOOP;
END ;
END ;
I've run this code in i*SQL PLUS.But when I run this code for 5 entries there is no error but when I modify the insert statement for 300 entries(300 identifiers in the insert statement)
it gives me error:
Warning: Package Body created with compilation errors.
Errors for PACKAGE BODY R:
LINE/COL ERROR
7/2 PL/SQL: SQL Statement ignored
7/14 PL/SQL: ORA-00913: too many values
Is there any feature in PL/SQL to decrease the entries in insert statement and make the insert statement along with the program small and increase the program performance.
Edited by: 983040 on Jan 20, 2013 11:11 PMBasic example (ran on 11.2.0.3):
SQL> create table testtab( id number, day date, val varchar2(30) );
Table created.
SQL>
SQL> create or replace package TestTabLib as
2
3 type TTestTab is table of testtab%rowtype;
4
5 procedure InsertRows( rowArray TTestTab );
6
7 end;
8 /
Package created.
SQL>
SQL> create or replace package body TestTabLib as
2
3 procedure InsertRows( rowArray TTestTab ) is
4 begin
5 forall i in 1..rowArray.Count
6 insert into testtab values rowArray(i);
7 end;
8
9 end;
10 /
Package body created.
SQL>
SQL> declare
2 rowArray TestTabLib.TTestTab;
3 begin
4 --// populating the array - using a bulk fetch as
5 --// an example
6 select
7 object_id, created, object_name
8 bulk collect into
9 rowArray
10 from all_objects
11 where rownum < 11;
12
13 --// bulk insert array
14 TestTabLib.InsertRows( rowArray );
15 end;
16 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from testtab;
ID DAY VAL
100 2011/12/05 09:16:03 ORA$BASE
116 2011/12/05 09:16:04 DUAL
117 2011/12/05 09:16:04 DUAL
280 2011/12/05 09:19:09 MAP_OBJECT
365 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
367 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
368 2011/12/05 09:19:10 TABLE_PRIVILEGE_MAP
370 2011/12/05 09:19:11 TABLE_PRIVILEGE_MAP
371 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
373 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
10 rows selected.
SQL>
SQL> declare
2 rowArray TestTabLib.TTestTab;
3 begin
4 --// populating the array - using a custom build
5 --// loop example such as a Java front-end will
6 --// use reading data from user input form
7 rowArray := new TestTabLib.TTestTab();
8 rowArray.Extend(2); --// user entered 2 values
9 for i in 1..rowArray.Count loop
10 rowArray(i).id := i;
11 rowArray(i).day := trunc(sysdate);
12 rowArray(i).val := 'value '||to_char(i,'000');
13 end loop;
14
15 --// bulk insert array
16 TestTabLib.InsertRows( rowArray );
17 end;
18 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from testtab where val like 'value%';
ID DAY VAL
1 2013/01/21 00:00:00 value 001
2 2013/01/21 00:00:00 value 002
SQL> -
How can we read data from spread sheet using RowSet Object ??
Please give some sample code for this...
Urgent requirement....please....http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html
�I sense many useless updates in you... Useless updates lead to defragmentation... Defragmentation leads to downtime...Downtime leads to suffering..Defragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
http://sqlservercode.blogspot.com/ -
How can I migrate data from an old MBA to a new one without having access to the screen of the old one? The screen of the old MBA is damaged !
If your "older" MBA has a Thunderbolt port then it isn't that old. See Target Disk Mode about how it's used. Note that without a monitor you won't be able to tell from the screen when it has fully started, and if it succeeded in starting in TDM. If it did, then the hard drive should appear on the Desktop of your new computer. You can then access it to transfer your files. You can even use Migration Assistant or any backup utility to transfer data. Just don't try to transfer system files.
-
How can I modify data from a Transparent Table without ABAP code.
Hi,All
How can I modify data from a Transparent Table (like TCURR), and important thing is I want do all that with no ABAP code here. It is like that we always do that in a Oracle database use TOAD or PLSQL third party tools, with no script code here.
I had fond that there is a way can do that:
1, type 'se11',and Display Database table 'TCURR', click Contents, then click Execute to display all data
2, type '/h' and let debugging on
3, select one of this data then click 'Display',enter in debugging system.
4, then make a breakpoint in the code. But... display a dialog let I type a 'ABAP Cmnds', I want to know what can be type in for that?
and, My system is ECC6.
thank you all
Edited by: xuehui li on Aug 20, 2008 6:30 PMHello,
Your approach (with Vijay's suggestion) MAY work. However, depending on how tight security is at the company that you are working at you may or may not be able to acutaly change the value of the SHOW field to EDIT. This will be especially true if you are working in a Production environment. Vijay's other comment is true as well. This is not a recommended approach to change data (especially data with a financial impact like TCURR) in a production environment. The auditors will not be impressed.
Explore the option of a maintenace view or look at tcode TBDM to upload a file which includes daily rates from providers like Reuters or try tcode s_bce_68000174 which is a maintenance view on TCURR.
Regards
Greg Kern -
How can you transfer data from one ipod to another ?
How can you transfer data from one ipod to another ipod ?
The geniusbar told me what to do, I understood but there is still a problem for me >:/ It's not showing up though. Like "device." Nothing is happening, and I tried as soon as I got home. Then after half an hour, then an hour, then 3 hours. My problem is that it's not showing up! It's stuck in recovery mode! There's still like 25% battery. So I have no idea why.
-
How can I transport data from one client to another client?
How can I transport data from one client to another client?
Regards,
Subhohmmm, CTS = cutomizing transport?
If you have a customizing table, there are still two possibilities.
1. customize in DEV system and transport
2. customize right there where you need it.
this depends on how the maintainance view is built. If it is a simple customizing table and you get not asked for a TR when customizing a new record or changing an existing one, you hit possibility 2. -
How can i store data from a pc to TC
how can I backup data from a PC to TC
Get a suitable backup software..
Windows backup is of course useless. But you should already know that. It will not work on any version less than pro anyway.. due to MS deciding people with home versions should never use networks. ???
That is why there is one million and one third party backup software that do work with network drives. Look up reviews of what works well. for the price you want to pay and get it.. Drive Image was a popular one. I must have a copy somewhere I bought .. then changed to Mac..
There are plenty of free ones.. I do use macrium reflect.. does disk image only unless you pay the license.. but works super well.. particular for restore.. which people kind of forget.. the value of backup is how well does it restore.
Use ethernet if possible.
Note that mixing TM and data on the TC is not necessarily a great idea if you are also running Macs. -
How can i get data from a maintance view?
Hi all.
Can you give me some suggestion about 'How can i get data from a maintance view?'?
Thanks
Best regardhi
good
go through this link
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ecdf446011d189700000e8322d00/content.htm
thanks
mrutyun^ -
How can i convert data from DBF to oracle database 10g?
Sir,
How can i convert data from DBF to oracle database 10g?I assume you at least know how to dump the contents of foxpro dbf file into CSV format.
Regarding SQL*Loader, hope this demo makes it a bit clear to you...
http://www.princeton.edu/~storacle/sqlloader_demo.shtml
I agree that it is an old web page (references Oracle 8.0.5) but basics remain the same.
If it is still unclear to you after referring above link, then get an Oracle consultant. -
How can i extract data from oracle table to flat file or excel spread shee
Hello,
DB Version is 10.1.0.3.0
How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
Regards,
DHere what I did
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
Sql> SPOOL bing
select * from -------;
SPOOL OFF;
I do not see file.
I also tried
Sql> SPOOL /tmp/bing
select * from -------;
SPOOL OFF;
But still not seeing the fie, -
How can get formatted data from hard drive
how can get formatted data from hard drive?
No chance without special tools/knowledge. There are companies that can do it, unless you use multiple format or rewrite data with special erase ustility or unless you have done low level format.
Regards
Milos -
when I was talking on phone, suddenly the phone was switched off.
i tried to switch it on but it gave the message....connect to itunes for set up.
when I connected it to itunes...it gave the message, itunes can not read data from this iphone, restore it to factory settings. It also said while restoring ypu will lose all media data but you can restore the contacts.
I restored the factory settings....the phone was on recovery mode...it was verified by itunes and all that..but in the end it again said that iphone has some problem and can not function right now.
after that when ever i connect it with itunes, it gives the message, it can not activate the iphone further, try again later or contact customer service.
What to do now?????? Customer service people say..it is hardware problemIf it's a hardware problem, then the phone will need to be replaced.
There is no magic that can fix a hardware problem. -
How can I get Data from the Sound cart in Labview? Does a VI exist?
How can I get Data from the Sound cart in Labview? Does a VI exist?
Yes, there are VIs for acquiring data from Sound cards. And examples too. If you don't have LabVIEW yet, do a search on NI's site for example VIs.
Khalid
Maybe you are looking for
-
AUR Github Inspiration from here. Looks like Rydgel never shared his theme, so I made something similar. The original probably uses a non-free font called 'Ginza Medium' which I don't have acces to, so I used 'Tetra ITC Std Light' for the logo which
-
Compiling Sata into Kernel [SOLVED]
First time compiling a custom kernel. I've gone through the config process about 10 times now but never took the plunge. I did notice, however, that using gconfig I can't get SATA_AHCI to become a 'checkmark' which, I have taken to understand, means
-
Continuous forest line speeds and zooms out or view NOT, but should?
Here is my simple problem which I can not resolve. I will try to make as a detailed description as possible as I can not figure out which step needs to be corrected. I would like to create a landscape view as seen by someone on a sleigh ride down the
-
I was working through my emails in Microsoft Web Access when I came across an email from a sender who keeps spamming me. I right-clicked on this unwanted email, saw a filter option and (recklessly) chose it. ALL my emails and the menus disappeared. I
-
Digital Booklet on Ipod?
I recently bought an album from Itunes that came with a digital booket. However, Itunes says the booklet can't be played on my Ipod. I haven't been able to view it on my computer either. How can I view the digital booklet? I doube click on it and not