dw: copy data to other rows in table?

Our app has a datawindow based on table MYSUBM which has a primary key 
of subm_no.  Suppose right now dw_subm has various data where subm_no = 
123.  Then the user changes the value of column MYADDR in that dw.  I 
need to copy the data in this field to column MYADDR in two other rows 
in table MYSUBM, where subm_no = 124 and 125.  I wonder if someone could 
suggest a good way to do this?  Thanks much.
0
Rick
3/29/2007 9:03:56 PM
sybase.powerbuilder.general 62418 articles. 18 followers. Follow

7 Replies
831 Views

Similar Articles

[PageSpeed] 2

A similar problem was discussed in the datawindow section in a thread titled 
"manipulate rowscopy".
The first question is whether you will know for sure whether the rows to be 
copied to already exist - do you need to do inserts or updates or determine 
which for each key value?

"Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message 
news:MPG.2075f37177c88227989755@forums.powersoft.com...
> Our app has a datawindow based on table MYSUBM which has a primary key
> of subm_no.  Suppose right now dw_subm has various data where subm_no =
> 123.  Then the user changes the value of column MYADDR in that dw.  I
> need to copy the data in this field to column MYADDR in two other rows
> in table MYSUBM, where subm_no = 124 and 125.  I wonder if someone could
> suggest a good way to do this?  Thanks much. 


0
Jerry
3/29/2007 9:46:19 PM
Thanks much.  They will *always* exist.

In article <460c33ab$1@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
> A similar problem was discussed in the datawindow section in a thread titled 
> "manipulate rowscopy".
> The first question is whether you will know for sure whether the rows to be 
> copied to already exist - do you need to do inserts or updates or determine 
> which for each key value?
> 
> "Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message 
> news:MPG.2075f37177c88227989755@forums.powersoft.com...
> > Our app has a datawindow based on table MYSUBM which has a primary key
> > of subm_no.  Suppose right now dw_subm has various data where subm_no =
> > 123.  Then the user changes the value of column MYADDR in that dw.  I
> > need to copy the data in this field to column MYADDR in two other rows
> > in table MYSUBM, where subm_no = 124 and 125.  I wonder if someone could
> > suggest a good way to do this?  Thanks much. 
> 
> 
> 
0
Rick
3/29/2007 9:52:03 PM
Then you want to retrieve them, do SetItem on the MYADDR column in each row, 
and Update().
If you want the user to see what is going on, you can return 2 in the 
RetrieveStart event to add the new rows rather than resetting first. You may 
also need to Sort() to put the new rows in their proper place.
If you want it invisible just create a datastore, and do the retrieve, 
setitem, update there. Be careful about keeping in sync with the datawindow. 
For instance, don't update until the DW is updated, parallel any delete in 
the DW with RowsDiscard in the DS, use Find() to do setitem on the correct 
row(s)....

"Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message 
news:MPG.2075ff0a4b067913989756@forums.powersoft.com...
> Thanks much.  They will *always* exist.
>
> In article <460c33ab$1@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
>> A similar problem was discussed in the datawindow section in a thread 
>> titled
>> "manipulate rowscopy".
>> The first question is whether you will know for sure whether the rows to 
>> be
>> copied to already exist - do you need to do inserts or updates or 
>> determine
>> which for each key value?
>>
>> "Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message
>> news:MPG.2075f37177c88227989755@forums.powersoft.com...
>> > Our app has a datawindow based on table MYSUBM which has a primary key
>> > of subm_no.  Suppose right now dw_subm has various data where subm_no =
>> > 123.  Then the user changes the value of column MYADDR in that dw.  I
>> > need to copy the data in this field to column MYADDR in two other rows
>> > in table MYSUBM, where subm_no = 124 and 125.  I wonder if someone 
>> > could
>> > suggest a good way to do this?  Thanks much.
>>
>>
>> 


