Home > database >  For beginners a simple code
For beginners a simple code

Time:10-22

Dw_1 data source for table_1 (qy_code qy_name, zsxm_ds, SFSSQQ, SFSSQZ, sl, ynse), through dw_1 input data, save time, I want to table_1 data is copied to the table_2 (qy_code qy_name, zsxm_ds, SFSSQQ, SFSSQZ, ynse), make the table_2 also has the corresponding data, I use the insert into statement is, can only save the data of the last line, consult, how to make many rows of data at the same time save to another table

CodePudding user response:

Insert into table2 (qy_code, qy_name zsxm_ds, SFSSQQ, SFSSQZ, ynse)
The select qy_code qy_name, zsxm_ds SFSSQQ, SFSSQZ, ynse from table2 where qy_cod in (' 1 ', '2')

'1', '2' for you need to import the data

CodePudding user response:

Still did not understand to the 1, 2, I, for example, the following graph: according to the 1, 2 and what is the

CodePudding user response:

Write a loop,,

CodePudding user response:

CodePudding user response:

Please grant instruction!!!!!!!!!!!

CodePudding user response:

Using database triggers,
Business logic is also problematic,
Why keep two copies?

CodePudding user response:

Table_2 do chart analysis is established, it wants to put all the summary together, table_1 table_2 just part of the data sources, no matter how much I make, can only save above is shown in the third row, the other two rows of data can't save

CodePudding user response:

It is recommended to use triggers,

CodePudding user response:

Insert data in the data window, can only be one line insertion, if so, save can only be saved when the latest row data, lz can try one line of the input data.

CodePudding user response:

You can make two dw on the interface, a dw1 data link table_1, another table_2 dw2 connection, in this way, you are in the preservation, after all records in the dw1 convenience, insert dw2, finally, two dw update together,

CodePudding user response:

I do is a tax return system, its different taxpayers to pay taxes is not the same, the rights of taxpayers itself is no input data, the only thing that can enter only ynse, SFSSQQ, SFSSQZ, as pictured above other system of these items are automatically according to the information of the taxpayers, so can't a a input or build two DW as upstairs said, after can only fill in the data directly to save,

CodePudding user response:

I'd like to ask, what is upstairs said database triggers, and I heard that pointer can also be used to solve this problem, pointer, please

CodePudding user response:

Trigger is a special stored procedure, it is binding on the table, the execution of it is not by the program calls, nor the manual start, but by the event to trigger, such as when a table for operations (insert, delete, update) will activate it

CodePudding user response:

If you want to set up database triggers, where should be created

CodePudding user response:

Now I use a for loop, the code is as follows (g_id g_name for global variables, q, z for local variables) :
Dw_grid. Accepttext ()
R_row_count=dw_grid. Rowcount ()
For I=1 to r_row_count
R_xm=dw_grid. Getitemstring (I, 'zsxm_ds')
R_ynse=dw_grid. Getitemdecimal (I, 'ynse')
Insert into ywxxb_sz (qy_code, qy_name SFSSQQ, SFSSQZ, zsxm_ds, ynse) values (: g_id, : g_name, : q, : z, : r_xm, : r_ynse);
Next
Why or just to save a row, and this time saved is not the last line, become the first line, but when I was in the debugger found r_xm, r_ynse may due to the change of the number of rows into different content, or what my code is almost

CodePudding user response:

Establish database triggers,

CodePudding user response:

Rowscopy, line between two DW copy, this is very simple, just what are you doing dw_2 try to define the field name and dw_1,,
Such as dw_1 query is a select qy_code qy_name, zsxm_ds, SFSSQQ, SFSSQZ, sl, ynse from table1, the query is selectqy_code dw_2, qy_name, zsxm_ds, SFSSQQ, SFSSQZ, '0' as sl, ynse from talbe2
Dw_2 need not include in the update sl columns can be...

The use of the following is rowscopy
Datawindowchild DWC

Dw_3. GetChild (" state_id, "DWC)

Dw_1. RowsCopy (dw_1. GetRow (), & amp;

Dw_1. RowCount (), Primary! DWC, 1, Primary!)

CodePudding user response:

Now I use a for loop, the code is as follows (g_id g_name for global variables, q, z for local variables) :
Dw_grid. Accepttext ()
R_row_count=dw_grid. Rowcount ()
For I=1 to r_row_count
R_xm=dw_grid. Getitemstring (I, 'zsxm_ds')
R_ynse=dw_grid. Getitemdecimal (I, 'ynse')
Insert into ywxxb_sz (qy_code, qy_name SFSSQQ, SFSSQZ, zsxm_ds, ynse) values (: g_id, : g_name, : q, : z, : r_xm, : r_ynse);
Next
Why or just to save a row, and this time saved is not the last line, become the first line, but when I was in the debugger found r_xm, r_ynse may due to the change of the number of rows into different content, or what my code is almost
/////////////////////////////////////////////////////////
Every time after insert, all seem to want to commit the, you give it a try, I also forgot,

CodePudding user response:

refer to 7th floor ha_ha_ha_00 response:
table_2 do chart analysis is established, it wants to put all the summary together, table_1 just table_2 part of data sources, no matter how much I make, can only save the third row in the above, the other two rows of data can't save

According to your demand actually table_2 a view can be used in place of the line, the trigger is also a good choice

As for the place that you use a for loop to insert the data at the back of the insert statement to evaluate the SQLCA. SQLCode, cautious doubt is a primary key to repeat a class problem

CodePudding user response:


She answers posts found that it was a year ago, who is so boring to top it up?

CodePudding user response:

Database, it is ok to use trigger
Program, through dw_1. Getitemstring () to obtain corresponding data assigned to dw_2

CodePudding user response:

Or use according to trigger the most convenient, but you can use PB, with rowscopy from dw_1 to dw_2 dw_1 and dw_2 dataobject, dw_2. After the update ()

CodePudding user response:

Access to rows first, and then through the FOR loop can be achieved,

CodePudding user response:

reference 15 floor ha_ha_ha_00 response:
now I use a for loop and code is as follows (g_id g_name for global variables, q, z for local variables) :
Dw_grid. Accepttext ()
R_row_count=dw_grid. Rowcount ()
nullnullnullnullnullnullnullnullnull
  • Related