How to prepare an INSERT statement from the resultset
Hi Friends ,
I have to generate CREATE and INSERT statements for the Table already present in the database .
I can prepare CREATE statement by getting the MetaData from the database . Is it possible to create INSERT statement for the data already present in the database table if so how.
Thanks ,
Rajesh Reddy
You should be able to do something like SELECT * FROM foo WHERE 1 = 2. No rows will be returned. Call ResultSet#getMetaData() to get the meta data for the column names and types. You should then be able to dynamically create your own INSERT statement.
- Saish
Similar Messages
-
How to change Bulk Insert statement from MS SQL to Oracle
Hi All,
Good day, I would like to bulk insert the content of a file into Oracle db. May I know how to change the below MS SQL syntax to Oracle syntax?
Statement statement = objConnection.createStatement();
statement.execute("BULK INSERT [TBL_MERCHANT] FROM '" MERCHANT_FILE_DIR "' WITH ( FIELDTERMINATOR = '~~', ROWTERMINATOR = '##' )");
Thanks in advance.
cs.Oracle SQL Loader utility allows you to insert data from flat file to database tables.
Go to SQL Loader links on following url to learn more on this utility
http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96652/toc.htm
Chandar -
How Can I Retrieve SQL Statement From The User ?
Hi
I want to know, how can I make the user can enter the SQL statement from himself ?? in this code he can't enter it. Only he can display the SQL that i wrote it...
this is my Code:
import java.sql.*;
public class db_testing {
static final String DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
public static void main(String[] args) {
Connection cn=null;
Statement st= null;
ResultSet rset=null;
try{
Class.forName(DRIVER);
cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
st=cn.createStatement();
rset=st.executeQuery("select * from employee");
ResultSetMetaData metadata=rset.getMetaData();
System.out.println("The begining: ");
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(metadata.getColumnName(i)+"\t");
System.out.println();
System.out.println();
while(rset.next()){
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(rset.getObject(i)+"\t\t");
System.out.println();}
catch(Exception e){
e.printStackTrace();
finally{
try{
cn.close();
st.close();
rset.close();
catch(Exception e1){
e1.printStackTrace();
}The following changes in the code will make the user to give the input
import java.sql.*;
public class db_testing {
static final String DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
public static void main(String[] args) {
Connection cn=null;
Statement st= null;
ResultSet rset=null;
try{
Class.forName(DRIVER);
cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
// st=cn.createStatement();
// rset=st.executeQuery("select * from employee");
PreparedStatement pstmt=null;
pstmt=cn.prepareStatement("select * from employee where id=?");
pstmt.setInt(1,Integer.parseInt(args[0]));
rset=pstmt.executeQuery();
ResultSetMetaData metadata=rset.getMetaData();
System.out.println("The begining: ");
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(metadata.getColumnName(i)+"\t");
System.out.println();
System.out.println();
while(rset.next()){
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(rset.getObject(i)+"\t\t");
System.out.println();}
catch(Exception e){
e.printStackTrace();
finally{
try{
cn.close();
st.close();
rset.close();
catch(Exception e1){
e1.printStackTrace();
} -
How do I move aiff files from the viewer to the timeline-it is not working when I click and drag or when I try to move the files to the overwrite or insert buttons-Thanks.
hi
You cannot move audio from the viewer
Mark your in and out points then in the browser grab hold of the audio tracks icon and drag that to the time line
PJ -
How to create a btrfs snapshot from the actual state?
Hi all,
i would like to create a backup via a snapshot from my root volume. How can i create a snapshot from the actual state of my partition and mount it again?
best regards :>Long time ago but it could be usefull for someone else.
Create snapshot of whole disk on btrfs:
$sudo btrfsctl -s /mnt/snapshot/`date +%F` /
Delete snapshot (don't try to delete it with "btrfsctl -D", it won't work yet):
$sudo btrfs subvolume delete /mnt/snapshot/2011-06-19/
Also usefull could be to create subvolumes for snapshoting. This create testvolume directory with subvolume in /mnt.
$sudo btrfsctl -S testvolume /mnt/
Last edited by fraantik (2011-06-19 14:52:54) -
How to get the values from the resultset???
I have a problem with this code given below,
i am executing an sql query which return a union of values from two tables.
the problem here is how do i read the values from the resultset.
here is the code....
package com.webserver;
import java.sql.*;
public class UnionDemo{
public static void main(String args[]){
Connection connection =null;
Statement statement =null;
ResultSet rs =null;
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
connection = DriverManager.getConnection("jdbc:oracle:thin:@:1521:ORCL","scott","tiger");
statement = con.createStatement();
rs = statement.executeQuery("(select tablename from node where appid=432) union (select tablename from uomnode where appid=432)");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next()){
System.out.println(rs.getString(1));
// instead of rs.getString(1) I also used rs.getString("tablename") but of no success....
}//end of while
}catch(Exception exp){
exp.printStackTrace();
finally{
try{
if (rs!=null) rs.close();
if (statement!=null) statement.close();
if (con!=null) con.close();
}catch(Exception exp1){
exp1.printStackTrace();
}//end of finally
}//end of main
}//end of class
when i execute this program i get an oracle error ORA-01009
which says (java.sql.SQLException: ORA-01009: missing mandatory parameter)
can anyone help to retrieve the values from this resultset...
thanx[cut]
i am executing an sql query which return a union of
values from two tables.
the problem here is how do i read the values from the
resultset.[cut]
When the error occours?
1) Executing query ?
2) Retrieving the field from the resultSet ?
3) ecc. ?
BTW, first of all, try to execute the query removing the parenthesis
of the two select statement. I know that there are some problem
with the oracle jdbc driver about them.
Hope it helps. -
Please Help!!!
How to write a case statement for the totals column of two different years (2013 and 2014) of the same month so that I can get a +/- column.
January 2014 January
2013 +/-
Region Entry Exit Total Entry Exit Total (Total of Jan2014-Total of Jan2013)
A 2 3
40 5 7 30 40-30= 10What is a table structure? Sorry cannot test it right now..
SELECT <columns>,(SELECT Total FROM tbl WHERE Y=2014)-(SELECT Total FROM tbl WHERE Y=2013)
FROM tbl
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How do you save "game state" so the user can continue next time?
I'm not sure what the correct game terminology is for this, but how do you save "game state" so the user can continue next time?
This seems like a pretty important feature for building some games, we don't want users to have to start over everytime.
Any ideas if this is possible?Check out my blog post on the PersistenceManager:
http://www.unitedmindset.com/jonbcampos/2010/11/01/flex-4-5-persistencemanager/
This will help you understand how to store the data. When the app starts up again get the state information from the persistencemanager and reset you game to the state you need. It requires a bit of code for the startup, but it is relatively simple. -
How to print out multilingual reports from the main report using Xliff temp
Hi all,
How to print out multilingual reports from the main report using Xliff temp?
When I want main report call subtemplate and finish xliff tranlation
<?for-each@section:INVOICE?><?end for-each?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
Prints out fine with Finnish translation
But if I want in main program to check what language is used e.g.
if trx_number = 142 call Finnish translation and if trx_number =144,
call English translation.
<?for-each@section:INVOICE?><?end for-each?>
<?if:TRX_NUMBER=’142’?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
<?end if?>
<?if: TRX_NUMBER=’144’?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
<?end if?>
Prints out always in English and never the Finnish translation.
Program goes fine to if branch but does not print out Finnish
Does anybody know what could be wrong?
BR
KariThanks Amit,
I have two layout, main-layout and sub-layout
Main layout call subtemplate
I have registered layout and xliff-file
Main template
Localized Templates
File Name Language Territory
XXNS_INVOICE_MAIN.rtf English
SUB template
Localized Templates
File Name Language Territory
XXNS_INVOICE_SUB.rtf English
Translatable Template
File Name Language Territory
XXNS_INVOICE_SUB.rtf English United States
Available Translations
Language Territory Progress
English Finland Complete
If main report call subtemplate and finish xliff tranlation
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
Prints out fine with Finnish translation
But if I want in main program to check what language is used e.g.
if....
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
.....end if;
if....
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
.....end if;
Prints out always in English and never the Finnish translation.
Program goes fine to if branch but does not print out Finnish
Do you it's set up problem or program problem
BR
Kari -
How to handle a return statement from a login webservice call
Hi all,
I am new to this iPhone apps. I am trying to wirte a webservice call in which I am comparing my username and password details in webservice and getting an boolean statement as a response. By using that response i should display valid or invalid statement on the screen.
Now i am able to get the response from the webservice, but i am unable to handle that boolean variable present in the xml statement.
Can any one please suggest me how to handle that boolean value from the xml statement?
Thanks
SRI.Since you are a registered developer you would be far better off posting this in the developers site, this forum is for users of apps.
-
How to display Top-5 earners from the table,there should be no duplication
Hi All
Can you give me some idea about this query,
i want a query like
1)How to dispaly top-N earners from the Emp Table ( i want to dispaly top 5 sal )
2)There should be no duplicaion in the sal.
3)If Two emp's earn the same sal,the sal should be picked up only once....!!
select distinct (sal) from emp order by sal desc;
select distinct (sal) from emp order by sal desc;
SAL
5000
3000
2975
2850
2450
1600
1500
1300
1250
1100
950
800
I want to display only first 5 rows !!
That first 5 rows i have to insert into other table..!! Please How to display only first 5 rows..!!
Please can you give me some idea..!!
Thank in AdvanceUSE THIS QUERY
SELECT SAL FROM (SELECT DISTINCT SAL FROM SCOTT.EMP ORDER BY SAL DESC) WHERE ROWNUM <= 5
IF U WANT TO FIND 3 SAL OR 4 0R ANY USE THIS QUERY
SELECT SAL FROM SCOTT.EMP A WHERE &N = (SELECT COUNT(DISTINCT B.SAL) FROM SCOTT.EMP B WHERE B.SAL <= A.SAL)
FOR &N = GIVE UR VALUE -
How can I delete tv shows from the iCloud on my Apple TV?
I recently purchased Apple TV (3rd gen) and need to delete a tv show that appears there. There's no trash can icon on the screen as some posts state--just an iCloud icon. How do I delete an item from the iCloud so it will no longer appear on the Apple TV?
You can't hide it AFAIK on AppleTV - do it via iTunes.
In iTunes elect the store home page, and choose Purchases in teh QuickLinks on the right.
Choose TV Shows and hover over the one to hide and there should be a small x to hide it.
If you need it back go into your actual account settings in iTunes and choose to unhide there.
AC -
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
How can I get all photos from the camera roll, and all new pictures taken, to get on the photostream so they can share between iphone and ipad?
When turning PhotoStream on with photos available in the Camera Roll, only photos captured by the iPhone or saved on the iPhone are placed in the PhotoStream.
For all photos that were in the Camera Roll prior to turning PhotoStream on, import the photos with your computer and add the photos to your PhotoStream on your computer. -
How do I delete a file from the Adobe Reader for iOS?
How do I delete a file from the Adobe Reader for iOS?
Read this:
http://forums.adobe.com/thread/1012973?tstart=0
Maybe you are looking for
-
Using XML_Query in JAVA
I'm using the OracleXMLQuery class to retrieve a CLOB from an Oracle table that was populated from an APEX Rich Text Field page. The XML file that is generated is fine except that the CLOB column has the angle brackets for the STRONG tag translated i
-
If anyone can clarify this for me it would be greatly appreciated. Can statistics collection be classified in 2 groups, Optimizer and Performance (AWR) Tuning? I ask this because I am reading Oracle 10g Admin Workshop I, chapter 12 "Proactive Monitor
-
Broken links after uploading web site to server
We created our office's web site using Dreamweaver CS4, and uploaded it to the server of our ISP. Prior to uploading, we tested the site in both IE7 and Firefox, and everything worked fine. After uploading, however, all images are lost and several
-
ITunes just stopped working. HELP.
I have the latest version and have had no problems until today. When I opened iTunes it looked like it was installing something, then give me unknown error 200 and says it can't open. HELP. The only things I can think that might have messed with iTun
-
Could not start NetSupport Manager Client For MacOS X because the license e
"Could not start NetSupport Manager Client For MacOS X because the license file has expired." I have a suspicion the above is a result of an old version of a program from a previous version of MACOS having been migrated, even from a PPC machine (PB17