How to 'build' one row only in a 2d array
Hi
I'd like to have a 2D array with eg 4 rows, and each time the loop iterates, it should append new data at the end of a specified row (row 0 in example) while the data in the other rows remain unchanged.
I tried all combinations of build array, replace array subset etc but for some reason I cannot get the rows to extend in length..
I want the output array in the example to be like:
2 2 2 2 2 2 2 2 2
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
Thus append the data array [2 2 2] 3 times to the first row, and leave the rest unchanged, but all I get is an empty array..
I've been struggling with this for a few hours now, but I can't find it.. Although I think it's very simple!
Or should I go fo
r an entirely different technique like clusters or so?
Can someone help me out?
Attachments:
build_1_row_in_2D_array.vi 24 KB
Khalid,
thanks for your diagram; it didn't help me because it doesn't really do what I want, but I think the transpose 2D function is pretty interesting anyway!
I found the solution myself, but I don't know if it's clean programming considering memory etc; I first initialize an array that is big enough to conatain all data and an array containing #row elements for storing the total amount of new data written in a row.
Then I can build a specified row and by shifting the size of the data already written in that row everything gets in place..
The loop takes quite a lot of blocks and wires, comments on how to get it smaller are welcome!!
Attachments:
build_1_row_in_2D_array_working.vi 37 KB
1_row_in_2d_array.jpg 179 KB
Similar Messages
-
Need a report column to hold data for one row only
Hey Guys,
I have a report which has a column that links to another page in my APEX application.
There is a requirement where only one of the rows in this report needs to have a link so I need the column to show the page link for one row and one row only.
The report will have about 5 rows at a time so is there a way to just make this link appear for the one row(it will be the top row) in the column attirbute in APEX? or can this be done in the SQL for the report?
Any help is much appreciated
Thanks
-MarkHi
The only way (I believe) to do this is within the SQL. Then you just wrap the column in a CASE statement and if it meets your criteria then build up the link and if not then display normally.
Something like this...
SELECT ename,
CASE WHEN empno = 7839
THEN '<a href="f?p='||:APP_ID||':4:'||:APP_SESSION||'::NO::P4_TARGET_ITEM:'||empno||'" >'||empno||'</a>'
ELSE TO_CHAR(empno)
END empno
FROM empCheers
Ben -
How to update one row in AdvancedDataGrid
My App have a AdvancedDataGrid and it has so much rows. Some
data rows for AdvancedDataGrid has changed and i don't want to
update all rows ... But i don't know how to update one row for my
AdvancedDataGrid
Some body help me ...
Thanks so muchs !thanks ntsii.
my problem is:
[Bindable]
var dp:ArrayColection = new ArrayColection({...});
<mx:AdvancedDataGrid dataProvider="{dp}">
<mx:groupedColumns>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
//==================================
in my dp have more rows and some time one of them is changed
then i guess the AdvancedDataGrid must build all rows when
it's dataProvider (dp) have changed.
And i don't want to that...
But i am not sure the AdvancedDataGrid buld all rows from
begin to end ... i don't know.. ! -
How to select one row in a table with radio button
Hi all.
I have a VO where there is an attribute (isDefault [String]) that identifies the default record in the view. The possible values are 'Y' for yes and 'N' for no. Obviously only one record can have the 'Y' value.
In my page I have created an ADF Table (with the usual data control drag & drop). I would to transform the default inputText of "isDefault" field with a selectOneRadio component in order to permit the user to select (and save contextually in the DB) the default row of this table.
Can you explain me how? I'm using JDeveloper 11.1.1.4.
Thanks in advance.
BaduelBaduel wrote:
Cvele,
thanks for your responses. Yes, it's easier to use af:selectBooleanCheckbox but I need that the selection is mutually exclusive (only one row can be selected). >If this is possible also with the boolean checkbox please tell me how.- Let's try with CheckBox :
1. At the ViewObjectImpl level (for example, YourViewObjectImpl), add the following code:
private oracle.jbo.Key currSelectedRowKey = null;
public void doRowSelection(Key newKey) {
// de-select old one
if (currSelectedRowKey != null) {
Row[] rows = findByKey(currSelectedRowKey, 1);
if (rows != null && rows.length > 0)
rows[0].setStatusAsBoolean(Boolean.FALSE); // cast to the appropriate row Impl class if need !
// remember a new selected row key:
currSelectedRowKey = newKey;
}In the ViewRowImpl, in the transient attr settter, do as follows:
public void setStatusAsBoolean(Boolean value) {
setStatus(value.booleanValue() ? ONE : ZERO);
if (value.booleanValue()) {
YourViewObjectImpl vo = (YourViewObjectImpl)getViewObject();
vo.doRowSelection(getKey());
} P.S. The above was not tested at all, but should give you an idea -
How just return one row of a one to many join..
So I have a one to many join where the SMOPERATOR table has data I need however it has a couple of rows that match the JOIN condition in there. I just need to return one row. I think this can be accomplished with a subquery in the join however have not been able to come up with the right syntax to do so.
So:
SELECT "NUMBER" as danumber,
NAME,
SMINCREQ.ASSIGNMENT,
SMOPERATOR.PRIMARY_ASSIGNMENT_GROUP,
SMOPERATOR.WDMANAGERNAME,
SMINCREQ.owner_manager_name,
SMINCREQ.subcategory, TO_DATE('01-'||TO_CHAR(open_time,'MM-YYYY'),'DD-MM-YYYY')MONTHSORT,
(CASE WHEN bc_request='f' THEN 'IAIO'
WHEN (bc_request='t' and substr(assignment,1,3)<>'MTS') THEN 'RARO'
WHEN (bc_request='t' and substr(assignment,1,3)='MTS') THEN 'M'
ELSE 'U' end) as type
from SMINCREQ
left outer join SMOPERATOR on SMINCREQ.assignment=SMOPERATOR.primary_assignment_group
WHERE SMINCREQ.owner_manager_name=:P170_SELECTION and SMOPERATOR.wdmanagername=:P170_SELECTION
AND open_time BETWEEN to_date(:P170_SDATEB,'DD-MON-YYYY') AND to_date(:P170_EDATEB,'DD-MON-YYYY')
AND
(bc_request='f' and subcategory='ACTIVATION' and related_record<>'t')
OR
(bc_request='f' and subcategory<>'ACTIVATION')
OR
(bc_request='t' and substr(assignment,1,3)<>'MTS')
order by OPEN_TIMeHi,
This sounds like a Top-N Query , where you pick N items (N=1 in this case) off the top of an orderded list. I think you want a separate ordered list for each assignment; the analytic ROW_NUMBER function does that easily.
Since you didn't post CREATE TABLE and INSERT statements for your sample data, I'll use tables from the scott schema to show how this is done.
Say you have a query like this:
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
ORDER BY dname
;which produces this output:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7934 MILLER CLERK 1300
ACCOUNTING 7839 KING PRESIDENT 5000
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
RESEARCH 7902 FORD ANALYST 3000
RESEARCH 7566 JONES MANAGER 2975
RESEARCH 7369 SMITH CLERK 800
RESEARCH 7788 SCOTT ANALYST 3000
SALES 7521 WARD SALESMAN 1250
SALES 7844 TURNER SALESMAN 1500
SALES 7499 ALLEN SALESMAN 1600
SALES 7900 JAMES CLERK 950
SALES 7698 BLAKE MANAGER 2850
SALES 7654 MARTIN SALESMAN 1250Now say you want to change the query so that it only returns one row per department, like this:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
SALES 7499 ALLEN SALESMAN 1600where the empno, ename, job and sal columns on each row of output are all taken from the same row of scott.emp, though it doesn't really matter which row that is.
One way to do it is to use the analytic ROW_NUMBER function to assign a sequence of unique numbers (1, 2, 3, ...) to all the rows in each department. Since each sequence startw with 1, and the numbers are unique within a department, there will be exactly one row per departement that was assigned the numebr 1, and we''ll display that row.
Here's how to code that:
WITH got_r_num AS
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
, ROW_NUMBER () OVER ( PARTITION BY d.dname
ORDER BY e.ename
) AS r_num
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT dname
, empno, ename, job, sal
FROM got_r_num
WHERE r_num = 1
ORDER BY dname
;Notice that he sub-query got_r_num is almost the same as the original query; only it has one additional column, r_num, in the SELECT clause, and the sub-qeury does not have an ORDER BY clause. (Sub-queries almost never have an ORDER BY clause.)
The ROW_NUMBER function must have an ORDER BY clause. In this example, I used "ORDER BY ename", meaning that, within each department, the row with the first ename (in sort order) will get r_num=1. You can use any column, or expression, or expressions in the ORDER BY clause. You muight as well use something consistent and predictable, like ename, but if you really wanted arbitrary numbering you could use a constant in the analytic ORDER BY clause, e.g. "ORDER BY NULL". -
Write to spreadsheet file.vi is storing data in one row only.
The 8 points of data is going into one column in the spreadsheet. In the "Write to spreadsheet file string.vi" how do I write the 8 points to one row for each cycle?
I got this VI from NI's web a couple of years ago and forgot how to modify this part. I usume it is within the write file.vi.
Thank you in advance
SkipI just reread your original post and the way the "Write to Spreadsheet File.vi" that ships with LV works by default is to put 1D arrays into rows. I read your post backwards and told you how to put the data in a column. Sorry.
In any case, perhaps you need to make sure the Transpose input ISN'T true, and that the delimiter IS a tab.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
This query
SELECT
SCRATTR_ATTR_CODE
from scrattr_TEST,scbcrse_TEST
where
SUBSTR(scbcrse_subj_code,1,3) = SUBSTR(scrattr_subj_code,1,3)
and SUBSTR(scbcrse_crse_numb,1,4) = SUBSTR(scrattr_crse_numb,1,4)Returns this
SCRATTR_ATTR_CODE
A
INS
MCSR How I can make to return someting like A INS MCSR in one row there is a row for every code
hERE is some code to create the tables and insert the data
CREATE TABLE SCRATTR_test
SCRATTR_SUBJ_CODE VARCHAR2(4 CHAR) NOT NULL,
SCRATTR_CRSE_NUMB VARCHAR2(5 CHAR) NOT NULL,
SCRATTR_EFF_TERM VARCHAR2(6 CHAR) NOT NULL,
SCRATTR_ATTR_CODE VARCHAR2(4 CHAR)
CREATE TABLE SCBCRSE_test
SCBCRSE_SUBJ_CODE VARCHAR2(4 CHAR) NOT NULL,
SCBCRSE_CRSE_NUMB VARCHAR2(5 CHAR) NOT NULL,
SCBCRSE_EFF_TERM VARCHAR2(6 CHAR)
insert into SCRATTR_test (SCRATTR_SUBJ_CODE,SCRATTR_CRSE_NUMB,SCRATTR_EFF_TERM,SCRATTR_ATTR_CODE) select 'BIO','2210','201320',' A' from dual;
insert into SCRATTR_test (SCRATTR_SUBJ_CODE,SCRATTR_CRSE_NUMB,SCRATTR_EFF_TERM,SCRATTR_ATTR_CODE) select 'BIO','2210','201320','INS' from dual;
insert into SCRATTR_test (SCRATTR_SUBJ_CODE,SCRATTR_CRSE_NUMB,SCRATTR_EFF_TERM,SCRATTR_ATTR_CODE) select 'BIO','2210','201320','MCSR' from dual;
COMMIT;
INSERT INTO SCBCRSE_test(SCBCRSE_SUBJ_CODE,SCBCRSE_CRSE_NUMB,SCBCRSE_EFF_TERM) SELECT 'BIOL','2210','201320' FROM DUAL
COMMIT; Thank youBased on your testcase, on 11.2 you could just:
SQL> select listagg(a.SCRATTR_ATTR_CODE, ' ') within group (order by rownum)
2 from scrattr_TEST a
3 , scbcrse_TEST b
4 where SUBSTR(b.scbcrse_subj_code,1,3) = SUBSTR(a.scrattr_subj_code,1,3)
5 and SUBSTR(b.scbcrse_crse_numb,1,4) = SUBSTR(a.scrattr_crse_numb,1,4);
LISTAGG(A.SCRATTR_ATTR_CODE,'')WITHINGROUP(ORDERBYROWNUM)
A INS MCSR -
Ensure one row only is set as default
We have a Customers table. The default customer is 'CASH SALE'. Our business rules require one and one only customer be the default customer, but the default customer can be changed from CASH SALE to any other customer. Our business rules do not allow the
CASH SALE customer to be modified beyond setting the IsDefault attribute to true or false
There is a column IsDefault bit and a unique filtered index on IsDefault.
CREATE UNIQUE INDEX IX_Customers_IsDefault
ON Customers(IsDefault)
WHERE IsDefault = 1
This works to the extent that it does not allow more than 1 row to be marked IsDefault, but it does not ensure that there is one row marked IsDefault = 1, ie it is possible for IsDefault = 0 for all rows.
We also have constraints that prevent updating or deleting CASH SALE
-- the CASH SALE customer cannot be deleted
CREATE TRIGGER Customers_No_Delete ON Customers
INSTEAD OF DELETE
AS
IF ( SELECT CustomerId
FROM deleted
) = 0
BEGIN
RAISERROR ('The CASH SALE customer cannot be changed nor deleted.', 16, 1)
END
ELSE
BEGIN
DELETE FROM Customers
WHERE CustomerId = ( SELECT CustomerId
FROM deleted
END
GO
-- the CASH SALE customer cannot be changed
CREATE TRIGGER Customers_No_Update ON Customers
INSTEAD OF UPDATE
AS
IF ( SELECT CustomerId
FROM inserted
) = 0
BEGIN
RAISERROR ('The CASH SALE customer cannot be changed nor deleted.', 16, 1)
END
ELSE
BEGIN
DELETE FROM Customers
WHERE CustomerId = ( SELECT CustomerId
FROM deleted
END
GO
However the trigger Customers_No_Update also prevents updating the IsDefault column. I know this is a common business scenario:CASH SALE cannot be edited but another customer can be marked as the default customer, so I assume there is a standard solution
... if someone could please point me the way.Thank you Erland. By using both of the triggers you suggested the problem is solved. I changed the trigger dont_touch_CASH_SALE so that rather than check if each column is updated, it checks that IsDefault is not the column being updated, ie IF NOT UPDATE(IsDefault)
Thanks again to everyone for your assistance.
Refering to your comment below
I may be mistaken but it appears the solution proposed by Visakh16 does not allow IsDefault = 1 for a customer other than CASH SALE
I dont think thats true
See this illustration
--Sample table for illustration
CREATE TABLE Customers
ID int IDENTITY(1,1),
CustName varchar(100),
IsDefault bit
--Some sample data inserted
INSERT Customers (CustName,IsDefault)
VALUES
('Cust1',0),
('Cust2',0),
('Cust3',0),
('CASH SALE',1)
--The suggested trigger
CREATE TRIGGER Customers_No_Update ON Customers
INSTEAD OF UPDATE
AS
IF EXISTS( SELECT 1
FROM inserted i
INNER JOIN Deleted d
ON d.ID = i.ID
AND d.CustName <> COALESCE(i.CustName,'')
WHERE d.CustName = 'CASH SALE'
BEGIN
RAISERROR ('The CASH SALE customer cannot be changed nor deleted.', 16, 1)
END
ELSE
BEGIN
UPDATE c
SET CustName = i.CustName,
IsDefault = i.IsDefault
FROM Customers c
INNER JOIN Inserted i
ON i.ID = c.ID
END
GO
--The updates
-- Modifying CASH SALE IsDefault. This will succeed
UPDATE Customers
SET IsDefault = 0
WHERE CustName = 'CASH SALE'
-- Modifying Cust1 IsDefault. This will succeed
UPDATE Customers
SET IsDefault = 1
WHERE CustName = 'Cust1'
-- Modifying Cust2 Name. This will succeed
UPDATE Customers
SET CustName = 'Cust2 Test'
WHERE CustName = 'Cust2'
-- Modifying CASH SALE Name. This will fail
UPDATE Customers
SET CustName = 'CASH SALE Test'
WHERE CustName = 'CASH SALE'
Only thing I've have not covered is the scenario which ensures you've only single default cust value at any point of time. If you want that to be enforced just extend trigger as below
CREATE TRIGGER Customers_No_Update ON Customers
INSTEAD OF UPDATE
AS
IF EXISTS( SELECT 1
FROM inserted i
INNER JOIN Deleted d
ON d.ID = i.ID
AND d.CustName <> COALESCE(i.CustName,'')
WHERE d.CustName = 'CASH SALE'
BEGIN
RAISERROR ('The CASH SALE customer cannot be changed nor deleted.', 16, 1)
END
ELSE IF EXISTS( SELECT 1
FROM Customers i
WHERE IsDefault = 1
AND NOT EXISTS (SELECT 1 FROM deleted WHERE CustName = i.CustName)
BEGIN
RAISERROR ('There cant be more than 1 default customers.', 16, 1)
END
ELSE
BEGIN
UPDATE c
SET CustName = i.CustName,
IsDefault = i.IsDefault
FROM Customers c
INNER JOIN Inserted i
ON i.ID = c.ID
END
GO
and do updates
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to write one row of data at a time to "Write to File"
I am trying to write 10 parameters to the LV "Write to File". This is for just one row at a time. This happens evertime I get a failure in my test routine. I am not quite sure how to accomplish this task. If I get another failure I write one row again. I testing 4 DUTS at a time so I write this row of data to each file. I am sure it is very simple.
Thanks
PhilipAssuming your 10 parameters are an numeric array with 10 elements, use "write to spreadsheet" file with append set to true. (... and if they are scalars, built the array first ).
LabVIEW Champion . Do more with less code and in less time . -
How to pass one row of a result set to a cffunction?
I can pass the entire result set of a query to a cffunction,
but the function only needs one row.
The code below is a syntax error, where "3" is array index
notation for the third row of the result set.
What is the correct way to pass one row of a result set to a
cffunction?
Thank you.iirc, cf does not allow one to reference and access a row of
a resultset
like that.
you will have to create a structure/array that holds the data
from
specific query row and pass that to your function. looping
over
queryname.columnlist list will make it easier and not
specific to any
particular query. make it into another function that accepts
a query and
row number as arguments and returns a struct/array of that
row data (or
automatically passes it to another function).
sample code for creating a structure of specific query row
data:
<cfset rowstruct = {}>
<cfloop list="#queryname.columnlist#" index="col">
<cfset rowstruct[col] = queryname[col][somerownumber]>
</cfloop>
<cfdump var="#rowstruct#">
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/ -
How to set one row or node 's height in the jtree?
How to set height of one row or node in the jtree?
I found the method :jTree.setRowHeight(height);.
But I want to set height of one row ,not all rows of a jtree.
Thanks for help!Who can help me?
-
How to return one ROW with Multiple value seperated by Colon in a SQL Query
Hi,
I have a SQL query as mentioned.
select deptno
from deptI want to mofidfy this query, so that this should return me department list with colon delimeted in one ROW.
10:20:30:40.......Thanks,
DeepakIn 10g:
select rtrim(xmlagg(xmlparse(content deptno || ':')).getstringval(), ':') data
from dept;
DATA
10:20:30:40with apologies for the abuse of XML... -
How to update one song only?
i have about 140 songs in my ipod shuffle, and i usually have new song to add. How to delete one song in ipod memory? i just can clear it (right-click),and the memory doesn't change anything???
and if i want to add just one or two songs? how can I?i tried and my ipod didn't update ...everytime i want to add new song, i have to restore my ipod,i think it's harmful but i have no idea.
anyone help me please? i don't want my ipod will die soon...
window Windows XP ipod shuffle 512MHi,
Check this link http://docs.info.apple.com/article.html?path=iTunesWin/6.0/en/799.html
If you have any more questions post back.
Santo -
How to commit ONE block only...
Hi Guys,
I have 2 database blocks in my form. In one block user can select and enter fields from a LOV. And in other record he can enter new records and save. This is the most common senerio of my form.
But in some case he can enter new record in the first block and can enter new records in the second block.
The problem i am facing is that if user select an existing record from a LOV and then on the basis of these values he enter an other record in the second block.. COMMIT_FORM also tries to save the record in the first block and as the record already exists it gives error "unbale to insert record" i want to commit only the second block but in some cases i have to commit both blocks.
Kindly suggest me what to do please.
Imran BaigIf u want to commit one block only for a particular condition then
create an on-insert trigger at the block :
If your condition is met then
INSERT_RECORD;
ELSE
NULL;
END IF;
similary you can code on-update,on-delete triggers as per your requirement -
How to copy one row to another in table interface DATA_CELL?
I am trying to copy the data from row i_y = 7 to row i_y =8 so I am adding my code in method DATA_CELL and can't get it to work. Please let me know if you have any ideas on what I am doing wrong.
Let's say I have row #7 as:
row #7 100|200|300
After running my code below,
row #8 300|300|300
Obviously the data that is populated in row #8 is wrong because I want it to match row #7. How do I get row #8 to be the same as row #7?
I declared zvalue in the attributes tab making it global and code DATA_CELL as:
if i_y = 7.
zvalue = i_display_value.
endif.
if i_y = 8.
c_cell_content = zvalue.
endif.
Thanks for any ideas you send my way.Tried again with this modified code but it still doesn't work. Any ideas on how to get all the columns in row #7 to show up in row #8? Thanks.
data: tmp_display_value like i_display_value.
case i_y.
when 7.
tmp_display_value = i_display_value.
when 8.
c_cell_content = tmp_display_value.
endcase.
Maybe you are looking for
-
Monitor calibration no longer works -- eye-one display 2
I have been reasonably successfully calibrating monitors for my Mac Pro desktop (Apple monitor) and Macbook Pro laptop for close to 3 years, with an X-rite eye-one display 2 system. I'm using Mac OS 10.6.6 on both computers. Over the last several da
-
USB ports no longer working on EliteBook 8560W
I have an EliteBook 8560W notebook running Windows 7 SP1 64-bit. My friendly IT department was trying to fix a webcam driver, installed various sdriver and system updates, and ended up giving it back to me in worse condition than when I gave it to th
-
Lens correction profiles LR3.4 Mac
I use a mac. I shoot raw. I created lens correction profiles for my camera and a few lenses. I uploaded them to Adobe. The lens corrections show up in Adobe Camera Raw but not in Lightroom. ACR "looks" for the .lcp files in the Library/Applicatio
-
Day of Defeat[SOLVED]
Hi there! I have a problem with running Day of Defeat Steam version under Wine. Installation goes well, but when I try to start the game it goes to main screen, hangs for few seconds and then goes back to Steam. Console gives out: err:ole:CoGetClassO
-
HT2928 My "sensor" button doesn't light up
When I start my walk, my sensor button isn't lit. Also there is no start screen