0
Jerry
3/29/2007 10:10:56 PM
Forgot to add - this kind of thing is often done with triggers in the 
database. More efficient, and you don't have to worry about putting it in 
multiple places in the front end - the business rule is always enforced.

"Jerry Siegel [TeamSybase]" <jNOsSPAMsiegel@yahoo!.com> wrote in message 
news:460c3970$1@forums-1-dub...
> Then you want to retrieve them, do SetItem on the MYADDR column in each 
> row, and Update().
> If you want the user to see what is going on, you can return 2 in the 
> RetrieveStart event to add the new rows rather than resetting first. You 
> may also need to Sort() to put the new rows in their proper place.
> If you want it invisible just create a datastore, and do the retrieve, 
> setitem, update there. Be careful about keeping in sync with the 
> datawindow. For instance, don't update until the DW is updated, parallel 
> any delete in the DW with RowsDiscard in the DS, use Find() to do setitem 
> on the correct row(s)....
>
> "Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message 
> news:MPG.2075ff0a4b067913989756@forums.powersoft.com...
>> Thanks much.  They will *always* exist.
>>
>> In article <460c33ab$1@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
>>> A similar problem was discussed in the datawindow section in a thread 
>>> titled
>>> "manipulate rowscopy".
>>> The first question is whether you will know for sure whether the rows to 
>>> be
>>> copied to already exist - do you need to do inserts or updates or 
>>> determine
>>> which for each key value?
>>>
>>> "Rick Charnes" <rickxyz--nospam.zyxcharnes@yahoo.com> wrote in message
>>> news:MPG.2075f37177c88227989755@forums.powersoft.com...
>>> > Our app has a datawindow based on table MYSUBM which has a primary key
>>> > of subm_no.  Suppose right now dw_subm has various data where subm_no 
>>> > =
>>> > 123.  Then the user changes the value of column MYADDR in that dw.  I
>>> > need to copy the data in this field to column MYADDR in two other rows
>>> > in table MYSUBM, where subm_no = 124 and 125.  I wonder if someone 
>>> > could
>>> > suggest a good way to do this?  Thanks much.
>>>
>>>
>>>
>
> 


0
Jerry
3/29/2007 10:25:38 PM
Ach, I just realized my explanation was terrible.  I need to copy *all* 
changed data in my dw off to the two other rows.  So maybe using SetItem
() might not work.  OK, say I create a datastore mirror.  I do my update
() on the original dw, then retrieve into the datastore with the new 
retrieval argument (subm_no = 124), but then how can I get all the 
changed data from the original row into the datastore?  Hmmm...RowsCopy
()... but then I have the subm_no column which I *don't* want to 
overwrite.

On another track, I had this fantasy of going into the SQLPREVIEW event 
of the dw, parsing the SQLSYNTAX string and replacing '123' first with 
'124' and then with '125' and .... is there a way to let the original 
SQL get sent to the database but then execute it *again*, the second 
(and third) time with a changed SQL statement with the new subm_no that 
I've parsed and created?

Hmmm...just thinking out loud...  Thanks for all your help.


In article <460c3970$1@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
> Then you want to retrieve them, do SetItem on the MYADDR column in each row, 
> and Update().
> If you want the user to see what is going on, you can return 2 in the 
> RetrieveStart event to add the new rows rather than resetting first. You may 
> also need to Sort() to put the new rows in their proper place.
> If you want it invisible just create a datastore, and do the retrieve, 
> setitem, update there. Be careful about keeping in sync with the datawindow. 
> For instance, don't update until the DW is updated, parallel any delete in 
> the DW with RowsDiscard in the DS, use Find() to do setitem on the correct 
> row(s)....
> 
0
Rick
3/30/2007 3:06:31 AM
To do that you would walk through the copiable columns, do GetItemStatus to 
see if each changed, and if so do a SetItem on each row in the retrieved DS 
mirror.
You could also create the rows in the DS with RowsCopy, then set each 
subm_no and do SetItemStatus to NotModified on that column and SetItemStatus 
to DataModified  on the row to generate UPDATE rather than INSERT. You would 
also have to have the DW object set to update with keys only because there 
is no Original data to compare with.
SQLPreview goes row by row, but I suppose you could pass the SQLSYNTAX to a 
script that tweaks it and uses EXECUTE IMMEDIATE or dynamic SQL to run it.
I still like the idea of a database trigger better - which DBMS are you 
using?

