Inserting data into one table using another table
Hi i have 2 tables
CREATE TABLE N_SET
N_ST_ID NUMBER(38) NOT NULL, ---- PK
N_ST_NM VARCHAR2(50 BYTE) NOT NULL,
N_ST_DSC VARCHAR2(200 BYTE),
DFTID NUMBER ------ FK
CREATE TABLE RZ
NST_ID NUMBER(38) NOT NULL, ---- FK
RID NUMBER(38) NOT NULL, --- PK
RNM VARCHAR2(30 BYTE) NOT NULL
I entered the data into the N_SET table using sequence in column N_ST_ID (using procedure)
Now i need to enter the data into RZ table where NST_ID should contain the value of N_SET.N_ST_ID
so for this i've written another procedure
but confused how to write the select statement to retrieve the above condition..
Could you help me in this please...
Hi,
I have a table Target whose structure is
create table employee
id VARCHAR2(20),
name VARCHAR2(20),
employee_seq NUMBER not null
-- Create sequence
create sequence test_seq
minvalue 1
maxvalue 999999999999999999999999999
start with 5
increment by 1
nocache
cycle;
create table emp
id VARCHAR2(20)
name VARCHAR2(20)
INSERT INTO emp
( id, name )
VaLUES ( '100','test1');
commit;
INSERT INTO emp
( id, name )
VaLUES ( '100','test2');
commit;
i have to insert into the TARGET table the fsa value from
SOURCE table along with the sequence number using sequence test_seq.nextval.
INSERT INTO employee
( id, name, employee_seq )
SELECT id, ename, ( select test_seq.nextval from dual )
FROM emp ;
Similar Messages
-
Insert data from one form to another table
I have a form which of course insert data into table1, i created a process within this form and include a sql statement to achieve this for me. My thoughts are this will take whatever is the value from the form and insert it into table2.
INSERT INTO ML_LIST (ML_TITLE,ML_LASTNAME)
VALUES
(P20_SSR_TITLE, P20_SSR_LASTNAME);
My error is column not allowed here
Any suggestionsI used the following
Begin
INSERT INTO ML_LIST (ML_TITLE,ML_LASTNAME)
VALUES
(:P20_SSR_TITLE,:P20_SSR_LASTNAME);
End; -
How to insert data from one server to another server?
Dear frnds
i have written the script in server ABC and the database XYZ, so i want to insert the data into the second server Customserver
hw should i insert the data .
Iam already tried for this creating the Linked server and exueting the script and inserting the data into that table but it will working on the current query editor only but
it should not been updated on the Target server database table.
below is the script pls help me out for this...
-- Creating the Linked server instance
sp_addlinkedserver 'sp_helpserver','','SQLNCLI',Null,Null,'Server=ABC001',Null
exec SP_addlinkedsrvlogin 'sp_helpserver','false',Null,'nshy22','#abx123'
--Insert data into the do.children
Truncate table dbo.children
Insert into dbo.Site_Table
select distinct Name, Code,State,
from dbo.children
--Insert data into the master
Truncate table Master
insert into Master
Select Code,Name,country from dbo.masterHello,
The SQL Server forums are over here:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book:
Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}}) -
INSERTING DATA INTO A SQL SERVER 2005 TABLE, WHICH HAS A IDENTITY COLUMN
Hi All,
I have to insert the data into a SQL SERVER 2005 Database table.
I am able to insert the data into a normal SQL Server table.
When I am trying to insert the data into a SQL Server table, which has a identity column (i.e. auto increment column in Oracle) I am getting error saying that can't insert value explicitly when IDENTITY_INSERT is set to OFF.
Had anybody tried this??
There are some SRs on this issue, Oracle agreed that it is a bug. I am wondering if there is any workaround from any one of you (refer Insert in MS-SQL database table with IDENTITY COLUMN
Thanks
V KumarEven I had raised a SR on this in October 2008. But didn't get any solution for a long time, finally I had removed the identity column from the table. I can't to that now :).
I am using 10.1.3.3.0 and MS SQL SERVER 2005, They said it is working for MS SQL SERVER TABLE, if the identity column is not a primary key and asked me to refer to note 744735.1.
I had followed that note, but still it is not working for me.
But my requirement is it should work for a MS SQL SERVER 2005 table, which has identity column as primary key.
Thanks
V Kumar -
Insert data into oracle database using a PHP form
I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
NOTE: I don't have any problem connecting to the database using php.
Here is the code I'm using:
<?php
// just print form asking for name if none was entered
if( !isset($query)) {
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Name: ";
echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
// insert client's name
$query = "INSERT INTO client (name) VALUES ($data)";
// connect to Oracle
$username = "xxxx";
$paswd = "yyyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);
OCIFreeStatement($stmt);
OCILogoff($db_conn);
?>
Thanks for your help. I will also appreciate a better was to do it.
Tonyresumption and jer,
Sorry I cannot format the code for easy reading!
The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
<?php
// connect to oracle
$username = "xxxxx";
$paswd = "yyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
// username and password will be unset if they weren't passed,
// or if they were wrong
if( !isset($query)) {
// just print form asking for account details
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Query: ";
echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
// remove unwanted slashes from the query
$query = stripslashes($query);
// run the query
$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);
// Open the HTML table.
print '<table border="1" cellspacing="0" cellpadding="3">';
// Read fetched headers.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
print '</tr>';
// Read fetched data.
while (ocifetch($stmt))
// Print open and close HTML row tags and columns data.
print '<tr>';
for ($i = 1;$i <= ocinumcols($stmt);$i++)
print '<td class="v">'.ociresult($stmt,$i).'</td>';
print '</tr>';
// Close the HTML table.
print '</table>';
OCIFreeStatement($stmt);
OCILogoff($db_conn);
?> -
How to insert data into BLOB column using sql
Hi all,
How to insert data into BLOB column directly using sql .
create table temp
a blob,
b clob);
SQL> /
Insert into temp values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
ERROR at line 1:
ORA-01465: invalid hex number
Please help in this.Thanks,
P Prakashsee this
How to store PDF file in BLOB column without using indirect datastore -
Best way to insert data into a non indexed partitioned table?
Hi,
I've a rather basic question that I haven't been able to find an answer to so hope that someone may be able to help.
We need to insert sales data into a partitioned table that is range partitioned on sales date. The incoming sales data can span a number of days, e.g. 31-JUL-2007 through to 04-AUG-2007 inclusive. I've come up with two approaches and would like to know which you would recommend and why?
Approach 1: Load data into each individual partition using a statement like:
INSERT /*+ APPEND */ INTO sales PARTITION (sales_20070731) SELECT * FROM sales_new WHERE sales_date = TO_DATE('31-AUG-2007','DD-MON-YYYY')
Approach 2: Load data into the entire table using a statement like:
INSERT /*+ APPEND */ INTO sales SELECT * FROM sales_new
ThanksYou need to compare both approaches by creating simple test case.
But there is no advantages in approach 1until you will have index on sales_date column.
With index these approaches are comparable and you can choose whatever best fits to your requirements.
Best Regards,
Alex -
How to insert a value in a table using another table
My table is like this
col1 col2 col3
india
Pakistan
my doubt is if i insert India in a table it will automatically insert India Id or code into another table
output i want is like this
col1 col2
10
20
please give the exact query.u will have to use triggers to achieve the functionality..
-
Inserting data into relational views of object tables
I hope someone could help me to solve the following problem:
I would like to design an object-relational database in O8i. Unfortunatly the client-software (GIS) can only understand relational data (except the object type 'geometry'). So I created relational views on my object tables. But now it is not possible to insert data in those views. Do I have to create triggers on those views for inserting data ???
Nevertheless: Updating data in views makes no problems.
Thank you for reading this and I look foreward to hearing from you soon.
Christian HeilHi Mohammed,
I guess following is your requirement
List1 tile is attached to "BOList1". On button press you wanted the data to be persisted to Business object "BOList1History"
I assume that you have created "BOLIst1History" properly by associating a write Bdoc etc etc.
Write a method in Business object "BOList" called ZUpdateHistory. This new method should contain code for creating an instance of "BOLIST1History" and fill the property values as per your requirement. Call this method from the Button press event as follows
anchor.bo.ZUpdateHistory
Hope this helps
Regards
Ganesh Datta -
How to insert data into mysql database using GUI?
HI there,
I have created a GUI application using Netbeans 6.7.1 in which there are three jtextfields. Now from those text fields i have to insert data in the mysql database. I have already connected to mysql using drivers and URL which is used to connect to DB. So what code should i write in the source of these text fields. Please help me and give the code to it.
I actually don't know what code to be written in the source of a text field.
Thank You.Yo buddy i didn't mean that. I wanted to say that if you see my project then it will be easy for you to help me. okay have a look at this code and tell me i have just created my gui
This is Main.java -->
package bookdatabase2;
import java.sql.*;
import java.awt.*;
import javax.swing.*;
* @author Mohd Azeem
public class Main {
* @param args the command line arguments
public static void main(String[] args)throws Exception {
// TODO code application logic here
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/books","root","");
//PreparedStatement state=con.prepareStatement("select * from titles");
//ResultSet result=state.executeQuery();
//while(result.next()){
// System.out.println(result.getString(1)+" "+result.getString(2)+" "+result.getString(3)+" "+result.getString(4));
This the gui i have created
BookDatabase.java -->
package my.bookdatabase;
import java.sql.*;
import javax.swing.*;
public class BookDatabase extends javax.swing.JFrame {
public BookDatabase()throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/books","root","");
initComponents(); }
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
public static void main(String args[])throws Exception {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try{
new BookDatabase().setVisible(true);}
catch(Exception e){}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
// End of variables declaration
Now tell me what to do?
i have only created the gui but unable to run it
when i click on run only main.java is being executed
but bookdatabase.java is not getting executed?
what should i do please help? -
How to convert row data into columns without using pivot table?
Hello guys
I have a report that has several columns about sales call type and call counts
It looks like this:
Calls Type Call Counts
Missed 200
Handled 3000000
Rejected 40000
Dropped 50000
Now I wanna create a report that look like this:
Missed call counts Handled Call counts Rejected Counts Drop counts Other Columns
200 300000000 40000 50000 Data
So that I can perform other calculations on the difference and comparison of handled calls counts vs other call counts..
I know pivot table view can make the report look like in such way, but they cant do further calculations on that..
So I need to create new solid columns that capture call counts based on call types..
How would I be able to do that on Answers? I don't have access to the RPD, so is it possible to do it sololy on answers? Or should I just ask ETL support on this?
Any pointers will be deeply appreciated!
Thank youThanks MMA
I followed your guidance and I was able to create a few new columns of call missed count, call handled counts and call abandoned counts.. Then I create new columns of ave missed counts, ave handled counts and so forth..
Then I went to the pivot view, I realized there is a small problem.. Basically the report still includes the column "call types" which has 3 different types of call "miss, abandon and handled". When I exclude this column in my report, the rest of the measures will return wrong values. When I include this column in the report, it shows duplicate values by 3 rows. It looks like this:
Queue name Call types Call handled Call missed Call abondoned
A Miss 8 10 15
A Handled 8 10 15
A Abandoned 8 10 15
in pivot table view, if I move call type to column area, the resulted measures will become 8X3, 10X3 and 15X3
So is there a way to eliminate duplicate rows or let the system know not to mulitply by 3?
Or is this as far as presentation service can go in terms of this? Or should I advice to provide better data from the back end?
Please let me know, thanks -
Re: Insert data into oracle database using a PHP form
Hai its different for me, i want to display a data based on the input from php form. I see and trying your script but it didn't work.
<?php
// just print form asking for name if none was entered
if( !isset($query)) {
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Name: ";
echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
$data=$_POST;
stripslashes($data);
// Select statement
$query = "SELECT * FROM animal WHERE skin=$data";
// connect to Oracle
$username = "xxxxxx";
$paswd = "xxxxxx";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=yyyyyyyy)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);
//$stmt = OCIParse($db_conn, $query);
//OCIExecute($stmt, OCI_DEFAULT);
//OCIFreeStatement($stmt);
//OCILogoff($db_conn);
$stmt = OCIParse ($db_conn, $sql);
OCIBindByName ($stmt, ":name", &$data, -1);
OCIExecute ($stmt);
OCIFreeStatement($stmt);
OCILogoff ($db_conn);
?>
Could you please advice me ? whats wrong with that script ?What is the error you get? What solutions have you tried already?
-
Need to update multiple columns using another table
I have 2 tables. and i need to update rows of 1 table using another table
Table1
Serial_no. payment_date Payment_amt
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
Table2
Serial_no Charge_amt Last_paymt_dt Last_paymt_amt
101 255
102 648
103 475
I want to update Last_paymt_dt and Last_paymt_amt of table2 using Table1, I have written following update statement but it gives error that single row subquery return multiple row.
Update Table2
set (Last_paymt_dt,Last_paymt_amt) = (select max(payment_date, payment_amt) from table1
where table1.Serial_no = table2.Serial_no group by payment_amt)
kindly suggest how should i update.SQL> select * from table1
2 /
SERIAL_NO PAYMENT_DA PAYMENT_AMT
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
6 rows selected.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255
102 648
103 475
SQL> update table2
2 set (last_paymt_dt,last_paymt_amt) = (
3 select max(payment_date),
4 max(payment_amt) keep(dense_rank last order by payment_date)
5 from table1
6 where table1.serial_no = table2.serial_no
7 )
8 /
3 rows updated.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255 28/06/2011 505
102 648 14/06/2011 269
103 475 20/05/2011 178
SQL> SY. -
In JSF framework application how to Insert data into DB using entitymanager
Dear friends,
I am developing a web application using JSF framework. In that i using entity class. In ManagedBean class i want to insert the data using entitymanager persist method. But it will not working. And don't show any errors. give me the suitable methode to insert data into the database using EntityManager.Persist() method.Yes, Panky_p,
i have attached the code for which i using in given below. In that am getting the data from database but only the problem is not inserting into the database.Give me the possible solution for that.Thank you
public String ValidUser(String username, String password) {
List<User> us = new ArrayList();
EntityManager em = getEntityManager();
try {
us = em.createNamedQuery("User.findAll").getResultList();
if (us != null) {
Iterator i = us.iterator();
while (i.hasNext()) {
User use = (User) i.next();
if (username.equals(use.getHmsusrloginName()) && password.equals(use.getHmsusrpassWord())) {
utx.begin();
Logindetail lo = new Logindetail();
lo.setHmslogusrId(use.getHmsusrusrId());
lo.setHmslogloginName(use.getHmsusrloginName());
lo.setHmslogtimeIn(getCurrentDate());
em.persist(lo);
utx.commit();
return "success";
return "failure";
} else {
return "failure";
} catch (Exception ex) {
System.out.println("Exception in GetConnection " + ex);
return "failure";
} -
Inserting Data into a Collection
Hi
Can anybody suggest how to Insert data into a Collection from another Collection Using Bulk Binds in PLSQL?
My scenario :-
CREATE OR REPLACE PACKAGE te_ar IS
TYPE srm_rec IS RECORD (col1 <table>.<col1>%TYPE, col2 <table>.<col2>%TYPE);
TYPE srm_rec_list IS TABLE OF srm_rec INDEX BY BINARY_INTEGER;
FUNCTION z_srm_rec RETURN srm_rec_list PIPELINED;
END te_ar;
CREATE OR REPLACE PACKAGE BODY te_ar IS
FUNCTION z_srm_rec RETURN srm_rec_list PIPELINED IS
v_srm_rec srm_rec;
TYPE col1_t IS TABLE OF <table>.<col1>%TYPE INDEX BY BINARY_INTEGER;
TYPE col2_t IS TABLE OF <table>.<col2>%TYPE INDEX BY BINARY_INTEGER;
col1_tt col1_t;
col2_tt col2_t;
CURSOR c1
IS
SELECT col1, col2 FROM table;
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT INTO col1_tt,col2_tt;
FORALL i IN 1 .. c1%ROWCOUNT
v_srm_rec.col1(i) := col1_tt(i);
v_srm_rec.col2(i) := col2_tt(i);
PIPE_ROW(v_srm_rec);
CLOSE c1;
RETURN;
END;
END te_ar;
I have created a Record Type in which I am trying to insert rows using bulk bind and return it using a pipelined function.
This approach is throwing me errors in which I am unable to use both Pipelining and Bulk Binds together so that I can make the Performance of the entire bit better.
Please suggest the way forward.
Any other relevant info I am ready to supply.
Thanks
ArnabFORALL is used for bulk DML statements and will not work for your collections. http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/forall_statement.htm#LNPLS01321. I think you may want to use a regular FOR loop.
Maybe you are looking for
-
Scanner from hp Photosmart c3100 doesn't work but I need it to!
I have MAC OS X Version 10.5.8. I have a HP Photosmart C3100 3 in one. Though, I can print fairly fine, it will not scan anything. I actually can't recall it ever scanning since I got this MAC but I just rolled with it... However, I now need this o
-
for private equity work, electronic data room, presentations, confidential information memorandums etc. is the mac book air sufficient?
-
Problem using java crypto class... Please help me
Hi, i'm trying to do application that send information via socket, and i have to send the data encrypted, i`m trying to implemented the RC4 algorithm.... I read an article that said that the java sdk 1.4 has already implemented the securities classes
-
Edit photo to fit dimension of 50 kbs
i am often told a file I want to use as my personal id in a web based account is too large, that it needs to be less than 50kbs. i take most of my pictures with my ipad and imported it to my I mac, the one i am presently trying to edit came in as 48
-
How to parse Double to Integer Type?
Dear all, I have a question in Java programming. How to change the variable of Double type into Integer Type? Is there any class that I should import in the Program? thanks.