Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set a particular data to all the rows in column

Status
Not open for further replies.

jaibin1984

Programmer
Feb 20, 2011
7
How to set a particular data to all the rows for a column in a data window without using the Array or any loops.
 
I am having a data window with 100 rows, and the columns are C1, C2, C3.
I want to set 12345 to all the rows in the column C1

Like this


C1 C2 C3
Abc 12345 1
123 12345 2
qwer 12345 A
123 12345 B
qwdqw 12345 4

So if there is anyway i can set the 12345 to all the rows in the column i can avoid the loop. The row no can be variable, sometimes it can be 100 or 200 or 10000
 
Try the SQL Script UPDATE:

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value

In your case,

UPDATE table_name
SET C1=12345

 
I cant update it into the table,, because i am running in a loop and i am getting collection of records from another datawindow. and before inserting the next collection i want to set a reference data to all the rows in the current collection to identify that from which collection it came, so if i use a loop again that will take too much time so to avoid that loop i need to set the reference data to all the rows in the collection.
 
How is the data getting into the datawindow? Are you using sharedata or rowscopy? What happens to the first set of data when you load the second? You may be able to use a datawindow expression depending upon what's happening.

Matt

"Nature forges everything on the anvil of time"
 
i am getting the data from some excel files , i am copying the data from the excel file (more than 100 excel files ) to a data window (Dw_1). (The data in the each file can vary columns will not change but the rows can go higher or lower)
I am reading each file to the data window Dw_1 and copying that to the dw_Actual using the rows copy method. The Dw_1 will be reset after each loop, but the dw_actual will contain all the data from all the excel files.

In order to keep track which data is coming from which excel file I need to add a refernce value say excel name to each section of data recorded in the dw_1. and also some vr_no's and all. because of i am already in a loop i cant declare another inner loop so i want a method that i can set the particular data value to all the rows in a column.
 
Okay, If the data is being imported from excel files, add a column to the DW_1 dataobject of type string (example column is 'sourcefile'). Once the data is loaded into DW_1 use the modify method similar to:
Code:
integer li_rc
string ls_filename
ls_file_name = <put name of file just loaded here>
li_rc = dw_1.modify("sourcefile='" + ls_filename + "'")

Now rowscopy this to dw_actual and continue on...

Matt

"Nature forges everything on the anvil of time"
 

Thanks for the replay..

I added a column 'file_name'
But when i use this cammand i am getting an error message like

line1: coolumn 12, incorrect syntax.

String
lS_ret = dw_1.modify("file_name='" + String('Jaibin') + "'" )
 
Had u checked this command , because while i am using i am getting an error messgae like 'line1: column 12, incorrect syntax. '

as per my understanding the Modify command is using to change the data window attributes or properties.

 
You don't believe you can do what I thought you could do. I've experimented with dynamically adding a column to a datawindow as you load each spreadsheet's values but it doesn't appear as though you can set the initial value of the new column. Dynamically adding a computed column works but then copying the rows to the permanent datawindow does not copy the data from the computed field.

Matt

"Nature forges everything on the anvil of time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top