How to insert One table value to Another Table
Hi friends
Please have a look on this Code. Since i am new Java i am not able to findout the Solution for it
private void displayavailablity(String selecteditem1)
try
Vector columnNames = new Vector();
Vector data1 = new Vector();
String bname,bauthor,bcategory,bref1,bavail,bid;
int bref,mid,num;
rs = st.executeQuery("SELECT * FROM Books where BAuthorandPublisher='" + selecteditem1 +"'");
while(rs.next())
bname = rs.getString("BName");
bauthor = rs.getString("BAuthorandPublisher");
bcategory = rs.getString("BCat");
bref = rs.getInt("BRef");
if(bref==1)bref1="Yes";
else bref1 = "No";
mid = rs.getInt("Mid");
if(mid==0)bavail="Available";
else bavail="Issued To:"+mid;
bid = rs.getString("BId");
System.out.println("Book Name is::"+bname);
System.out.println("Book Availabilty::"+bavail);
num = st.executeUpdate("insert into BSearch Values('"+bid+"','"+bname+"','"+bcategory+"','"+bauthor+"','"+bavail+"','"+bref1+",')");
System.out.println("Inseted in the table");
/**ResultSetMetaData md= rs.getMetaData();
int columns =md.getColumnCount();
String booktblheading[]={"Book ID","Book NAME","BOOK AUTHOR/PUBLISHER","REFRENCE","CATEGORY"};
for(int i=1; i<= booktblheading.length;i++)
columnNames.addElement(booktblheading[i-1]);
while(rs.next())
Vector row = new Vector(columns);
for(int i=1;i<=columns;i++)
row.addElement(rs.getObject(i));
data1.addElement(row);
//System.out.println("data is:"+data);
((DefaultTableModel)table.getModel()).setDataVector(data1,columnNames);
//DefaultTableModel model = new DefaultTableModel(data1,columnNames);
//table.setModel(model);
rs.close();
//st.close(); */
catch(SQLException ex)
}I trigger this Method when a JComboBox Item is Selected.
For an example when i select an Item the select Query brings all the Record Equals to the Selected item. Now i want to insert the Selected items with some Modification to Another Table.
Now the Problem is My Program Inserts Only One Record (Though there are Many Records Equals to Selected Item)
Please give me a Better Solution
Thank you
jolif,
If you're "new to java" then might I suggest you leave swing until you're "not so new to java"... it involves so many "advanced concepts" (unlike VB) that it constitutes a biohazard... i.e. it's fundamentally inimical to humanoid lifeforms.
Now... Having duly vented my spleen, try rs.updateRow();
Similar Messages
-
How to insert comma delimited values into a table
I have a variable holding values like,
'A,Ba,Ccc' OR
'1,2,3,4'
I want to know how to convert and insert these values in oracle table as seperate rows like,
A
Ba
Ccc[ OR ]
1
2
3
4
Thanks,
PrevinAnswered (I guess) in this dbms_utility.comma_to_table.
Cheers, the ever helpful APC -
How to insert apex_application_files file content into another table?
Hi All,
I am using Apex 3.2 on Oracle 10g.
I have used 'file_browse' item to upload a spreadsheet file into apex_application_files table.
I would like to populate another table with the contents of this spreadsheet file from apex_application_files.
I have spent almost 2 days looking for an answer on how to do this.
Can you please tell me how to do this or point me to a good resource?
Thank you,
Naushad.Hi Thanks,
I did see this code, but this is not what I was looking for. This code simply inserts the file into another table, but I was looking for the contents of this file (eg. a single column spreadsheet with 10 lines and all ten of these lines to be inserted as rows in a table) inserted as rows into another table.
I managed to implement this by following below link:
http://nzchaudhry.wordpress.com/2011/07/18/uploading-csv-using-oracle-application-express-apex/
Thanks to all of you.
Naushad. -
How to pass one lookup value to another lookups
Hi All,
I've two relational sources with a join condition,added lookup and kept join condition too.I've to pass this lookup value to another lookup.
let me know how we can handle this in odi.
ThanksIf you don't use "expression in the SELECT clause" option, why don't you simply drag and drop your file datastores in your canvas and do a standard join?
The result will be the same.
See here for more details : Re: Lookup Vs Join -
How to add one textbox value into another textbox value every month in a list of infopath 2013
InfoPath 2013.
I have created a list in which I placed 2 textboxes.
I have one textbox named Paid Amount:
Second textbox named Invoice Amount:
I want when I add any amount in Invoice Amount textbox in every month it Add into
Paid Amount textbox
How I can do this ?
for e.g:
Paid Amount : 2
Invoice Amount: 3
Paid Amount = 5
When enter next month 6 in Invoice Amount the
Paid Amount turn into 11.You can apply formula using a rule by creating a hidden field and calculate the values. Refer to the following posts for more information
http://office.microsoft.com/en-in/infopath-help/add-subtract-multiply-and-divide-values-HP001096532.aspx
https://support.office.com/en-us/article/Add-rules-for-performing-other-actions-5322d726-b787-4e5f-8d37-ba6db68b451d?ui=en-US&rs=en-US&ad=US
and for complex calculations using code, refer to the following posts
http://www.infopathdev.com/forums/p/21500/74297.aspx
http://drekendrop.blogspot.in/2011/03/infopath-2010-get-and-set-value-of.html
Cheers, -
How get the all the table values to another table based on Action
Hi All,
I am new to webdyn pro.
I have two tables Table1 and Table2 with context nodes Tab and Tab1.
Table1 I have a button Save If I submit Save the data from first table to second table .
I was written the code
IPrivateTableScrollBar.ITabElement element;
for(int i=0;i<10;i++)
element=wdContext.createTabElement();
element.setName("test"+i);
element.setSal("100"+i);
wdContext.nodeTab().addElement(element);
added some data to first table.
how can I get the all 10 rows from first table to second table if I write wdContext.node<Element>.getName() and getSal() I can get only selected one row .how can I get the all rows in a sigle click to second table.
please help.Hi mohammed,
Use the following lines of code to iterate through the elements :
Iprivate<your view>.I<your node1 name>Element elmt1 = null;
Iprivate<your view>.I<your node2 name>Element elmt2 = null;
for(int i=0;i<wdContext.node<your node1 name>().size();i++)
elmt2 = wdContext.node<your node2 name>().create<your node2 name>Element();
elmt1 = wdContext.node<your node1 name>().get<your node1 name>ElementAt(i);
elmt2.set<attribute name>(elmt1.get<attribute name>);
wdContext.node<your node2 name>().addElement(elmt2);
Hope this helps,
Best Regards,
Nibu. -
How to insert one XML document into another
Hi,
I've been working on a simple CMS.
There is a main template that is just a HTML page. The main template has a few extra 'module' tags that indicates places where individual modules have to be placed.
main template: template.xml
<html>
<body>
<div>
<module id="centre"/>
</div>
</body>
</html>module template: module_centre.xml
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>My application has to detect every 'module' tag from the template.xml and insert there XML content from a proper module template.
The result file has to be generated dynamically on a request. The structures of 'modules' can be only defined in module_*.xml files.
The expected result
<html>
<body>
<div>
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>
</div>
</body>
</html>What's the best practice do solve this case?
PawelI think I've came up with a better solution.
SRC file
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<title></title>
<style type="text/css">
div.c4 {background-color:pink;width:400px;height:50px}
div.c3 {background-color:green}
div.c2 {background-color:blue;width:400px;height:299px}
div.c1 {background-color:red}
</style>
</head>
<body>
<module id="XXX"/>
<div id="main" class="c3">
<div id="top" class="c1"><module id="menu_test"/></div>
<div id="bottom" class="c2"><module id="menu_test2"/></div>
</div>
<div id="footer_container" class="c4"> <module id="menu_footer"/></div>
</body>
</html>MODULE src file
<?xml version="1.0" encoding="UTF-8"?>
<div id="admin_panel_module" style="background-color:orange;width:200px;height:50px">
<p>Control Panel TEST</p>
</div> @param source - NODES from MODULE document
*@param target - TEMPLATE document where MODULES are going to be inserted*
@throws Exception
public static void insertModules(Node source, Document target) throws Exception {
Node importedNodes = target.importNode(source, true);
// Use XPath to find all 'module' nodes in ''
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) xpath.evaluate("//module", target, XPathConstants.NODESET);
// Remove MODULE node and insert there an XML content from MODULE template
for (int idx = 0; idx < nodes.getLength(); idx++) {
Node editedModuleElement = nodes.item(idx);
// parent of module mode
Node parentNode = editedModuleElement.getParentNode();
// replace <module/> node with imported nodes from 'module' XML document
parentNode.replaceChild(importedNodes, editedModuleElement);
// nodes.item(idx).appendChild(node);
importedNodes = target.importNode(source, true);
}Edited by: maestr0 on May 24, 2010 12:44 AM -
How to insert into default values in onli 1 column of a table
if u create a table with onli 1 column
which can accept a default value of say
only 100.
then how do u actualli enter values into the table.
is there any data dictionary which stores details about default
values of a tableThe default value for a column is the value that will be stored
for that column if you do not provide one in your insert
statement. If you do provide a value, then it will be stored in
the column.
You can query user_tab_columns ( or all_ or dba_)to see the
default value assigned to a column. -
How to insert check box value in table?
Hi all
kindly help me how to insert check box value in database. what code i have to use as i am new in programing.
thanx in advanceHi,
There is no "Check box" in a table, a check box is a GUI (Graphical user interface) item.
What you want is to store a boolean value in a table. For that you can use the varchar2(1) datatype and store Y or N. (or anything else)
(you cannot define boolean as a datatype for a column).
If you're using a front-end application like apex then it might be useful for you to read the documentation about chekc boxes :
http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/check_box.htm#CHDDFBFH
(for the rest if it's Oracle Forms then everything is already said).
Edited by: user11268895 on Aug 17, 2010 10:44 AM -
How to update one table based on another table ??
Hello Friends:
I am trying to run the following query in oracle but it won't run.
UPDATE BOYS
SET
BOYS.AGE = GIRLS.AGE
FROM GIRLS
WHERE
BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
BOYS.LASTNAME = GIRLS.LASTNAME;
This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
thanksSee if this helps.
If you wrote an SQL statement:
update boys set age = 10;
Every row in the boys table will get updated with an age of 10. But if you wrote:
update boys set age = 10
where firstname = 'Joe';
Then only the rows where the firstname is Joe would be updated with an age of 10.
Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
About the select null question regarding the outer where clause:
Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here. -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
How could I insert the deleted row into another table within a trigger?
Hi,
How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
CREATE TRIGGER delete_trigger
AFTER DELETE
ON test
FOR EACH ROW
BEGIN
-- How could I insert the deleted row into another table
END delete_trigger;
Message was edited by:
user569548Hi,
I'm not sure what's wrong there.
I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
SELECT column_name
FROM all_tab_columns
WHERE table_name = 'my_tab'; //but no rows selected?
This topic might not be what this thread should be about. Here I posted a new thread:
How to get colum names of the newly created table?
Thanks.
Message was edited by:
user569548 -
Copy selected values from a table control into another table control
hi there,
as seen in the subject i need to copy selected values from a table control into another table control in the same screen. as i dont know much about table controls i made 2 table controls with the wizard and started to change the code... right now im totally messed up. nothing works anymore and i don't know where to start over.
i looked up the forums and google, but there is nothing to help me with this problem (or i suck in searching the internet for solutions)
i have 2 buttons. one to push the selected data from the top table control into the bottom tc and the other button is to push selected data from the bottom tc into the top tc. does somebody has a sample code to do this?you're funny
i still don't get it... can't believe, there is no tutorial or sample code around how to copy multiple selected rows from a tc.
here's my code, maybe you can tell me exactly were i have to change it:
tc1 = upper table control
tc2 = lower table control
SCREEN 0100:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE get_nfo. --> gets data from the dictionary table
MODULE tc1_change_tc_attr.
LOOP AT it_roles_tc1
INTO wa_roles_tc1
WITH CONTROL tc1
CURSOR tc1-current_line.
ENDLOOP.
MODULE tc2_change_tc_attr.
LOOP AT it_roles_tc2
INTO wa_roles_tc2l
WITH CONTROL tc2
CURSOR tc2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_roles_tc1.
CHAIN.
FIELD wa_roles_tc1-agr_name.
FIELD wa_roles_tc1-text.
ENDCHAIN.
FIELD wa_roles_tc1-mark
MODULE tc1_mark ON REQUEST.
ENDLOOP.
LOOP AT it_roles_tc2.
CHAIN.
FIELD wa_roles_tc2-agr_name.
FIELD wa_roles_tc2-text.
ENDCHAIN.
FIELD wa_roles_tc2-mark
MODULE tc2_mark ON REQUEST.
ENDLOOP.
MODULE ok_code.
MODULE user_command_0100.
INCLUDE PAI:
MODULE tc1_mark INPUT.
IF tc1-line_sel_mode = 2
AND wa_roles_tc1-mark = 'X'.
LOOP AT it_roles_tc1 INTO g_tc1_wa2
WHERE mark = 'X'. -
> big problem here is, that no entry has an 'X' there
g_tc1_wa2-mark = ''.
MODIFY it_roles_tc1
FROM g_tc1_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc1
FROM wa_roles_tc1
INDEX tc1-current_line
TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
MODULE tc2_mark INPUT.
IF tc2-line_sel_mode = 2
AND wa_roles_tc2-mark = 'X'.
LOOP AT it_roles_tc2 INTO g_tc2_wa2
WHERE mark = 'X'. -
> same here, it doesn't gets any data
g_tc2_wa2-mark = ''.
MODIFY it_roles_tc2
FROM g_tc2_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc2
FROM wa_roles_tc2
INDEX tc2-current_line
TRANSPORTING mark.
ENDMODULE.
thx for anybody who can help with this! -
I need to copy data from a table in one database (db1) to another table in
Hi
I need to copy data from a table in one database (db1) to another table in another database (db2).
I am not sure if the table exists in db2,,,if it doesnot it needs to be created as well data also needs to be inserted...
How am I supposed to this using sql statements..?
I shall be happy if it is explained SQL also...
Thanking in advanceHow many rows does the table contains? There are manyway you can achieve this.
1. export and import.
2. create a dblink between two databases and use create table as select, if structure doesnot exists in other database, if structure exists, use, insert into table select command.
example:
create a dblink in db2 database for db1 database.
create table table1 as select * from table1@db1 -- when there is no structure present
-- you need to add constraints manually, if any exists.
insert into table1 select * from table1@db1 -- when there is structure present.
If the table contains large volume of data, I would suggest you to use export and import.
Jaffar -
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com
Maybe you are looking for
-
Dual hard disk drives on one IDE
I am running 2000pro. I have recently installed an HP dvd200i on the same IDE channel as my MSI CDR/RW drive model # MS-8340. My MSI drive worked great up until the dvd200i was installed. While the dvd200i works fine, my system no longer sees the
-
The keyboard shortcuts for all of the options still work, but will not let me select anything with the mouse. The Apple key seems also not to allow selection of anything on the Menu Bar. I can browse normally when this happens; it's not freezing or c
-
How can i remove background of a picture and inser a new one online?
how can i remove background of a picture and inser a new one online?
-
Whole computer slows down drastically when network drive is mounted
Firstly, I hope I'm asking this in the right place. I'm using a MacBook with a Time Capsule and a 1.5TB USB drive attached to the Time Capsule as a wireless network drive. Whenever the network drive is connected, my whole computer runs intolerably sl
-
Lumia 1020 update to 8.1
I just want to know, when the updates to 8.1 will be released? Solved! Go to Solution.