"Rick Charnes" <blue.heron3@verizon.net> wrote in message 
news:MPG.2076566ee597b36d989680@forums.sybase.com...
> Ach, I just realized my explanation was terrible.  I need to copy *all*
> changed data in my dw off to the two other rows.  So maybe using SetItem
> () might not work.  OK, say I create a datastore mirror.  I do my update
> () on the original dw, then retrieve into the datastore with the new
> retrieval argument (subm_no = 124), but then how can I get all the
> changed data from the original row into the datastore?  Hmmm...RowsCopy
> ()... but then I have the subm_no column which I *don't* want to
> overwrite.
>
> On another track, I had this fantasy of going into the SQLPREVIEW event
> of the dw, parsing the SQLSYNTAX string and replacing '123' first with
> '124' and then with '125' and .... is there a way to let the original
> SQL get sent to the database but then execute it *again*, the second
> (and third) time with a changed SQL statement with the new subm_no that
> I've parsed and created?
>
> Hmmm...just thinking out loud...  Thanks for all your help.
>
>
> In article <460c3970$1@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
>> Then you want to retrieve them, do SetItem on the MYADDR column in each 
>> row,
>> and Update().
>> If you want the user to see what is going on, you can return 2 in the
>> RetrieveStart event to add the new rows rather than resetting first. You 
>> may
>> also need to Sort() to put the new rows in their proper place.
>> If you want it invisible just create a datastore, and do the retrieve,
>> setitem, update there. Be careful about keeping in sync with the 
>> datawindow.
>> For instance, don't update until the DW is updated, parallel any delete 
>> in
>> the DW with RowsDiscard in the DS, use Find() to do setitem on the 
>> correct
>> row(s)....
>> 


0
Jerry
4/1/2007 7:17:21 PM
Thanks much.  We're using SQL Server.  The powers-that-be have nixed the 
idea of using a trigger as they're worried it might adversely impact 
other functions.  The SQLPREVIEW solution has turned out to work well.  
There are about a dozen dw's that this needs to be done for, and the job 
of creating a dozen mirror datastores seemed daunting.  I wrote a 
function that's called in the SQLPREVIEW event of each of the twelve 
dw's, and I'm off and running.

I really appreciate your taking the time to help me with this.

In article <460ff731@forums-1-dub>, jNOsSPAMsiegel@yahoo!.com says...
> To do that you would walk through the copiable columns, do GetItemStatus to 
> see if each changed, and if so do a SetItem on each row in the retrieved DS 
> mirror.
0
Rick
4/2/2007 12:15:03 AM
Reply:

Similar Artilces:

How to move a row in a data table object to the top of the table? The data table is in a data set. The data is bound to a drop down list box.
I am maintaining some 2003 C#/asp.net code for a web application. In the application a table in a data set is usedto populate a drop down list box.(The drop down list box will display a list of names) Before the data set table is bound to the list box control, blank characters are inserted at the topof the data set table. The purpose of this, is to display a blank line in the drop down list box, when the list box isinitially displayed. This code works fine. (See lines 1-14 below). Now I have been asked to modify the source code so that instead of a blank line being inserted at to top of th...

Adding Rows from different Data table to a single Data Table
Hi, I have 3 data tables say dt1, dt2, dt3. None of the tables have any relation with each other. Now i my requirement is to merge all these 3 datatables into 1.  But, i dont want it into different rows. Means to say, record from 1st, 2nd and 3rd table shud be merged as a single row in resultant datatable. Below example explains better Table 1 : 123 abc 890 Table 2 : rew 234 Table 3: sdfsd 234 dfg 45645 Now Resultant table shud be :  123 abc 890 rew 234 sdfsd 234 dfg 45645 Any help is appreciated :) Thanks in advance   If you keep your feet firmly on ...

