Loop through result set and delete row
so here is what I need -
I have a query that pulls rows from the Database through a stored procedure.(these are properties in an area)
Before I start looping through the query, I need to check the distance between my current location and the property. If it less than 5 miles, only then should I display that property. The distance in miles will be chosen while submitting the search form.
So is there a way to delete rows from the result set based on the criteria? Or
Is there a better way to accomplish this? I am using the the google api to get the latitudes and longitudes. The other issue to keep in mind is the load time.
Thanks
You can do this the easy way or the hard way. Depends on whether your condition that needs to be checked can be expressed in the form of a SQL where clause. If it can, then do what BKBK suggested, and use a query of query to create a new resultset that only has the rows from the original resultset that don't meet your condition.
If the calculation of the condition is more complex, then do a CFLOOP over the query and examine each row to see if you want to keep it or toss it. if you want to toss it, the delete that row - there is a function in CFLIB.ORG called querydeleterow that should help you. Or, you could just clear out the row's contents and then do the query of query as described in BKBK's post to create a new resultset that doesn't include the blank rows.
Similar Messages
-
Hello, I am experience a heapdump while looping through a result set from a query I amr unning.
Our system creates an instance of a transfer object representing one row in the result set for each row as it loops through. The result set brings back 36000 rows, so it is creating 36000 objects. As a result, a heapdump is occurring. What can be done to fix this error?even if it holds 360000 rows,
I still think [zadok] idea is a great idea.
you can get, for example first 1000 rows, cacluate it save result, and then get the next 1000 rows, is it make sense?
if you still want to get it by one time, extend your vm mem, normal setting is 64M(I am not sure) -
Problem while looping through record set and tem table for matching data
hi I am using one record set and ane temp table and looping through both to find the match between dates.
If date matches then it shud do some processing otherwise it will return default values(null values).
FOR i IN student_rec .FIRST..student_rec .LAST /*student_rec.school_date has 01-MAR-2012,02-MAR-2012,03-MAR-2012,04-MAR-2012,05-MAR-2012*/
LOOP
l_return_out.school_date := student_rec(i).school_date;
l_return_out.marks_obtained := student_rec(i).marks_obtained;
FOR i IN selected_dates .FIRST..selected_dates .LAST /*selected_dates has 02-MAR-2012,03-MAR-2012,05-MAR-2012*/
LOOP
DBMS_OUTPUT.PUT_LINE(selected_dates(i));
IF selected_dates(i)=student_rec(i).sett_date
THEN
EXIT;
end if;
---------call procedure P1
-----------get output as ret_val1 /*getting ret_val1 as 10 for 02-MAR-2012,03-MAR-2012,05-MAR-2012 */
----------call procedure P2
---------get ouput as ret_val2 /*getting ret_val1 as 20 for 02-MAR-2012,03-MAR-2012,05-MAR-2012 */
if ret_val1>0 0r ret_val2>0
then
l_return_out.has_csts := yes;
l_return_out.cst_present := 10;
l_return_out.cst_absent := 20;
else
l_return_out.has_csts :=No;
l_return_out.cst_present:= 0;
l_return_out.cst_absent := 0;
end if;
end loop;
l_return_out.has_cst := student_rec(i).has_csts;
l_return_out.cst_missing := student_rec(i).cst_present;
l_return_out.cst_existing := student_rec(i).cst_absent;
PIPE ROW(l_return_out);
END LOOP;
RETURN ;
I am expecting this as result
school_date marks_obtained has_csts cst_present cst_absent
01-MAR-2012 20
02-MAR-2012 30 yes 10 20
03-MAR-2012 40 yes 10 20
04-MAR-2012 70
05-MAR-2012 60 yes 10 20
but this as result
school_date marks_obtained has_csts cst_present cst_absent
01-MAR-2012 20
02-MAR-2012 30
03-MAR-2012 40
04-MAR-2012 70
05-MAR-2012 60
Can anybody please highlight the mistake i am doing while processing the logic??
Edited by: 942390 on Jul 13, 2012 8:44 PM
Edited by: 942390 on Jul 13, 2012 8:45 PMI am getting a set values from a record set....student_rec
and on pipelining this record set from 1st till last
i am getting this
school_date marks_obtained has_csts cst_present cst_absent
01-MAR-2012 20
02-MAR-2012 30
03-MAR-2012 40
04-MAR-2012 70
05-MAR-2012 60
so initially has_csts, cst_present and cst_absent is null for all dates.
now have a temp table of selected_dates(which contains these dates 02-MAR-2012,03-MAR-2012,05-MAR-2012)
now I am want to populate has_csts, cst_present and cst_absent with data only for those dates which is present in selected_dates temp table(02-MAR-2012,03-MAR-2012,05-MAR-2012) and that too has_csts, cst_present and cst_absent will be populated with some condition (based on the values from procedure got from P1 and P2).
so want result set to look like
school_date marks_obtained has_csts cst_present cst_absent
01-MAR-2012 20
02-MAR-2012 30 yes 10 20
03-MAR-2012 40 yes 10 20
04-MAR-2012 70
05-MAR-2012 60 yes 10 20
so what could be the possible solution to obtained this.... -
ABAP routine - looping a result set from table.
I am trying to access a table and pass the resulting rows to an internal table.
However, before passing, I need to do some data manipulation on one of the columns of the table and then pass it.
If I didn't have to do this, I could have just said
INTO CORRESPONDING FIELDS OF TABLE
But since I have do data manipulation, I cannot do this. This is what I am doing now.
SELECT * FROM /BI0/QEMPLOYEE WHERE JOB = '1234' AND DATETO = '99991231'.
MOVE /BI0/QEMPLOYEE-EMPLOYEE TO INT_EMP-EMPN.
MOVE /BI0/QEMPLOYEE-JOB TO STR1.
STR2 = STR1 + 0(4)
SEARCH STR2 FOR ' ' STARTING AT 1 ENDING AT 1.
IF SY-SUBRC EQ 0.
REPLACE ' ' WITH '0' INTO STR2.
ENDIF.
MOVE STR2 TO INT_EMP-FAC.
But this will move only one row. How can I move all the rows? Is there a loop that I can use? I can see a loop for internal tables but I need to loop the result set and then send it. I posted this question twice but haven't gotten the right answer.
Thanks.Hi,
Are you trying to write the code in Update Routine or a Start Routine.?
If you want to update all the records, you can use the start routine.
So you need to use a loop for doing all the records.
If you are using a Update routine then you dont have to use the loop.
But here I recommend the Start Routine is the best choice.
Here is a document which can be helpful for you:
http://bluestonestep.com/component/option,com_docman/task,doc_download/gid,13/
Happy Tony -
How can I use a Lookup task to lookup from my SQL Result set and have a join
So in my Control Flow, I have an Execute SQL Task which gets my Table result set. I then have a Foreach Loop Container that iterates through the result set and a Data Flow. The first task in the Data Flow is an OLE DB Source SQL Command that retrieves data
columns associated with my result set. I then do a Derived Column so I can SUBSTRING from one of my data columns and now I want to perform a Lookup to my Application Database.
How do I code my Lookup task to utilize my SQL Result set variable and match on it? I cannot use the GUI for the Lookup task as my Lookup has to have some JOINS in it.
Thanks for your review and am hopeful for a reply.Can you expand on that? I'm sorry but I am new and a novice to the SSIS world and I want to do this as best I can and as efficiently as I can. Are you saying that Rajen's way suggested above is the way to go?
A little background....external data from a 3rd party client. I'v staged that external data to a SQL Server staging table. I have to try and match that data up to our database using SSN, DOB, and Gender...and if I can't match that way then I have to try
and match by Name. I need to make sure that there is only one and only one account for that match. If I cannot match and match one and only one, then I'll create rows on a DataAnomaly Table. If I do match, then I have to check and make sure that there is only
one and only one Member span for that match. Similarly handle the data anomaly and then check and make sure there is a "Diabetes" claim and similarly handle the DataAnomaly accordingly.
That's where I'm at. Sooooo are you saying to use Rajen's suggestion? I don't think I can do that because I need multiple SQL tasks and I cannot connect multiple OLE DB Source tasks.
Any help and suggestions are greatly appreciated.
Thanks. -
How to Loop through another list and update a column with SharePoint Designer 2013 Workflow
Hi,
I am trying to get my head around the new 2013 Workflow Engine and SharePoint Designer 2013 Workflow Text-Based Designer.
I have two lists.
List A has 2 columns: Title, Completed (Yes/No)
List B has 3 columns: Title, LookupListATitle, Completed (Yes/No)
All the 2013 Workflow components have been installed and configured and I am selecting the 2013 Workflow option in SPD
I am trying to set off a 2013 Workflow when an item in List A is edited to Loop through List B and select items where the LookupListATitle column's value is equal to the Title value of the current item, and set the value of the Completed column for those
items in ListB to "Yes".
I have the Workflow configured like this:
Stage: Stage 1
IF Current Item:Completed equals Yes
Loop: 1
The contents of this loop will run repeatedly while: ListB:LookupListATitle equals Current Item: Title
Update item in ListB.
(The dialog options for the update item action as follows:
List: ListB
Field: Completed, Value: Yes
In the Find the List Item section
Field: LookupListATitle
Value: Current Item: Title)
Transition to stage
Go to End of Workflow
When I update an item in ListA and set its Completed column to Yes, I would expect the Workflow to find all the items in List B where the Lookup column is equal to ListA's Title (there are 2) and update their Completed column to Yes. But it doesn't work.
When I look at the Workflow Status it says the Internal Status is "Canceled" and the information pop up has the following alien language (and may be truncated):
RequestorId: 95f03b62-8956-ac14-c5cf-dc98c89c589c. Details: System.ArgumentException: Invalid JSON primitive: Item001. Parameter name: value at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.ConvertStringToJsonNumber(String value) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.ReadPrimitive(String
type, XmlDictionaryReader jsonReader) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.JXMLToJsonValue(XmlDictionaryReader jsonReader) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.JXMLToJsonValue(Stream jsonStream, Byte[] jsonBytes)
at Microsoft.Activities.DynamicValue.ParseJson(String json) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
Unfortunately I don't have access to the server, logs etc.
I would love to find some tutorials, or any books on SharePoint Designer 2013 in general and Workflows in particular but my searches haven't turned up much so far apart from a pre-release Beginning SharePoint Workflows which is in its very early stages and
not much help yet.
Can anyone give me some guidance on how to set up While Loops to iterate through a related list using SharePoint Designer 2013?
MarkHi,
I understand that you wanted to update the items in the other list (Participants) where the Course equals the Current Item.
You need to use “Call HTTP Web Service" action and “Build Dictionary" action to get the Maxid and then loop Participants to update the items.
You can follow the steps as below to achieve what you want:
Create a custom list named Courses, add columns: Title(Single line of text), Course ID(Single line of text), Course Finalised (Yes/No).
Create a custom list named Participants, add columns: Title(Single line of text), Course(Lookup), CourseFinalised (Yes/No).
Create workflow associated to Courses, start the workflow automatically when an item is created or changed.
Add conditions and actions:
The HTTP URL is set to
https://sitename/_api/web/lists/GetByTitle('listname')/items?$orderby=Id%20desc and the HTTP method is set to “GET”. Then the list will be order by Id and desc.
Then if Course Finalised is equal to Yes, the CourseFinalised of the associated items in Participants will be updated to Yes.
More information:
http://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/
Thank you for your understanding.
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Insert row and delete row in a table control
Hi Experts,
I am using a table control in module pool programming, How can I Insert row and delete row in a table control?
Thanks in Advance....Santhosh,
Iam using this code..
FORM fcode_delete_row
USING p_tc_name TYPE dynfnam
p_table_name
p_mark_name .
-BEGIN OF LOCAL DATA----
DATA l_table_name LIKE feld-name.
data: p_mark_name type c.
FIELD-SYMBOLS <tc> TYPE cxtab_control.
FIELD-SYMBOLS <table> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa>.
FIELD-SYMBOLS <mark_field>.
-END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
get the table, which belongs to the tc *
CONCATENATE p_table_name '[]' INTO l_table_name. "table body
ASSIGN (l_table_name) TO <table>. "not headerline
delete marked lines *
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
access to the component 'FLAG' of the table header *
ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
if <MARK_FIELD> = 'X'.
PERFORM f_save_confirmation_9101.
IF gv_answer EQ '1'.
DELETE <table> INDEX syst-tabix.
IF sy-subrc = 0.
<tc>-lines = <tc>-lines - 1.
ENDIF.
ELSE.
ENDIF.
ENDIF.
ENDLOOP.
in this code ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
if <MARK_FIELD> = 'X'.
this code is not working... -
Why to need close the result set and statement
why to need close the result set and statement
It's best to explicitly close every ResultSet, Statement, and Connection in the narrowest scope possible.
These should be closed in a finally block.
Since each close() method throws SQLException, each one should be in an individual try/catch block to ensure that a failure to close one won't ruin the chances for all the others.
You can capture this in one nice utility class, like this:
package db;
import java.sql.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
* Created by IntelliJ IDEA.
* User: MD87020
* Date: Feb 16, 2005
* Time: 8:42:19 PM
* To change this template use File | Settings | File Templates.
public class DatabaseUtils
* Logger for DatabaseUtils
private static final Log logger = LogFactory.getLog(DatabaseUtils.class);
/** Private default ctor to prevent subclassing and instantiation */
private DatabaseUtils() {}
* Close a connection
* @param connection to close
public static void close(Connection connection)
try
if ((connection != null) && !connection.isClosed())
connection.close();
catch (SQLException e)
logger.error("Could not close connection", e);
* Close a statement
* @param statement to close
public static void close(Statement statement)
try
if (statement != null)
statement.close();
catch (SQLException e)
logger.error("Could not close statement", e);
* Close a result set
* @param rs to close
public static void close(ResultSet rs)
try
if (rs != null)
rs.close();
catch (SQLException e)
logger.error("Could not close result set", e);
* Close both a connection and statement
* @param connection to close
* @param statement to close
public static void close(Connection connection, Statement statement)
close(statement);
close(connection);
* Close a connection, statement, and result set
* @param connection to close
* @param statement to close
* @param rs to close
public static void close(Connection connection,
Statement statement,
ResultSet rs)
close(rs);
close(statement);
close(connection);
* Helper method that maps a ResultSet into a map of columns
* @param rs ResultSet
* @return map of lists, one per column, with column name as the key
* @throws SQLException if the connection fails
public static final Map toMap(ResultSet rs) throws SQLException
List wantedColumnNames = getColumnNames(rs);
return toMap(rs, wantedColumnNames);
* Helper method that maps a ResultSet into a map of column lists
* @param rs ResultSet
* @param wantedColumnNames of columns names to include in the result map
* @return map of lists, one per column, with column name as the key
* @throws SQLException if the connection fails
public static final Map toMap(ResultSet rs, List wantedColumnNames)
throws SQLException
// Set up the map of columns
int numWantedColumns = wantedColumnNames.size();
Map columns = new LinkedHashMap(numWantedColumns);
for (int i = 0; i < numWantedColumns; ++i)
List columnValues = new ArrayList();
columns.put(wantedColumnNames.get(i), columnValues);
while (rs.next())
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
List columnValues = (List)columns.get(columnName);
columnValues.add(value);
columns.put(columnName, columnValues);
return columns;
* Helper method that converts a ResultSet into a list of maps, one per row
* @param rs ResultSet
* @return list of maps, one per row, with column name as the key
* @throws SQLException if the connection fails
public static final List toList(ResultSet rs) throws SQLException
List wantedColumnNames = getColumnNames(rs);
return toList(rs, wantedColumnNames);
* Helper method that maps a ResultSet into a list of maps, one per row
* @param rs ResultSet
* @param wantedColumnNames of columns names to include in the result map
* @return list of maps, one per column row, with column names as keys
* @throws SQLException if the connection fails
public static final List toList(ResultSet rs, List wantedColumnNames)
throws SQLException
List rows = new ArrayList();
int numWantedColumns = wantedColumnNames.size();
while (rs.next())
Map row = new LinkedHashMap();
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
row.put(columnName, value);
rows.add(row);
return rows;
* Return all column names as a list of strings
* @param rs query result set
* @return list of column name strings
* @throws SQLException if the query fails
public static final List getColumnNames(ResultSet rs) throws SQLException
ResultSetMetaData meta = rs.getMetaData();
int numColumns = meta.getColumnCount();
List columnNames = new ArrayList(numColumns);
for (int i = 1; i <= numColumns; ++i)
columnNames.add(meta.getColumnName(i));
return columnNames;
}Anybody who lets the GC or timeouts or sheer luck handle their resource recovery for them is a hack and gets what they deserve.
Do a search on problems with Oracle cursors being exhausted and learn what the root cause is. That should convince you.
scsi-boy is 100% correct.
% -
Adding and deleting "rows" in pdfs
I need to know the best way to edit pdfs. What I have are files that resemble a table setup in Word. I would need to add and delete "rows" of information which are also set up in columns. I also may need to edit some of the text in a row.
What is the best tool for me to use? Acrobat? Illustrator? We are currently using v.10 on Macs. Is there a fairly simple way to accomplish this?I don't think there is a good way to do this. Except for very simple edits, it's better to edit the source document and recreate the PDF. If there is no source document available, you can try exporting to Word from Acrobat and see if you get something usable.
-
Help with streaming result sets and prepared statements
hi all
I create a callable statement that is capable of streaming.
statement = myConn2.prepareCall("{call graphProc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}",java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
statementOne.setFetchSize(Integer.MIN_VALUE);
the class that contains the query is instantiated 6 times the first class streams the results beautifully and then when the second
rs = DatabaseConnect.statementOne.executeQuery();
is executed I get the following error
java.sql.SQLException: Can not use streaming results with multiple result statements
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1370)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1688)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3031)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:943)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1049)
at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:589)
the 6 instances are not threaded and the result set is closed before the next query executes is there a solution to this problem it would be greatly appreciated
thanks a lot
BrianDatabase resources should have the narrowed scope
possible. I don't think it's a good idea to use a
ResultSet in a UI to generate a graph. Load the data
into an object or data structure inside the method
that's doing the query and close the ResultSet in a
finally block. Use the data structure to generate
the graph.
It's an example of MVC and layering.
Ok that is my bad for not elaborating on the finer points sorry, the results are not directly streamed into the graphs from the result set. and are processed in another object and then plotted from there.
with regards to your statement in the beginning I would like to ask if you think it at least a viable option to create six connections. with that said would you be able to give estimated users using the six connections under full usage.
just a few thoughts that I want to
bounce off you if you don't mind. Closing the
statement would defeat the object of of having a
callable statement How so? I don't agree with that.
%again I apologise I assumed that since callable statements inherit from prepared statements that they would have the pre compiled sql statement functionality of prepared statements,well If you consider in the example I'm about to give maybe you will see my point at least with regards to this.
The statement that I create uses a connection and is created statically at the start of the program, every time I make a call the same statement and thus connection is used, creating a new connection each time takes up time and resources. and as you know every second counts
thanks for your thoughts
Brian. -
Loop through all layers and sublayers
is there a way that I can loop through all layers and sublayers looking for a name of a layer? I have one that loops through only top level layers. I am thinking I have to somehow incorperate all pathItems, groupItems and the like to incorperate all types of "layers" there might be, since a group is technically not a layer but a groupItem.
this is what I am doing so far:
for (var i = 0; i < numberOfLayers; i++) {
var customName = "div structure";
var myLayer = app.activeDocument.layers[i];
var myLayer = myLayer.name;
alert(myLayer);
//alert (myLayer);
if (customName == myLayer) {
alert("layer matches");
else { break; }
any ideas?Sorry I don't understand what it is you are trying to achieve… Most collections offer a getByName() method if you know what you are looking for eg…
doc.layers.getByName( 'fluff' );
This should return you the first found or error so you need to try & catch when using this… -
Looping through results of a Select through a DB adapter
I am selecting an unknown number of rows from a database through the DB adapter into my process. When I get these results I need to loop through them, but the examples I have seen require an attribute to define each row for the loop to work . My result set is not giving me an attribute and I do not see how to define one in the wizard used to define the adapter.
Is there a way to assign an attribute to each row automatically as it comes out or after the fact? Or is there another way to attack this problem that I do not see?
Thank you in advance for the help.
--Mikeyou can take the results payload and loop thru with the while statement, then you can iterate thru each result and doing whatever you need to. Just make a counter variable of type int and count the number of records in the payload, then initialize a iterator varible on int and set to 0.
then just loops thru the payload and add +1 to iterator until it reaches the count number. This allows you to hit each records one by one, and do any kind of analysis on the current record set. -
How can I select and delete rows based on the value in one column?
I searched through the discussion board, and found a thread on deleting blank rows, but not sure how to modify it to work with my issue.
I have put together a rather complicated spreadsheet for designing control systems, it calculates parts needed based on check boxes selected in a second spreadsheet.
Since not all systems require all parts there are many rows that have a 0 quantity value, I would like to select these rows and delete them once I have gone through the design phase (checking off required features on a separate sheet).
I like the way the other thread I found will gather all the blank rows at the bottom without changing the order of the rows with data in them.
I don't understand exactly how the formula in the other thread works well enough to modify it to look for a certain column.
I hope I made myself clear enough here, to recap, I would like to sort the rows based on a zero value in one (quantity) column, move them (the zero quantity rows) to the bottom of the sheet, and then delete the rows with a zero quantity (I can delete them manually, but would like to automate the sorting part).
Thanks for any help anyone can provide here.
DannyI apologize but, as far as I know, Numbers wasn't designed by Ian Flemming.
There is no "this column will be auto-destructing after two minutes"
You will have to use your fingers to delete it.
I wish to add a last comment :
if your boss has the bad habit to look over your shoulder, it's time to find an other one.
As I am really pig headed, it's what I did. I became my own boss so nobody looked over my shoulder.
Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 20:30:25
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
How can I loop through a Vector and compare
I'm working on a school project that is a quiz server. Instructors could telnet into the app and create quizes and then users can take them. I have it so it can set up new quizes so far. Right now I'm working on it so the user can choose a quiz and take the test. Since it requires proper user handling I have it so I display the quiz ID and quiz Name. The user would need to enter the quiz ID to take it. I have it that as it displays the ID's it enters them into a Vector. Then I do a loop through all elements until I get one that equals the user selection. I'm having problems with it though. Here's some code:
do
quizCheck = false;
for (int i=0;quizReference.size();i++)
if (selectionInt==quizReference.elementAt(i))
quizCheck=true;
}while (quizCheck==false);
It's giving me a Error #300:method==(int,java,lang.Object)not found in class testproject.TestProject on the if line. Is there a way to handle this scenario. Also is there a better way?Hi,
elementAt(...) returns an Object - of what type is your selectionInt? - guess, it is a primitve int value, not an Object.
You can find it easier - say, you have Integer values in that Vector - and selectionInt is an int value - now you can find it using
int p = quizReference.indexOf(new Integer(selectionInt));
p is either -1 (if not found) or the index of the first found element, with the same int value as selectionInt.
Hope, this helps
greetings Marsian -
Loop through nested elements and insert via PL/SQL
INSERT INTO Orders(id, OrderXML) VALUES
(S_Orders.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<Order xmlns="urn:foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:foo foo-1.xsd">
<OrderRef>BBB</OrderRef>
<OrderDate>2005-03-29</OrderDate>
<CustomerID>1051</CustomerID>
<Items>
<Item>
<ProductID>7</ProductID>
<Price>45.6</Price>
<Quantity>2</Quantity>
</Item>
<Item>
<ProductID>19</ProductID>
<Price>73.5</Price>
<Quantity>10</Quantity>
</Item>
</Items>
</Order>'
I some questions regarding index search of nested elements like,Items in the above example.
I would like to know how I can LOOP through the Items like 1..2 LOOP
and insert those elements(item) into one table. Order information should go in to another table.
Can this be done with xpath and PL/SQL.
Regards
UlfHi Marco!
Here's some more information:
CREATE TABLE ITEM (ProductID NUMBER,
Price NUMBER(8,2)
Quantity 10 NUMBER);
CREATE TABLE ORDER (OrderRef VARCHAR2(10),
ORDER_DATE VARCHAR2(10),
CUSTOMERID NUMBER);
The main problem that I have is to create an solution that can be dynamic so that I can have for instance one order and four items in one XML.
The second XML can have one order and 10 items.
First I want to insert the order elements in the order table and then the items records in the item table.
To complicate things futher my real XML have namespaces in the XML, but this I think I can handle.
Summary: So for each order row(element) I want to traverse the Item elements and insert them to the Item table.
Regards
/Ulf
Maybe you are looking for
-
Oracle 8i Lite Sql*Plus error
When attempting to connect to Sql*Plus I get the error ORA-21526 in an infinite loop. Any ideas how to get around it? I am running under Windows 98. null
-
Report from Service entry sheet
Dear all Kindly let me know which transaction code to use to get report on Expenditure on a particular service master. regards M.Chandra mohan
-
Hi I posted this more as an FYI. I'm using Firefox 31 on two PCs. and had a phishing incident today. I read your article on Firefox's ant-phishing / anti-malware protection, and using the two test pages you provided I found the phishing test page was
-
Video downloads freeze after a minute or so
When I download videos, for example from a site such as Vimeo, or the iPad promo video from the Apple site, the video freezes after a minute or so and will go no further. Any ideas? Is it down to the size of my processor? There doesn't seem to be a p
-
BPC Data Generator Dimension List Issue
Hi BPC NW Experts, Could you, please, help to resolve the following issue? During selection of an application set in the BPC Data Generator Tool we do not get the list of the application set dimensions. We are running on BPC NW 7.5 SP07. The local ma