Multiple rows insertion - need help
Hello all,
I need to insert multiple rows in a table with a single query and the number of rows is 269470.
There are 3 columns in the table. One of the columns is determined by another sub query which returns multilple(269470) rows and the other 2 columns remain same for all.
I came up with the following query but need a loop to make it run multiple time(269470 times).
insert into EMLUSRRECV
(user_id, storeent_id, receiveml)
values
((select user_id from users where user_id not in (select distinct user_id from EMLUSRRECV) and CURR = 'USD' and rownum = 1), 11154, 1);
Thanks in advance.
Edited by: 924585 on Feb 20, 2013 7:19 PM
924585 wrote:
Hello all,
I need to insert multiple rows in a table with a single query and the number of rows is 269470.
There are 3 columns in the table. One of the columns is determined by another sub query which returns multilple(269470) rows and the other 2 columns remain same for all.
I came up with the following query but need a loop to make it run multiple time(269470 times).
insert into EMLUSRRECV
(user_id, storeent_id, receiveml)
values
((select user_id from users where user_id not in (select distinct user_id from EMLUSRRECV) and CURR = 'USD' and rownum = 1), 11154, 1);
Thanks in advance.
Edited by: 924585 on Feb 20, 2013 7:19 PMwhy not just:
insert into emlusrrecv
select user_id, 11154, 1
from users
where user_id not in (select user_id from EMLUSRRECV)
and CURR = 'USD' and rownum = 1)
Similar Messages
-
How can I use multiple row insert or update into DB in JSP?
Hi all,
pls help for my question.
"How can I use multiple rows insert or update into DB in JSP?"
I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
With thanks,That isn't true. Different SQL databases have
different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
and there are also a lot of different ways of talking to
SQL databases that are possible in JSP, from using
plain old java.sql.* in scriptlets to using the
jstlsql taglib. I've done maintenance on both, and
they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
Well, sure. As long as you only want to update rows
with the same value in column 2. I had the impression
he wanted to update a whole table. If he only meant
update all rows with the same value in a given column
with the same value, that's trivial. All updates do
that. But as far as I know there's know way to update
more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
Unless you're using MySQL, for instance. I only have
experience with MySQL and M$ SQL Server, so I don't
know what PostgreSQL, Oracle, Sybase, DB2 and all the
rest are capable of, but I know for sure that MySQL
can insert multiple rows while SQL Server can't (or at
least I've never seen the syntax for doing it if it
does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
Don't assume that all SQL databases are the same.
They're not, and it can really screw you up badly if
you assume you can deploy a project you've developed
with one database in an environment where you have to
use a different one. Even different versions of the
same database can have huge differences. I recommend
you get a copy of the O'Reilly book, SQL in a
Nutshell. It covers the most common DBMSes and does a
good job of pointing out the differences.Yes, I understand that.
It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing. -
Multiple row insert not working as before after applying hotfix apsb13-13
Coldfusion 9.01
Windows Server 2003
Microsoft Access database (yeah, we know)
Before the hotfix was applied, we could add multiple rows (anywhere from 1-100 or more) and now we're limited to 15 rows at a time after applying the hotfix. We've narrowed it down to the hotfix being the culprit as we had to rebuild the server not to long after this hotfix was applied (~ 1 month) and the multiple row inserts were once again working fine until we got to the point of applying this hot fix again.
Anyone heard of this happening? Any ideas how to correct?
Thanks in advance,
fmHelp
Below is code of how we're doing the multiple row insert (it's performed over 3 pages):
Page 1
<cfform name="form1" method="post" action="handler.cfm?page=update_2">
<input type="hidden" name="sProductID" value="<cfoutput>#qProducts.sProductID#</cfoutput>">
<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<th scope="row" colspan="2" align="center">Update an Inventory Product</th>
</tr>
<tr>
<th width="42%" scope="row">Product ID</th>
<td width="58%"><cfoutput>#qProducts.sProductID#</cfoutput></td>
</tr>
<tr>
<th width="42%" scope="row">Friendly Name</th>
<td width="58%"><cfoutput>#qProducts.sFriendly_Name#</cfoutput></td>
</tr>
<tr>
<th width="42%" scope="row">Description</th>
<td width="58%"><cfoutput>#qProducts.sDescription#</cfoutput></td>
</tr>
<tr>
<th width="42%" scope="row">Vendor</th>
<td><select name="sVendor">
<cfoutput><option value="#qProducts.sVendor#">#qProducts.sVendor#</option></cfoutput>
<option value=""></option>
<cfoutput query="qVendor">
<option value="#sVendor#">#sVendor#</option>
</cfoutput>
</select></td>
</tr>
<tr>
<th scope="row">Order No.</th>
<td><cfinput name="sOrder_No" type="text" value="" required="yes" message="Order number is a required field."></td>
</tr>
<tr>
<th scope="row">Lot No.</th>
<td><input name="sLot" type="text" value=""/></td>
</tr>
<tr>
<th scope="row">Date Expires</th>
<td><input name="dtExpire" type="text" value=""/></td>
</tr>
<tr>
<th scope="row">Boxes received</th>
<td><input name="iBoxes" type="text" value="" /></td>
</tr>
<tr>
<th scope="row">Doses/Units</th>
<td><input name="pcount" type="text" value="" /></td>
</tr>
<tr>
<th scope="row">Note</th>
<td><cfoutput>#qProducts.sNote#</cfoutput></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th scope="row" colspan="2" align="center"><input type="submit" value="Submit" /></th>
</tr>
</table>
</cfform>
</table>
Page 2
<form name="form1" method="post" action="handler.cfm?page=update_3">
<cfoutput><input type="hidden" name="pcount" value="#FORM.pcount#"></cfoutput>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="6" align="left">Record count (Doses/Units)= <cfoutput>#FORM.pcount#</cfoutput></td>
</tr>
<tr>
<td>Product ID</td>
<td>Vendor</td>
<td>Order No.</td>
<td>Lot No.</td>
<td>Expiration Date</td>
<td>Num. of Boxes</td>
</tr>
<cfset Peoplecount = 0>
<cfloop index="Add" from="1" to="#form.pcount#" step="1">
<tr>
<cfset Peoplecount = PeopleCount + 1>
<td><input <cfoutput> value="#FORM.sProductID#" </cfoutput> name="sProductID_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sProductID_"></td>
<td><input <cfoutput>value="#FORM.sVendor#"</cfoutput> name="sVendor_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sVendor_"></td>
<td><input <cfoutput> value="#FORM.sOrder_No#" </cfoutput> name="sOrder_No_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sOrder_No_"></td>
<td><input <cfoutput>value="#FORM.sLot#"</cfoutput> name="sLot_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sLot_"></td>
<td><input <cfoutput> value="#DateFormat(FORM.dtExpire, 'MM/DD/YY')#" </cfoutput> name="dtExpire_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="dtExpire_"></td>
<td><input <cfoutput>value="#FORM.iBoxes#"</cfoutput> name="iBoxes_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="iBoxes_"></td>
</tr>
</cfloop>
<tr>
<td> </td>
<td>
<input type="submit" name="Submit" value="Submit">
<input name="HowMany" type="hidden" id="HowMany" value="<cfoutput>#Form.pcount#</cfoutput>">
</td>
</tr>
</table>
</form>
</table>
Page 3
<cfquery name="qGetOnHand" datasource="#variables.DSNCI#">
SELECT *
FROM Products
WHERE sProductID = '#session.sProductID#'
</cfquery>
<cfquery datasource="#variables.DSNCI#">
UPDATE Products
SET iOnHandQty = (#FORM.pcount# + #qGetOnHand.iOnHandQty#)
WHERE sProductID = '#session.sProductID#'
</cfquery>
<cfset quantity = #FORM.pcount#>
<cfset Pcount = 0>
<!-- Start Loop -->
<cfloop index="Add" from="1" to="#form.howmany#" step="1">
<cfset Pcount = Pcount + 1>
<cfset Product = "Form.sProductID_#Pcount#">
<cfset Product = Evaluate(Product)>
<cfset Vendor = "Form.sVendor_#Pcount#">
<cfset Vendor = Evaluate(Vendor)>
<cfset Order = "Form.sOrder_No_#Pcount#">
<cfset Order = Evaluate(Order)>
<cfset Lot = "Form.sLot_#Pcount#">
<cfset Lot = Evaluate(Lot)>
<cfset Expires = "Form.dtExpire_#Pcount#">
<cfset Expires = Evaluate(Expires)>
<cfset Boxes = "Form.iBoxes_#Pcount#">
<cfset Boxes = Evaluate(Boxes)>
<cfquery datasource="#variables.DSNCI#" name="InsertData">
Insert into Received_History (sProductID, sVendor, sOrder_No, sLot, dtExpire, iBoxes, dtReceived)
values ('#Product#', '#Vendor#', '#Order#', '#Lot#', <cfif Expires IS "">NULL<cfelse>#CreateOdbcDate(Expires)#</cfif>, #Boxes#, #CreateOdbcDate(Now())#)
</cfquery>
</cfloop>Rasi wrote:show your complete default.pa (also make sure that you dont override pulse settings in ~/.config/pulse) this setting should allow sound for ANY user - i just tried it and it works
also: of course you restarted pulseaudio?
I restarted pulseaudio and my computer.
My default.pa is displayed in the first post.
My files in /etc/pulse:
> ls -la /etc/pulse
total 28
drwxr-xr-x 1 root root 116 May 16 10:22 .
drwxr-xr-x 1 root root 3740 May 16 10:47 ..
-rw-r--r-- 1 root root 1269 Mar 3 21:31 client.conf
-rw-r--r-- 1 root root 2348 Oct 8 2013 daemon.conf
-rw-r--r-- 1 root root 5756 May 16 10:24 default.pa
-rw-r--r-- 1 root root 5718 Oct 8 2013 default.pa.pacnew
-rw-r--r-- 1 root root 2112 Oct 8 2013 system.pa
-la
My files in ~/.config/pulse:
> ls -la ~/.config/pulse
total 1048
drwx------ 1 homeuser homeuser 660 Sep 12 2013 .
drwx------ 1 homeuser homeuser 1054 Apr 24 14:06 ..
-rw-r--r-- 1 homeuser homeuser 40960 Oct 17 2013 1a8726d55f9140ae9d95dc512eacea67-card-database.tdb
-rw-r--r-- 1 homeuser homeuser 43 May 16 10:37 1a8726d55f9140ae9d95dc512eacea67-default-sink
-rw-r--r-- 1 homeuser homeuser 42 May 16 10:37 1a8726d55f9140ae9d95dc512eacea67-default-source
-rw-r--r-- 1 homeuser homeuser 12288 May 16 10:49 1a8726d55f9140ae9d95dc512eacea67-device-volumes.tdb
lrwxrwxrwx 1 homeuser homeuser 23 Sep 12 2013 1a8726d55f9140ae9d95dc512eacea67-runtime -> /tmp/pulse-cDmMRoO9oFBz
-rw-r--r-- 1 homeuser homeuser 12288 May 15 22:43 1a8726d55f9140ae9d95dc512eacea67-stream-volumes.tdb
-rw------- 1 homeuser homeuser 256 Jun 15 2013 cookie
-rw-r--r-- 1 homeuser homeuser 331776 Jun 21 2013 equalizer-presets.tdb
-rw-r--r-- 1 homeuser homeuser 659456 Sep 20 2013 equalizer-state.tdb
Thanks for your efforts. -
Hi,
I know this question has been asked and there was an answer:
http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-tim e-in-an-sqlite-database
But now things has changed, from version 3.7.11 SQLite does work normally with multiple insert:
http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-tim e-in-an-sqlite-database
http://www.sqlite.org/lang_insert.html
Now the problem is that I use SQLite Expert to perform a multiple row insert with normal sql method:
INSERT INTO table (col1, col2) VALUES
('row1col1', 'row1col2'), ('row2col1', 'row2col2'), ...
And this works. However when I try to use this insert within Flash Builder it gives me an error - syntax error near ",".
Is there a way I can check or update SQLite within Flex so I could use multiple row insert?
Thanks in advance for answers:)Unlike in php (values(product1),(product2),(product3))
you cannot insert records like that in a sqlite db.
What i did is the following
public function insertMonthRecords():void
var sqlText:String = "INSERT INTO month( monthname)
" +
"VALUES('Januari')";
insertStatement = new SQLStatement();
insertStatement.sqlConnection = conn;
insertStatement.addEventListener(SQLEvent.RESULT,
insertResult);
insertStatement.addEventListener(SQLErrorEvent.ERROR,
errorHandler);
insertStatement.text = sqlText;
insertStatement.execute();
insertStatement.text = "INSERT INTO month(monthname)
VALUES('Februari')";
insertStatement.execute();
insertStatement.text = "INSERT INTO month(monthname)
VALUES('March')";
insertStatement.execute();
insertStatement.text = "INSERT INTO month(monthname)
VALUES('April')";
insertStatement.execute();
And so on.. To bad i didn't found a solution to execute all
the inserts at once. Inserting this way takes time :-(
If you have a better solution, just let me know.
Greetz, Jacob -
Multiple rows insert and update form example
I just want to share with you an example of a multiple rows insert and update form. You can access it HERE (http://tryapexnow.com/apex/f?p=12090:21)
You will find on the same page the complete description of all elements used to buid it.
I'm waiting for opinions, suggestions, and questions here in this thread.
ThanksHello Valentin,
I got an error message when I clicked on the weblink. Here is the message
Error ERR-7620 Could not determine workspace for application. Could you please take a look at this.
Thanks,
Karol -
Print insert result to a printer in TSQL trigger after insert - Need help.
Hi,
I am trying to print a record to a printer whenever a new record is inserted into a table called PrintTickets, using TSQL trigger for insert.
Is it possible to print a new inserted record to a printer?
Here is the trigger tsql statement:
ALTER TRIGGER [dbo].[PrintDeal]
ON [dbo].[PrintTickets]
AFTER INSERT
AS
declare @Id numeric(18,0)
,@DealId char(15)
,@ValueDatePeriod1Currency1 datetime
,@Bank1Name char(56)
,@Currency1 char(3)
,@Currency2 char(3)
,@PaymentInstructionP1C1 char(80)
,@DealerId char(6)
,@DealVolumeCurrency1 float
,@CalVolumeP1C2 float
,@ExchangeRatePeriod1 float
declare @tmp table
Id numeric(18,0)
,DealId char(15)
,ValueDatePeriod1Currency1 datetime
,Bank1Name char(56)
,Currency1 char(3)
,Currency2 char(3)
,PaymentInstructionP1C1 char(80)
,DealerId char(6)
,DealVolumeCurrency1 float
,CalVolumeP1C2 float
,ExchangeRatePeriod1 float
PRIMARY KEY (Id)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
insert @tmp
select
Id
, DealId
, ValueDatePeriod1Currency1
, Bank1Name
, Currency1
, Currency2
, PaymentInstructionP1C1
, DealerId
, DealVolumeCurrency1
, CalVolumeP1C2
, ExchangeRatePeriod1
FROM dbo.PrintTickets
WHERE ID=@@IDENTITY
select @Id=Id
,@DealId=DealId
,@ValueDatePeriod1Currency1=ValueDatePeriod1Currency1
,@Bank1Name=Bank1Name
,@Currency1=Currency1
,@Currency2=Currency2
,@PaymentInstructionP1C1=PaymentInstructionP1C1
,@DealerId=DealerId
,@DealVolumeCurrency1=DealVolumeCurrency1
,@CalVolumeP1C2=CalVolumeP1C2
,@ExchangeRatePeriod1=ExchangeRatePeriod1
from @tmp
-- Code to print to a physical printer if possible
END
The table is called PrintTickets and it contains the following columns:
Id numeric(18,0)
,DealId char(15)
,ValueDatePeriod1Currency1 datetime
,Bank1Name char(56)
,Currency1 char(3)
,Currency2 char(3)
,PaymentInstructionP1C1 char(80)
,DealerId char(6)
,DealVolumeCurrency1 float
,CalVolumeP1C2 float
,ExchangeRatePeriod1 float
PRIMARY KEY (Id)
The dummy records that I am inserting for testing the results in csv format:
Id,DealId,ValueDatePeriod1Currency1,Bank1Name,Currency1,Currency2,PaymentInstructionP1C1,DealerId,DealVolumeCurrency1,CalVolumeP1C2,ExchangeRatePeriod1
696,XXX#33111 ,2014-03-04 00:00:00.000,HSBC ,USD,EUR,XXXXXXXXXXXXXXXXXXXXXXX ,MAT ,342342,87987,0.3123
697,XXX#33113 ,2014-03-04 00:00:00.000,USB ,EUR,USD,9999999999999999999999,ZXY,2334243,32213,0.3245
698,XXX#33114 ,2014-03-03 00:00:00.000,SWISS BANK ,CHF,USD,99999999999999900000,XYZ ,32423424,342,0.83432
699,XXX#33115 ,2014-03-03 00:00:00.000,UK BANK ,USD,PND,XXXXXXXXXXXXXXXXXXXXXXX ,ABC,9809808,0,0.0349
700,XXX#33116 ,2014-03-04 00:00:00.000,USCF BANK ,XXX,XXX,XXXXXXXXXXXXXXXXXXXXXXX ,ABC,89798797,756756,0.734
I appreciate any help.
Thanks in advance.Is it possible to print a new inserted record to a printer?
From SQL Server?
The task of SQL Server is to manage large of data effciently. It is not a general programming environment. It could possibly be done with a CLR procedure that that talks to the printer, but it is not the correct solution.
A possible design could be to post a message on a Service Broker queue, and then the printing server would poll the queue and print the ticket.
By the way, there are more flaws in your trigger. To find the inserted rows, you need to query the virtual table "inserted" which holds a copy of these rows. Furthermore, since a trigger fires once per statement, the trigger must handle the fact
that multiple rows are inserted.
Erland Sommarskog, SQL Server MVP, [email protected] -
Please i need help on how to enter multiple row into mysql with batch insert
statement and jsp.I do not have much java expereience
<---- THIS AN EXAMPLE OF MY INSERT FORM ---->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="some sort of jsp page">
mike : <input type="text" name="staffid" />
john : <input type="text" name="staffid" />
peter :<input type="text" name="staffid" />
james :<input type="text" name="staffid" />
jerry :<input type="text" name="staffid" />
mikel: <input type="text" name="staffid" />
<input name="submit" type="button" />
</form>
</body>
</html>
<--MY DATABASE LOOKS LIKE --->
name | staffid |
I have been looking for a way to enter only the value or all the values that is entered by
the user.Save the file under savevalues.jsp and the form submit posts the data to the same page which then executes the java code for obtaining connection, batch statement. You have to set the jdbc driver for mysql in the classpath and change the table name and column name
<%@ page import="java.sql.* %>
<%
if (request.getParameterValues("staffid") != null) {
try {
Connection conn = null;
Statement stmt = null;
String driver = "org.gjt.mm.mysql.Driver";
String url = "jdbc:mysql://localhost/octopus";
String username = "root";
String password = "root";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, password);
conn = getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
conn.setAutoCommit(false);
String []values = request.getParameterValues("staffid");
for (int i=0; i< values.length; i++ ) {
stmt.addBatch("INSERT INTO tablename(name) VALUES(values)");
int[] updateCounts = stmt.executeBatch();
conn.commit();
} catch (SQLException sqle) {
System.out.println("Exception here :" + sqle.getMessage());
} catch(Exception e) {
System.out.println("Exception here :" + e.getMessage());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="savevalues.jsp">
mike : <input type="text" name="staffid" />
john : <input type="text" name="staffid" />
peter :<input type="text" name="staffid" />
james :<input type="text" name="staffid" />
jerry :<input type="text" name="staffid" />
mikel: <input type="text" name="staffid" />
<input name="submit" type="button" />
</form>
</body>
</html>
{code} -
Please i need help on how to enter multiple row into mysql with one insert
statement and jsp , i have been trying this for weeks without sucess e.g
<---- THIS AN EXAMPLE OF MY INSERT FORM ---->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="some sort of jsp page">
mike : <input type="text" name="staffid" />
john : <input type="text" name="staffid" />
peter :<input type="text" name="staffid" />
james :<input type="text" name="staffid" />
jerry :<input type="text" name="staffid" />
mikel: <input type="text" name="staffid" />
<input name="submit" type="button" />
</form>
</body>
</html>
<--MY DATABASE LOOKS LIKE --->
name | staffid |
| |
| |
| |
I have been looking for a way to enter only the value or all the values that is entered by
the user.ODAFEONIHOWO wrote:
Please i need help on how to enter multiple row into mysql with one insert
statement and jsp it's not possible - you'll need to do a batch insert
i have been trying this for weeks without sucess e.g how much experience do you have with Java? -
Handling error with multiple row insert/update
Hi,
I need to insert multiple rows into a table, and I understand that i need to use executeArrayUpdate().
My problem is this :
1. How do I know in case some of the rows in the array failed during the INSERT?
2. When I do know that, how do I find those particular rows?
ThanksODAFEONIHOWO wrote:
Please i need help on how to enter multiple row into mysql with one insert
statement and jsp it's not possible - you'll need to do a batch insert
i have been trying this for weeks without sucess e.g how much experience do you have with Java? -
Multiple row insert "How To".
I need a "How To" to add multiple rows to a table based on various input values.
On my page I have the following:
In the report section:
select htmldb_item.hidden(1,null) circuit_id,
htmldb_item.text(2,null) datacomm_id,
htmldb_item.text(3,null) lan_equip_id,
htmldb_item.text(4,null) circuit,
htmldb_item.text(6,null) segment,
htmldb_item.text(7,null) subnet,
htmldb_item.text(8,null) lan_equip_model_id,
htmldb_item.text(12,null) jack,
htmldb_item.text(13,null) jpairs,
htmldb_item.text(14,null) risers,
htmldb_item.text(15,null) building,
htmldb_item.text(16,null) uplink_lan_equip,
htmldb_item.text(17,null) uplink_group,
htmldb_item.text(21,null) comments,
htmldb_item.text(22,null) vlan
from neteng_circuits
In the page processing processes section:
-- insert circuits
for i in 1..htmldb_application.g_f01.count
loop
insert into neteng_circuits
(datacomm_id,
lan_equip_id,
circuit,
topology,
segment,
subnet,
lan_equip_model_id,
lan_equip_ip,
group1,
port,
jack,
jpairs,
risers,
building,
uplink_lan_equip,
uplink_group,
uplink_port,
initials,
date_modified,
comments,
vlan)
values
(htmldb_application.g_f02(i),
htmldb_application.g_f03(i),
htmldb_application.g_f04(i),
:P41_TOPOLOGY,
htmldb_application.g_f06(i),
htmldb_application.g_f07(i),
htmldb_application.g_f08(i),
:P41_LAN_EQUIP_IP,
:P41_GROUP1,
:P41_PORT,
htmldb_application.g_f12(i),
htmldb_application.g_f13(i),
htmldb_application.g_f14(i),
htmldb_application.g_f15(i),
htmldb_application.g_f16(i),
htmldb_application.g_f17(i),
:P41_UPLINK_PORT,
:P41_INITIALS,
:P41_DATE_MODIFIED,
htmldb_application.g_f21(i),
htmldb_application.g_f22(i));
end loop;
In the items section (with appropriate setup):
5: P41_TOPOLOGY Select List
9: P41_LAN_EQUIP_IP Text Field
10: P41_GROUP1 Text Field
11: P41_PORT Text Field
18: P41_UPLINK_PORT Text Field
19: P41_INITIALS Select List
20: P41_DATE_MODIFIED Date Picker (DD-MON-RR)
Ultimately the only fields which differ for the 48 new circuits
which I wish to insert are:
circuit_id (based on a trigger), jack, jpair (based on a select list),
and port (values are 1-48, could be 1-16 under some circumstances).
The uplink fields depend on the uplink_port value and there are similar
relationships for other fields - I need to get them using select statements
dynamically behind the scenes.
Please help me to create this scenario.
Thank you for all your help. Trudy.Does she want to insert 48 rows from the multi-row add delete check box report? If I understand that part correctly, then she needs to create an add button that adds another empty row into the table. Then she needs to populate the row with data; she would have to do this 48 times. From a form or a report I doubt that there is any other way to do it. When you do the update, the database gets updated by your sql insert statement that is in the update process you create. The update gets an event notification by an update button that you have created by clicking the Create a button displayed among the region's items when you created the button. The view also gets rendered with the same sql code. Refer to the example in the links that I gave you;
your other question seems to revolve around sql.
add the condition where x > =1 and y <= 48 into your sql conditions with an
if condition. there are plenty of references for sql through a search on google;
Let me know how things go.
I have gotten my update to work with the workaround. The delete works with the following code:
for i in 1..htmldb_application.g_f01.count
loop
delete from patient_info where primary_key_Column = htmldb_application.g_f02(htmldb_application.g_f01(i));
end loop;
I also have the sample add and insert(update) working. but I need to get the add the row dynamically to work in my real world data.
Veena -
Error restoring row currency - Need Help
Hi All,
Can anyone explain me how can I control the row currency???????
this is my situation:
when I navigate from page1 (with one read-only table - tableEmployees) to page2 (with a read-only table - tableSelectEmployees, with this columns: ps, eps, obs, obs2, where ps, eps and obs are the primary keys), selecting the "create" button, I need to insert a new row in tableSelectEmployees (page2) with this values (ps=2, eps=2, obs=null, obs2=null). -----> Until here everything works Fine :)
The Big problem is when I need to navigate from page2 to page3 (with a read-only table - tableAddEmployees with this columns: DOM_ID, id, meaning, where Id is the primary key). The tableAddEmployees has a Query like this:
SELECT *
FROM tableAddEmployees
WHERE NVL(tableAddEmployees.DOM_ID,0) = NVL(:1, 0)
AND tableAddEmployees.ID NOT IN (
SELECT obs
FROM tableSelectEmployees
WHERE Ps= :2
AND Eps = :3
AND NVL(obs, 0) = NVL(:4, 0))
When I select the new row created (Ps=2, Eps=2, null, null) in page 2 and go to page3 I get this error messages from the log window:
12:17:20 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.EvermindHttpServletRequest
12:17:20 DEBUG (JhsActionServlet) -Request URI: /App_S2-ViewController-context-root/S2PopUpObstaculos.do
12:17:20 DEBUG (JhsActionServlet) -Request Character Encoding: windows-1252
12:17:20 DEBUG (JhsActionServlet) -Parameter searchText:
12:17:20 DEBUG (JhsActionServlet) -Parameter event_Rollback:
12:17:20 DEBUG (JhsActionServlet) -Parameter event:
12:17:20 DEBUG (JhsActionServlet) -Parameter partial:
12:17:20 DEBUG (JhsActionServlet) -Parameter source:
12:17:20 DEBUG (JhsActionServlet) -Parameter eventValue:
12:17:20 DEBUG (JhsActionServlet) -Parameter rowKeyStr:
12:17:20 DEBUG (JhsActionServlet) -Parameter partialTargets:
12:17:20 DEBUG (JhsDataAction) -Executing action /S2PopUpObstaculos
12:17:20 DEBUG (JhsDataAction) -lastIssuedPageTimeStamp set to: 1156245440919
12:17:20 DEBUG (JhsDataAction) -Found existing searchBean for S2AltaSociais2UIModel
12:17:20 DEBUG (JhsDataAction) -Stored searchBean for S2AltaSociais2UIModel on request
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value=0 ,new value=
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 1 has changed: old value=0 ,new value=2
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 2 has changed: old value=0 ,new value=2
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value=0 ,new value=
12:17:20 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:17:20 DEBUG (JhsDataAction) -executing onRollback
12:17:20 DEBUG (JhsDataAction) -executing Rollback ActionBinding
12:17:21 DEBUG (JhsDataAction) -Restoring row currencies
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosAssoc1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosAssoc1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 ERROR (JhsDataAction) -Error restoring row currency for S2ObstaculosLevel1Iterator: JBO-25020: View row of key oracle.jbo.Key[2 2 null ] not found in S2ObstaculosLevel1Iterator.
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value= ,new value=278263
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value= ,new value=278263
12:17:21 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:17:21 DEBUG (JhsDataAction) -Storing table binding factory under key jhsTableBindings on request
12:17:21 DEBUG (JhsDataAction) -Forward set by parameter property returned: /WEB-INF/page/S2PopUpObstaculos.uix
--->If I want this null values why is JDeveloper changing the row currency?
When I select one row from page2 with values like this (2, 2, 278264, null) I get the correct response:
12:19:41 DEBUG (JhsActionServlet) -Request class: com.evermind.server.http.EvermindHttpServletRequest
12:19:41 DEBUG (JhsActionServlet) -Request URI: /App_S2-ViewController-context-root/S2PopUpObstaculos.do
12:19:41 DEBUG (JhsActionServlet) -Request Character Encoding: windows-1252
12:19:41 DEBUG (JhsActionServlet) -Parameter searchText:
12:19:41 DEBUG (JhsActionServlet) -Parameter event_Rollback:
12:19:41 DEBUG (JhsActionServlet) -Parameter event:
12:19:41 DEBUG (JhsActionServlet) -Parameter partial:
12:19:41 DEBUG (JhsActionServlet) -Parameter source:
12:19:41 DEBUG (JhsActionServlet) -Parameter eventValue:
12:19:41 DEBUG (JhsActionServlet) -Parameter rowKeyStr:
12:19:41 DEBUG (JhsActionServlet) -Parameter partialTargets:
12:19:41 DEBUG (JhsDataAction) -Executing action /S2PopUpObstaculos
12:19:41 DEBUG (JhsDataAction) -lastIssuedPageTimeStamp set to: 1156245581741
12:19:41 DEBUG (JhsDataAction) -Found existing searchBean for S2AltaSociais2UIModel
12:19:41 DEBUG (JhsDataAction) -Stored searchBean for S2AltaSociais2UIModel on request
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 0 has changed: old value=0 ,new value=278264
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 1 has changed: old value=0 ,new value=2
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 2 has changed: old value=0 ,new value=2
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: value of bind param 3 has changed: old value=0 ,new value=278264
12:19:41 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: executing query, bind parameter values have changed
12:19:41 DEBUG (JhsDataAction) -executing onRollback
12:19:41 DEBUG (JhsDataAction) -executing Rollback ActionBinding
12:19:41 DEBUG (JhsDataAction) -Restoring row currencies
12:19:42 DEBUG (JhsDataAction) -ViewObject S2DominiosLevel1: bind parameter values have not changed
12:19:42 DEBUG (JhsDataAction) -Storing table binding factory under key jhsTableBindings on request
12:19:42 DEBUG (JhsDataAction) -Forward set by parameter property returned: /WEB-INF/page/S2PopUpObstaculos.uix
Can anyone help me with this problem, please?
What can I do to solve this currency problem?
Please, I really need help on this!!!
I'm using JDeveloper10.1.2, struts, uix pages.
Thanks,
AtenaCan anyone give some help here?
-
I've created a Database schema that will allow the admin to
easily update thier form. To do this I am using the data from the
DB to dynamically create the form. For example, if the admin wants
to add a new input to the form, they can do that by giving it a
name and a type, such as text or radio.
I've written code that displays the form based on the data.
I'm stuck on getting the results from the form inserted back to the
DB. Hopefully I can explain this well enough without having to post
all the details.
I have one table that is the responses from the form. Each
row contains 5 columns that represent the request, the question,
the option chosen, any details from the option chosen (text from a
text field) and a customer id.
I need to do an insert that will create a new row for the
user's response to each question. I'm having some difficulty
creating this mutiple row insert. Here is what I have so far, I'm
using a mix of a DW insert with my own code. I'm hoping it's just a
syntax issue...but it could be more. Thanks in advance.I didn't really explain the result. Nothing is inserted into
the DB and everything that appeared on the page before adding the
insert now no longer appears. -
Hello Team....
i have two view one is read only view & other is updatable view.....i want to take the data(Multiple row) from read only view & want to insert in to updatable view.
How can i do this....?Hi Charu,
Try this:
1- in the property of the Read only table ( represent read only view ) make this
- Row Selection -----------> Multiple
- In Behivior clear SelectionListener
- In Advanced clear SelectedRowKeys
- In Advanced Binding make a bind to the table in backing bean
In Backing Bean:
RowKeySet rowSet1 = getYourTable().getSelectedRowKeys();
Iterator rowSetIter = rowSet1.iterator();
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding voIter =
(DCIteratorBinding)bindings.get("ReadOnlyViewObjectIterator");
while (rowSetIter.hasNext()) {
List l = (List)rowSetIter.next();
Key key = (Key)l.get(0);
voIter.setCurrentRowWithKey(key.toStringFormat(true));
Row r = voIter.getCurrentRow();
ApplicationModule am=voIter.getViewObject().getApplicationModule();
ViewObject vo = am.findViewObject("UpdatableViewObject");
Row vr=vo.createRow();
vr.setAttribute("attributeName1",r.getAttribute("attributeName1");
vr.setAttribute("attributeName2",r.getAttribute("attributeName2");
vr.setAttribute("attributeName3",r.getAttribute("attributeName3");
vo.insertRow(vr);
I hope this work
Sameh Nassar -
Multiple row insertion into rm_text_lines from "free format select text"?
We use the Repository Object Navigator (RON) to define views through the "free format select text" ("Select text" and "Where/Validation condition" fields).
Before the upgrade/migration to 9i (repository and clients), multi-line definitions inserted in these text fields with older Designer clients were saved in multiple rm_text_lines rows and have remained this way after the upgrade/migration.
With the 9i Designer clients, the multi-line definition (separated by "Enter" key) are now inserted as only one row.
Is there any (easy) way in Designer 9i client to "force" the insertion of multiple rows into rm_text_lines when an "Enter" (chr(13)+chr(10)) is encountered?Can you give a use case? Are you using some Repository API scripts that expect that rm_text_lines are no longer than a single line, that are now failing when the text is actually fairly long? Are you printing and want to make sure that line breaks occur where the user put them?
I ask because there really isn't a way to force Designer to break long text into multiple rm_text_line rows. Therefore, you are going to have to change your API scripts and reports to take the possible long lines into account. -
Multiple row insertions having a multiple item form
Hello everyone
A director at the company i work has asked for an application to help users request cleaning products for each of the buildings in the premises.
Consider there are 2 main tables:
- table request_cab, having the following columns:
- ID
- year
- request_number
- request_date
- obs
- user_id (references table users)
- dept_id (references table departments)
- deliverydate
- deliveryplace_name
- warehouse_id (references table warehouses)
- table request_lin, having:
- ID
- cab_id (references request_cab)
- year
- quantity
- product_id (references table product)
- productmeasure_id (references table measures)
As seen, table request_lin keeps the product details of the user's request while request_cab keeps the info regarding the request itself and who has made it.
The director wants only one form displaying all the 35 cleaning products available for request at the same time, having the users to insert the quantity of the corresponding product to request. She doesn't want the user to select the products to be requested so select-boxes won't do.
The problem i have is that the only way i know how to work with APEX is that each field on the form represents a single and different column in the table and what i need is to consider each field a single row to be inserted - this means, at worst, i have 35 lines to insert.
I believe it can't be done so i ask for your expert's knowledge to help me answer this question: Can this be done in APEX?
I thank in advance ALL the help you can give me!
Best regards
allpHi
Thank you for your reply.
I've been trying the tabular form option but i don't think it'll do because the idea is to have all items at the same form, displayed like a list. I've noticed 2 things:
- With tabular form, you have to insert each product by itself... And, even if i have an auxiliary table with all the id and product names that have to be displayed on the form, i can't integrate it at the table to which the tabular form will insert the records (in this case, table request_lin)...
- with manual tabular form, i have to list all the content of the request_lin table, which i don't want... I just need a template showing all products and textboxes to enter quantities...
Best regards
allp
Maybe you are looking for
-
Unable to launch the APex 4.0
Hi , While Installing i didnt get even a single error . I already had the Oracle XE and default apex 3.2 intsalled with it . Now i have moved from 10g to 11g , so i uninstalled the old apex using @apxremov.sql script Later i installed APEX 4.0 on 11g
-
hi, i cannot perform any syncs / back ups (including mobile me) on my imac other than old ipods. i recieve this message "An unknown error occurred while performing a sync operation. Please check your account and network settings, then try again".
-
What should/can I do?
-
I touch an app icon - it enlarges to full screen size as if loading but 1 second later it shrinks back to icon size. All the app icons do this - I can't load anything ! If anyone can help I'd be grateful - thanks - Paul
-
It "errors" when i try to export my keynote deck to quicktime. help?
I used to be able to but there must be a bug. It gets to the end of the export and stops saying there is an error and to close out. I have tried to export in all of the sizes and QT formats. Anyone?