How to select data from a table and insert the selected data in the same table as new row
Hi    I have a table called Version and its attributes are Version_ID, Project_ID , Hospital_ ID , Date_Created and comments. I want to select the data by Version_ID,Project_ID and  Hospital_ID and the selected data is inserted in the same table(Version) as new row . Table: Version (Version_ID(Primary_key), Project_ID(Foreign_Key),Hospital_ID(Foreign_Key),Date_Created,Comments).  Iam using Visual Web Developer Express 2005 and SQL Server 2005. Iam doing on asp.net 2.0. Could anyone please send me the code in asp.net 2.0 for the above problem. ...

Data row from a Data Table
Hi All, I have a method which returns all the rows to a DataTable.  So from that Data Table I want a particular Row whose values should be assigned to text boxes on the webpage. Please can any help me out on how to do this ? Thanks for your time..   // assuming that you want the first row DataRow r=dataTable1.Rows[0]; TextBox1.Text=r["Column1"]; TextBox2.Text=r["Column2"];  Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensiv...

How do you copy table data to another table?
I need to copy existing row data from one table into a new row in a different table, both in the same database.  Can this be done in a stored procedure where the selected row is passed in as parameter value? Thank you, There's plenty of ways you can do this.Try INSERT INTO YourTable (.column list) SELECT (columnlist) FROM YourTable WHERE <Condition>  ***********************Dinakar NethiLife is short. Enjoy it.*********************** that easy? thank you.  I am getting that 'can't see the forest for the trees' feeling....

how to copy gridview data to data table...?
Hi all, I need to copy a grid with headerrow,datarow,footerrow into a data table.... how to acheive this...plz help meThanks,Cute You can do in following steps: (1) New DataTable (2) Add columns exactly same as DataGrid.Columns.count (3) Add data by adding rows in datatable of datagrid. you need to iterate this process till gridview.rows.count (4) dt.rows.acceptchanges :)Manish Sharma  http://www.codeproject.com/KB/aspnet/GridView_To_DataTable.aspxPlease Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.comhttp://www.mitatdotnet.blogspot.co...

Copying data from one table to other table
Hello All, I have two tables in DB2, BNKDBF and BNKPOS. Lets call there tables A and B respectively. Table A has 11 rows and 9 fields. And Table B has zero rows and 11 fields. One thing.. there will always be 11 rows in table A. Now i want to do is that copy those 11 rows from Table A to Table B and then put data in two additional fields in all rows of Table B. Faisal insert into tableB   select * from tableAYou'll need to give more information on the additional fields if you want help with them.Nick Nick, Please can ellaborate this thing a little bit...

Copying a row of data to another row
I have multiple tables with a lot of columns. The users of the application would like to populate freeform datawindows with the data from a previous row (record). Only 1 table is used in each of the datawindows and I know the primary key values for the rows to copy from and to. What is the most efficient way to have a user click a button or select a menu option to populate the current row with all the values (minus the primary key) from a prior row? The version of PB is 10.2 and the database is MS SQL 2005. Any ideas or suggestions would be much appreciated. Thanks Don This is...

stored procedure to copy table 1 to table 2 appending the data to table 2.
Just wondering if there is an easy transact statement to copy table 1 to table 2, appending the data in table 2.with SQL2000, thanks.Paul GSoftware Engineer Appending the rows, or the columns? Append rows: Insert into table2SELECT * FROM table1 Append columns: UPDATE Table2SET t2.col1=t1.col1+t2.col1, t2.col2=t1.col2+t2.col2, etcFROM Table2 t2JOIN Table1 t1 ON (t1.yourkeyhere=t2.yourkeyhere) Not sure how useful the second append is, and it'd be really odd to actually want to do that, but you can, if you ever really needed to ;p ok thanks, just need to append the rows.  Lo...

