Get the length of column for each row in 2d array
let say if i declared a 2d array
int [][]set = new int[5][5];
if i had finished storing datas in the 2d array like the following
Columns
row 0[10][10][10][10][10]
row 1[20][][][][]
row 2[15][25][30][][]
row 3[17][12][][][]
row 4[10][][][][]
how do we know the the length of each row of the datas?
for example row 0 had 5 column data , row 1 got 1 col data, row 3 got 3 columns of data..
is it possible?
as what i know int set[1].length() = 5 and is not 1... am i right?
as what i know int set[1].length() = 5 and is not
1... am i right?No, there is no parenthesis for the array property length
Lets suppose you create this 2-D array;-
int [][]array = {{1,2,3,4},
{5,6,7,8},
{10,11,12,13},
{15,16,17,18} };
EG:-
This is array[0][0]= 1;
This is array[1][0]= 5;
This is array[2][2]= 12;
This is array[3][1]= 16;
int first = array[0].length; // will initialise 'first' to a value of 4
Similar Messages
-
Upload a file where no. of columns for each row is not fixed...
Hi All,,
I have to upload a file......
number of columns for each rows are not fixed ....
e.g.
Posting Date Company Code Currency Header Text Cost Center Internal Order Ref 1 Ref 2 Line Text Account no. Amount Account no. Amount Account no. Amount Account no. Amount Account no. Amount Account no. Amount Account no. Amount
31-05-09 1000 EUR PAYROLL 05/2009 1234 123456 123456 seaman RU 999999 9,999.99
31-08-09 1000 EUR PAYROLL 05/2009 678 98765 98765 officer GB 600015 4,560.00 600035 2,125.50 600020 1,325.40 600025 245.75 600030 300.00 280010 1,000.00 281091 6,000.00
its in tab delimited txt file.....
how to upload this type of file..
Plz suggest....
thnx
rahulHi,
Define your internal table like this.
TYPES: BEGIN OF upload_type,
upload(330),
END OF upload_type.
DATA: itab_upload TYPE STANDARD TABLE OF upload_type,
wa_upload TYPE upload_type.
Data: file type string.
file = 'C:/test.txt'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = itab_upload
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Use the sring operations to identify your coloumns.
Regards,
Satish -
How to get the value of column from previous row to current row?
Hi All,
I am facing a critical problem in SQL query (for reporting purpose (COGNOS)). please reply to my query.
REQUIREMENT: i want to retrive value of a column (this is not a table column, this will be calculated based expression) from previous row to current row.
EXAMPLE:
TABLE NAME: i have to join multiple tables. so, i am not mentioning table names here.
DISPLAY COLUMNS in the report: item, loc, sku, beginval (not table column), endval (not table column, this will calculated based on some expressions), etc. Here, first time the value of BEGINVAL will be taken from some x column name of x table. ENDVAL will calculated based on the expression. For the next row onwards, BEGINVAL will become the value of ENDVAL and the value of ENDVAL will be calculated based on the expression and this expression uses the value of BEGINVAL.
my report will look like below.
ITEM LOC SKU BEGINVAL ENDVAL
1 HYD 1-HYD 10 10+1+2 (13)
2 HYD 2-HYD 13 13+1+2 (16)
3 SEC 3-SEC 16 16+1+2 (19)
4 SEC 4-SEC 19 19+1+2 (22)
etc....
in the above output, BEGINVAL and ENDVAL columns are not part of any table. they are alias column names.if you observe intially BEGINVAL will be assigned to some value, but from subsequent rows, BEGINVAL will become the ENDVAL of previous row.
Please help me on how to write this query?Hi, please find the detail description of the problom.
DDL (table scripts)
ITEM
CREATE TABLE ITEM
ITEM VARCHAR2(50 CHAR) NOT NULL,
DESCR VARCHAR2(50 CHAR) DEFAULT ' ' NOT NULL,
UOM VARCHAR2(50 CHAR)
SKU
CREATE TABLE SKU
ITEM VARCHAR2(50 CHAR) NOT NULL,
LOC VARCHAR2(50 CHAR) NOT NULL,
OH float
SKUPROJSTATIC
CREATE TABLE SKUPROJSTATIC
ITEM VARCHAR2(50 CHAR) NOT NULL,
LOC VARCHAR2(50 CHAR) NOT NULL,
STARTDATE DATE
VehicleLoad
CREATE TABLE VEHICLELOAD
LOADID VARCHAR2(50 CHAR) NOT NULL,
DESCR VARCHAR2(50 CHAR) DEFAULT ' ' NOT NULL,
SHIPDATE DATE DEFAULT TO_DATE('01/01/1970','MM/DD/YYYY') NOT NULL,
ARRIVDATE DATE
VEHICLELOADLINE
CREATE TABLE VEHICLELOADLINE
LOADID VARCHAR2(50 CHAR) NOT NULL,
ITEM VARCHAR2(50 CHAR) NOT NULL,
QTY float(126)
DML scripts
I can't provide the the DML scripts, because its very huge data.
Main QUERY is below.
below is the query which i have to write and execute.
select
i.item,
i.descr,
i.unitsperpallet,
sp.loc,
sp.startdate,
'Crucial_IND',
LAG (EndBal,1,0) OVER (ORDER BY STARTDATE) BeginBal,
SP.FCSTCUSTORDERS CustOrders,
SP.COMMITINTRANSOUT,
SP.RECARRIV,
SP.TOTINTRANSIN,
(BeginBal - sp.FCSTCUSTORDERS - sp.COMMITINTRANSOUT + sp.TOTINTRANSIN ) EndBal,
'CuttingQty',
VLL.QTY,
vl.source,
vl.arrivdate,
vl.shipdate,
vl.loadid,
s.oh
from item i, skuprojstatic sp, sku s, VehicleLoad vl, VehicleLoadLine vll
where sp.item = i.item
and s.item=i.item
and sp.item =s.item (+)
and sp.loc = s.loc (+)
and vll.item = s.item
and vll.loadid = vl.loadid
and to_char(sp.startdate ,'mm/dd/yyyy') = to_char(vl.arrivdate,'mm/dd/yyyy')
and sp.loc = vl.dest (+)
order by sp.startdate
problem description: in the above query, BeginBal and EndBal is what i am looking for. when i execute this query, oracle throwing an error saying that alias names can't be used as expressions. For the first row, the BeginBal should be the value sku.OH and for the subsequent rows, this value will be the previous row value of EndBal. -
Qry return same value for a particular column for each row but not all time
hi,
We recently migrated to Oracle Database 10.2.0.3.0 from 9i. We were using a sql to populate a table and it had been running fine. After migration the same sql is fetching / population incorrect values, but not everytime. If we run the same sql again it gives a correct result.
Ex:
insert into a1 ( col1, col2, col3 )
select a.field1, b.field2, c.field
from tab1 a, tab2 b, tab3 c
where a.field = b.field
and b.field (+) = c.field
something like this. Let us assume it fetches 200 rows
But sometimes the col1 has the same value for all the 200 rows and col2, col3 has correct values. If we run the same sql next time, the col1 fetches the correct value and everything is correct.
Could someone help on the above issue.I know it's difficult but can you put together a small test case for us to reproduce this behaviour? Did you contact Oracle Support?
Any special constructs used behind the scenes? Virtual private database? Views?Materialized Views? Anything else? -
Setting different Tabel Cell SemanticColor for Multiple Columns of each row
Hi,
I have requirement of setting different colors to different columns for each row based on some condition in table data.
The data to table is coming from model, hence table is mapped to model node and attributes.
I have created Seperate Node CellColorNode with attribue CellClr1 and CellClr2 of type TextView Semantic Color.
Set the calculated, read only attribute to True. Mapped table columns text view to the CellColorNode->CellClr1 and CellColorNode-->CellClr2 correspondingly.
Now, my query is how do i set the colors to CellClr1 and CellClr2 attributes. As I need to set the color for multiple columns of each table row.
Is it in method getColorCellCellClr generated? Any Example Code?Its resolved by following below link
http://scn.sap.com/thread/158286 -
How get values of columns for selected rows in SortingTable
Hi,
is possible to get values of more columns for selected rows? I have SortingTable that have 1st column loaded from list and 2nd and 3rd columns are text areas where user must write some text. I need way how to get values from all three columns for selected rows.
My table looks like this:
System name I User Account I User Password
system1 ...............jblack ............. passw1
system2 ...............pdowe..............p@ssw
system3 ...............ekie................. pas123
Column System name is loaded from list, columns User Account and User Password are Text class. How can I get values for all three columns in case that I select e.g. system1 or system1 & system2?
I read [this post|http://forums.sun.com/thread.jspa?forumID=764&threadID=5220609] but there is described selection only for one column.
Code of my SortingTable is following:
<Field name='tblDalsiSystemy'>
<Display class='SortingTable'>
<Property name='align' value='center'/>
<Property name='sortEnable' value='false'/>
<Property name='selectEnable' value='true'/>
<Property name='pageSize' value='5'/>
<Property name='pageButtonAlign' value='center'/>
<Property name='columns'>
<List>
<String>System name</String>
<String>User Account</String>
<String>User Password</String>
</List>
</Property>
</Display>
<FieldLoop for='y' in='lstSystemList'>
<Field name='SystemName'>
<Display class='SortingTable$Row'>
<Property name='key'>
<ref>lstSystemList</ref>
</Property>
</Display>
<Display class='Label'>
<Property name='align' value='center'/>
<Property name='value'>
<ref>y</ref>
</Property>
</Display>
</Field>
<Field name='UserAccount'>
<Display class='SortingTable$Row'>
</Display>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
<Field name='UserPassword'>
<Display class='SortingTable$Row'>
</Display>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
</FieldLoop>
</Field>Getting value is performed by:
<ref>tblDalsiSystemy.selected</ref>Any help?
Thanks
PetrHi Ivan,
thanks for your advice - it works.
Here is my final code:
<Field name='tblDalsiSystemy'>
<Display class='SortingTable'>
<Property name='align' value='center'/>
<Property name='sortEnable' value='false'/>
<Property name='selectEnable' value='true'/>
<Property name='pageSize' value='5'/>
<Property name='pageButtonAlign' value='center'/>
<Property name='columns'>
<List>
<String>System name</String>
<String>User Account</String>
<String>User Password</String>
</List>
</Property>
</Display>
<FieldLoop for='y' in='lstSystemList'>
<Field name='SystemName'>
<Display class='SortingTable$Row'>
<Property name='key'>
<ref>lstSystemList</ref>
</Property>
</Display>
<Display class='Label'>
<Property name='align' value='center'/>
<Property name='value'>
<ref>y</ref>
</Property>
</Display>
</Field>
<Field name='Account[$(y)].login'>
<Display class='SortingTable$Row'/>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
<Field name='Account[$(y)].passwd'>
<Display class='SortingTable$Row'/>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
</FieldLoop>
</Field>Maybe it could be helpful for somebody another :-)
Petr -
I'm trying to get the count for each row to total count for each month
Something like this
Hardware | Jan
Monitors | 5
Processors | 137
Printers | 57
etc........
How can I write a query for this. I can get the Hardware column but don't know how to get the next column.If you can provide more data like sample input DML statements it would have been wonderful..
Assuming is , you need a pivot. Here is an article on basic Pivot..
http://sqlsaga.com/sql-server/how-to-use-pivot-to-transform-rows-into-columns-in-sql-server/
something like this may be..
DECLARE @Input TABLE
Hardware VARCHAR(20),
[Date] VARCHAR(20)
INSERT INTO @Input VALUES('Monitor', '01/01/2014'), ('CPU', '01/01/2014'), ('Monitor', '01/03/2014')
, ('ABC', '01/01/2014'),('Monitor', '02/01/2014')
;WITH CTE AS
SELECT Hardware, LEFT(DATENAME(M, [Date]),3) AS [MonthName] FROM @Input
SELECT *
FROM
SELECT Hardware, [MonthName], COUNT(Hardware) AS Count FROM CTE GROUP BY Hardware, [MonthName]) a
PIVOT (MAX([Count]) FOR [MonthName] IN ([Jan], [Feb])) pvt
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
Update button in sql report for each row can only get the report value
I have to added Update for each row of records like:
select a.*,'Update' button from (
select c.*,d.login from country c,champ d
where c.champ_id=d.champ_id(+)
order by c.name) a
then go to the report->edit button ->Column Link
I added some items P40_REGION, P40_CHAMPID,P40_ACTIVE,P40_CODE and assign the value like #region#,#active# ,#code# to these item, but when I click the update button in the report I found the values such as #region#,#active# ,#code# is the report value not the select list selected value(the region, active column are displayed as select list lov).
Can anyone tell me how to sort this knid of problem?
Thanks a lot!Sorry, it doesn't work. I also tried apex_application.g_f01(i), but not everytime I can get the value or get the incorrect value. If you have time you can try to create it like what I have described. Our team use two days now but still can not sort this problem.
-
Horizontal lines for each rows in the rtf template
Hi,
I am a newbie for XML Publisher. I just created a XML Publisher report for Vendor invoices. But for each invoice/invoice line rows I am getting a horizontal line which separates each row. But I just wanted the vertical line to separate the columns and not for the rows.
For example, the output looks like
Invoice number | Item Description| Quantity|
123__________| xyz__________|_____30 |
_____________| xyz__________|_____30 |
_____________| xyz__________|_____30 |
345__________| xyz__________|_____30 |
I am getting the report some this like this. But I need the report like below,
Invoice number | Item Description| Quantity|
123__________| xyz__________|_____30 |
_____________| xyz__________|_____30 |
_____________| xyz__________|_____30 |
345__________| xyz__________|_____30 |
(Please consider the ____ as space)
Please suggest me some solution. tons of thanks in advance.Hi Vetsrini,
Thanks for your prompt reply. I hope I had put the tag that you had mentioned. But anyhow I had sent your the template and the sample XML file to see the output.
I have one more question also I want a curvey edge for the table and no tthe sharp edge like this _|. If possible please suggest for this also.
Looking forward for your reply.
Hope your mail id is fusion{DoT}object[AT]gmail[dOt]com -
Prompting user for input for each row in the report
Is it possible to have a user entered field for each row in a report ?
ie. have a report with empolyee number, employee name, title, salary, and comment. Select of of these columns from the SQL query except for the comment, and then when the report is generated have the user be prompted for what the want the comment to be for every employee in the report?That is, have the user generating the report enter in a different comment for EACH employee. (ie Joe Smith's comment is "good worker and John Smith's comment is "come to work late on Tuesdays and Thursdays", Sally Jones' comment is "Expert in C++" etc.) as the reports is being built for each row returned from the query.
-
How to add a comment for each row on the output of a report?
I would like to add a comment (field) for each row on the output of report? This comment should to be saved as well. Is there a way i can do that?
Regards,
RamHi Dimitri,
through the instead of trigger functionality i am able to update the view. This is view is based on different views which should be linked to a table (as you suggested) in which comments can be stored. Hower this table is empty and how to link this table with the view now? I face the following challenge.
View consists the following columns, for example
select name, sex, age from test_view
name sex age
John M 20
Anton M 30
Willy M 40
shirley F 38
sharon F 37
The report has the following output, for example
name sex age
John M 20
Anton M 30
Willy M 40
Shirley F 38
Sharon F 37
Now i would like to add comment through a button.
The report layout looks like
name sex age
John M 20 <add comment button>
After submitting the <add comment button> you can enter text which deals with John
text='John doesnot like me'
Finally the report display the comment as well
name sex age
John M 20 'John doesnot like me' <update/delete comment button>
Anton M 30 <add comment button>
Willy M 40 <add comment button>
Shirley F 38 <add comment button>
Sharon F 37 <add comment button>
After submitting the <update/delete button> you can change or delete the entered text.
I hope this example clears things up.
Regards,
Ram -
How can can i subtract the value of the column in each row ?
I want to subtract the value of the column in each row if the row is not enough then continue to next row.
For example
ID QTY
A 20
B 40
C 60
I want to update this table by subtract the value of the column (QTY) out 70 so the result i want will be
ID QTY
A 20 - 70 = -50 --> 0 this row will be updated to 0 and 50 will continue to next row
B 40 - 50 = -10 --> 0 this row will be updated to 0 and 10 will continue to next row
C 60 - 10 = 50 --> Stop loop
How can i write the sql query for this operation , ThanksPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. You have no idea,
do you? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. What did you try on your own before posting? I will bet that you did nothing! You expect other people to do your job or homework for you.
>> I want to subtract the value of the column in each row if the row is not enough then continue to next row. <<
This makes no sense. Rows have no ordering; that is a spreadsheet. There is no such thing as a generic “id” in RDBMS. And an identifier is not a sequence which would have an ordering.
CREATE TABLE Foobar
(something_seq INTEGER NOT NULL PRIMARY KEY,
onhand_qty INTEGER NOT NULL);
Learn how to use the SUM()OVER() and LAG() aggregate functions, post what you tried for yourself and then we will help you.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Different values in a list box for each row of the table control...
Dear Experts,
Is it possible to populate different values for each row in a listbox inside a table control ?
Example,
Row 1 in the the table contains A, B & C
Row 2 in the same table contains C, D & E
If yes, How?
yes i am using
call function 'VRM_SET_VALUES'
exporting
id = i_name
values = i_list.
Thank you .
Message was edited by:
Kokwei Wong
Message was edited by:
Kokwei WongHi Wong,
this is code example for listbox
TYPE-POOLS vrm .
DATA: lt_vrm_values TYPE TABLE OF vrm_value.
DATA: wa_vrm_values TYPE vrm_value.
PARAMETER p_list AS LISTBOX VISIBLE LENGTH 10.
INITIALIZATION.
wa_vrm_values-key = 'Key1'.
wa_vrm_values-text = 'Value1'.
APPEND wa_vrm_values TO lt_vrm_values.
wa_vrm_values-key = 'Key2'.
wa_vrm_values-text = 'Value2'.
APPEND wa_vrm_values TO lt_vrm_values.
wa_vrm_values-key = 'Key3'.
wa_vrm_values-text = 'Value3'.
APPEND wa_vrm_values TO lt_vrm_values.
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_LIST'
values = lt_vrm_values
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
To fill it with data from DB, just do select in INITIALIZATION and put that values with same alghoritmus.
Manas M.
P.S.: This is very easy question, you should use search ... -
:new., lob columns and after insert ... for each row trigger
I'm having this little problem with
my update/insert triggers and lob columns.
I have this little trigger:
CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
AFTER INSERT ON BLOB_DATA
FOR EACH ROW
BEGIN
INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
END;
Which works except when the DATA column
is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
The one thing that is different for the lob columns is that the application updating
the data is using a bind statement with returning, like:
INSERT INTO BLOB_DATA
VALUES(:ID,EMPTY_BLOB())
RETURNING DATA INTO :DATA;
COMMIT;
Thanks for any helpI'm having this little problem with
my update/insert triggers and lob columns.
I have this little trigger:
CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
AFTER INSERT ON BLOB_DATA
FOR EACH ROW
BEGIN
INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
END;
Which works except when the DATA column
is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
The one thing that is different for the lob columns is that the application updating
the data is using a bind statement with returning, like:
INSERT INTO BLOB_DATA
VALUES(:ID,EMPTY_BLOB())
RETURNING DATA INTO :DATA;
COMMIT;
Thanks for any help -
How can I get (using API) the current sort column for some report
hello,
How can I get (using API) the current sort column for some report ? For example something like "fsp_sort_1_desc" - if the user sorts by the first column ?
I cannot use the :REQUEST for this, sometimes the current sort column is not in the :REQUEST, but it is still active.
I thought it was posssible by using
APEX_UTIL.GET_PREFERENCE (
p_preference IN VARCHAR2 DEFAULT NULL,
p_user IN VARCHAR2 DEFAULT V('USER'))
RETURN VARCHAR2;
function, but I don't really know which preference should I pass as parameter.
looking in WWV_FLOW_PREFERENCES$, i saw preferences_names like FSP4000_P527_R6281510839654570_SORT , I'm not sure how this name is formed.
I'm using generic columns for that complex report (which has a flexible number of columns shown), and the idea is that sometimes I have to overwrite that sort column, in case the user chose the version of the report with fewer columns than the previous one.
Can I get (using API) a list of all preferences set for some user ?
Thank you,seems that it is FSP<app_number>P<pagenumber>R<regionnumber>_SORT.
is there anyplace where I can get these kind of things documented ?
Thank you.
Maybe you are looking for
-
Can/How Do I Create a Photo Gallery Template in Bridge
It is possible for me to create a photo web gallery "template" in Bridge CS5. I would like it so that every time I create a photo gallery for sports photos, the header, google analytics, facebook icon, twitter icon copyright and more are all the sam
-
Placing photos from Bridge to PS
Why won't two photos in Bridge be placed in Layers in PS when the command is given under Tools in Bridge?
-
Deployment not working for Oracle Help 12c (12.1.3.0.0)
Hi I am trying to install the ohw-links.ear and ohw-rcf-demo-thin.ear. But after the installation when I am trying to access the below url, I am getting below error and I can't see the help home page. http://pc72648dd:8201/ohw-links/faces/helppages/
-
hi folk i have project to create client server program with multiuser i know how to deal with threading server by bassing messages but what about if all client will share the same board ( applet with graphics ) how can i deal with that ??
-
IDOC processing inbound in receiver system , transaction WE57
Hello, possibly a simple question for those who are familar with IDOC processing. In transaction WE57 you can add function modules for processing IDOCs e.g. inbound IDOCs. Now I see in our system that there are two function modules added to the same