copy data from excel row to gridview row
Hi All, I need to copy data from excel to asp.net gridview. I have to select a row and press Ctrl+C to copy from excel, then I have to paste it in Gridview. Thanks in advance. I dont think you can Copy and Paste data from Excel to Gridview.But you can export data from Excel to GridView control, please check the below articles.http://www.aspdotnetcodes.com/Importing_CSV_Database_Schema.ini.aspxhttp://www.aspdotnetcodes.com/SqlbulkCopy_Data_Transfer.aspxMarking a Reply as 'Answered', not only GAIN us some POINTS, but it also HELP others to find RIGHT solution....

Copy all data from MSSQL tables to Access table
I want to copy all data and tables from my mssql database to a new access database. Is this possible?Cheers,Curt.Regards, Curt...

How To copy rows from crosstab DW to crosstab DW
Hi All, i am using pb8 and i am trying to copy rows from crosstab DW to crosstab DW, But the return code is -1 why? How can i copy rows from crosstab to crosstab or shardata from crosstab to crosstab? thanks david ...

Hiding html table rows and table data
Hello, I have a user control which has an html table with 2 tds per tr like this:<table> <tr> <td style="padding-left:10px;"><asp:HyperLink ID="hlListings" runat="server" ForeColor="#0c6db4"></asp:HyperLink><asp:Label ID="lblAll" runat="server" ForeColor="#999999"></asp:Label></td></tr> <tr> <td style="padding-left:10px;"><asp:HyperLink ID="hlOfferAuction" runat="server" ForeColor="#0c6db4"></asp:Hype...

how delete a 1 row data in data table?
hi ! i know this is a newbie type of question! Im afraid! anyone knows how delete a 1 row data in data table? thanks in advanced!practice makes perfect but nobody is perfect so why practice! You can remove a row one of two ways. DataTable.Remove(DataRow)DataTable.RemoveAt(Index) HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

Web resources about - dw: copy data to other rows in table? - sybase.powerbuilder.general

Table of United States Core Based Statistical Areas - Wikipedia, the free encyclopedia
for the United States of America . The OMB defines a Core Based Statistical Area as one or more adjacent counties or county equivalents that ...

Standards organization accepts completion of last row of periodic table
... momentous discovery: it was accepting the existence of four new chemical elements. Combined, they complete the bottom row of the periodic table. ...

"Periodic table's seventh row finally filled as four new elements are added."
... of four super-heavy chemical elements by scientists in Russia, America and Japan has been verified by experts and formally added to table." ...

petition asks to have a heavy metal element on the periodic table named after Lemmy
Lemmy w/ Motörhead in Austin, 2015 (more by Tim Griffin) Heavy rock lost its most iconic figure over Christmas with the sudden and unexpected ...

The periodic table is getting four new elements
The new elements complete another row on the periodic table; what will they be called?

Name game: What to call the periodic table's four newest elements? (+video)
The four elements, the first to be added to the periodic table since 2011, are currently known as 113, 115, 117 and 118. Got a better name?

Bills Fan Destroys Flaming Table Because Some Men Just Want To Watch The World Burn
Bills Fan Destroys Flaming Table Because Some Men Just Want To Watch The World Burn

Four New Elements Added to Periodic Table
Elements 113, 115, 117, and 118 have met criteria for discovery, making them the first elements to be added to the periodic table since 2011. ...

Four new 'superheavy' elements added to the periodic table
... teachers everywhere will soon instruct their pupils to buy new textbooks or grab a pen and manually add four new elements to the periodic table. ...

Periodic Table gains four new superheavy elements, completing the seventh row
A multinational team of scientists has isolated four new superheavy elements that sit at the very end of the periodic table, completing the seventh ...

Resources last updated: 1/7/2016 4:13:42 AM