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
Ulf
Hi 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
Similar Messages
-
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 -
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 -
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 nested datasets
My apologies in advance if this has been asked before, but the search function on these forums doesn't appear to be working at the moment...
Using: Spry 1.6.1
Dreamweaver CS5
IE 7 and 8, Firefox 4, and Chrome 10
The question:
I have a parent xml dataset, with two nested datasets, like this:
var dsCourse = new Spry.Data.XMLDataSet("menu2.xml", "menu");
var dsTopic = new Spry.Data.NestedXMLDataSet(dsCourse, "topic");
var dsLessons = new Spry.Data.NestedXMLDataSet(dsTopic, "lesson");
The data displays properly in the html, using regions, etc. However, when I try looping through them using javascript:
topics = dsTopic.getData();
for (var t = 0; t < topics.length; t++) { //loop through the topics dataset
dsTopic.setCurrentRowNumber(t);
var top = dsTopic.getCurrentRow();
alert('current topic row name: ' + top["@name"]); //for debug purposes, display the topic name
var rows = dsLessons.getData();
for (var i = 0; i < rows.length; i++) { //loop through the lessons dataset
dsLessons.setCurrentRowNumber(i);
alert("lesson name is: " + rows[i]['name']);//display the lesson name
It will perform both loops properly, displaying the correct information for each dataset in Firefox 4, but in IE 7 and 8, and in Chrome it will list each of the Topics correctly, but only displays the first set of lessons.
The xml looks like:
<topic name="Claims" default="true" complete="false">
<lesson>
<name>Getting Started</name>
<score>0</score>
</lesson>
<lesson>
<name>Adding a Claim</name>
<score>0</score>
</lesson>
<lesson>
<name>Adding a Claimant</name>
<score>0</score>
</lesson>
<topic name="Bills" default="false" complete="false">
<lesson>
<name>Bill Components</name>
<score>0</score>
</lesson>
etc.
For what it's worth, all of the topics and lessons display properly in the html using spry regions, etc. It only appears to have an issue in javascript. And then only in IE. Is there, perhaps, a better way to do this that I'm not aware of?
Thanks in advance!
JonathanThis might help http://labs.adobe.com/technologies/spry/samples/data_region/NestedXMLDataSample.html
Gramps -
Search in Nested Tables and Insert the result into new Nested Table!
How can I search in Nested Tables ex: (pr_travel_date_range,pr_bo_arr) using the SQL below and insert the result into a new Nested Table: ex:g_splited_range_arr.
Here are the DDL and DML SQLs;
Don't worry about the NUMBER( 8 )
CREATE OR REPLACE TYPE DATE_RANGE IS OBJECT ( start_date NUMBER( 8 ), end_date NUMBER( 8 ) );
CREATE OR REPLACE TYPE DATE_RANGE_ARR IS TABLE OF DATE_RANGE;
DECLARE
g_splited_range_arr DATE_RANGE_ARR := DATE_RANGE_ARR( );
g_travel_range DATE_RANGE := DATE_RANGE( '20110101', '99991231' );
g_bo_arr DATE_RANGE_ARR := DATE_RANGE_ARR( DATE_RANGE( '20110312', '20110317' ), DATE_RANGE( '20110315', '20110329' ) );
FUNCTION split_date_sql( pr_travel_date_range DATE_RANGE,
pr_bo_arr DATE_RANGE_ARR )
RETURN DATE_RANGE_ARR
IS
l_splited_range_arr DATE_RANGE_ARR;
BEGIN
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM (WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT tr_end_date, 0 FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT bo_start_date - 1, 1 FROM TABLE( pr_bo_arr )
UNION ALL
SELECT bo_end_date + 1, -1 FROM TABLE( pr_bo_arr )),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val) AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val) AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date);
RETURN l_splited_range_arr;
END;
BEGIN
g_splited_range_arr := split_date_sql(g_travel_range,g_bo_arr);
FOR index_g_splited_range_arr IN g_splited_range_arr .FIRST .. g_splited_range_arr .LAST LOOP
DBMS_OUTPUT.PUT_LINE('g_splited_range_arr[' || index_g_splited_range_arr || ']: ' || g_splited_range_arr(index_g_splited_range_arr).start_date || '-' || g_splited_range_arr(index_g_splited_range_arr).end_date );
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
NULL;
END;Or can I create a VIEW with parameters of Nested Tables in it so I can simply call
SELECT *
BULK COLLECT INTO g_splited_range_arr
FROM view_split_date(g_travel_range,g_bo_arr);@riedelme
For your questions:
1) I don't want to store in the database as a nested table
2) I don't want to retrieve data from the database. Data will come from function split_date() parameter and data will be processed in the function and function will return it in nested table format. For more detail please look at the raw function SQL.
I have a SQL like:
WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM travel
UNION ALL
SELECT tr_end_date, 0 FROM travel
UNION ALL
SELECT bo_start_date - 1, 1 FROM black_out_dates
UNION ALL
SELECT bo_end_date + 1, -1 FROM black_out_dates),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val)
AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val)
AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date;I want to change the tables black_out_dates and travel to Nested Array so I can use it in a function with Nested Array travel and Nested Array black_out_dates parameters and the function will return Nested Array of date ranges.
Here is what I want in raw SQL:
DECLARE
g_splited_range_arr DATE_RANGE_ARR := DATE_RANGE_ARR( );
g_travel_range DATE_RANGE := DATE_RANGE( '20110101', '99991231' );
g_bo_arr DATE_RANGE_ARR := DATE_RANGE_ARR( DATE_RANGE( '20110312', '20110317' ), DATE_RANGE( '20110315', '20110329' ) );
FUNCTION split_date_sql( pr_travel_date_range DATE_RANGE,
pr_bo_arr DATE_RANGE_ARR )
RETURN DATE_RANGE_ARR
IS
l_splited_range_arr DATE_RANGE_ARR;
BEGIN
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM (WITH all_dates
AS (SELECT tr_start_date AS a_date, 0 AS black_out_val FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT tr_end_date, 0 FROM TABLE( pr_travel_date_range )
UNION ALL
SELECT bo_start_date - 1, 1 FROM TABLE( pr_bo_arr )
UNION ALL
SELECT bo_end_date + 1, -1 FROM TABLE( pr_bo_arr )),
got_analytics
AS (SELECT a_date AS start_date,
LEAD( a_date ) OVER (ORDER BY a_date, black_out_val) AS end_date,
SUM( black_out_val ) OVER (ORDER BY a_date, black_out_val) AS black_out_cnt
FROM all_dates)
SELECT start_date, end_date
FROM got_analytics
WHERE black_out_cnt = 0 AND start_date < end_date
ORDER BY start_date);
RETURN l_splited_range_arr;
END;
BEGIN
g_splited_range_arr := split_date_sql(g_travel_range,g_bo_arr);
FOR index_g_splited_range_arr IN g_splited_range_arr .FIRST .. g_splited_range_arr .LAST LOOP
DBMS_OUTPUT.PUT_LINE('g_splited_range_arr[' || index_g_splited_range_arr || ']: ' || g_splited_range_arr(index_g_splited_range_arr).start_date || '-' || g_splited_range_arr(index_g_splited_range_arr).end_date );
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
NULL;
END;I must change the tables black_out_dates and travel in a way so it will be something like
FROM TABLE( pr_travel_date_range )to get the result into l_splited_range_arr so it will be something like
SELECT start_date, end_date
INTO l_splited_range_arr(start_date, end_date)
FROM ( -
Need help - Create an application to loop through folder of images & insert
Hi,
We have a requirement to loop through a folder of images (around 1000) and insert all of them to a database. What is the best way to approach this. I am new to Swing, so looking for a bit of direction (not for anybody to write the code..I can do that :). Ideally, the user would be able to select all of the images they would like to upload.
Any feedback much appreciated.
Thanks.what you don't understand is that there is rarely a single straightforward solution,
due to the various customizations available, so most regulars test their solutions
just to make sure it works. This takes time - perhaps only a few minutes, sometimes
significantly longer.
how do you think we feel when we click on another forum, only to find a/the solution
posted there some hours earlier?
our time totally wasted, trying to help an inconsiderate arsehole
keep going through life with no consideration for others - your kind are the first ones
to go when 'downsizing' - and the current financial situation is looking good for that.
(free tip: find yourself a good streetcorner now) -
Insert Loop through a Report or Insert using a Column Link
Hello!
I think I have an easy one.
I have created a site that tracks "issues" with the curriculum of a university's courses. If a curriculum developer sees something that must be updated, they use this site to log the "issue" so we have a running list of how the curriculum has changed for the particular course or courses. Some "issues" span multiple courses, so a table was created to allow the issue to be associated with as many courses as necessary.
The "Courses" table holds a list of all courses at the university
The "Issue_Courses" table combines the primary key for the "issue" and the "course" and creates the association between issues and courses.
The page users use to create the associations has a report called "add_courses" which is searchable and filterable so the user can narrow down the list of courses they want to view (the list is well into the thousands), and this report contains a column with check boxes. This page also contains a hidden field containing the primary key for the issue, "p13_Issue_ID"
I would like to create an insert statement that grabs the primary key for the issue from "p13_issue_ID" and loops through the report, inserting a new record for each checked box in the report. Any assistance would be great! Admittedly, my sql is pretty week.
Another option that I think would work, if possible, would be to have a "column link" that simply runs the insert process by grabbing the issue primary key from "p13_issue_ID" and the course id from the report. Then, the user could simply click on an "Add" link or something similar on the report, which would run the insert statement, and basically create that association. Is this possible?
Thanks in advance!
Edited by: 846852 on Mar 23, 2011 3:12 PM
Edited by: 846852 on Mar 23, 2011 3:14 PMStart with adding a checkbox column to the report in page (13 ??)
select apex_item.checkbox(1,course_id) CHECK
,course_name
FROM courses
I assumed that course_id is the PK of the courses table , if not change the column names appropriately
In report attributes of the "CHECK" column, change the column type to "*Standard Report Column*" (important).
Now you should see a report with courses lists and checkboxes to choose them, You can also do the same with an interactive report(if you want to use it features to filter down records)
Inorder to process the records create a PLSQL process that loops over the selected records(courses) and creates the relation in the Issue courses table using the hidden item and checked course primary key(course_id above)
DECLARE
ln_course_id NUMBER;
BEGIN
FOR 1 IN 1..APEX_APPLICATION.G_f01.COUNT
LOOP
ln_course_id := APEX_APPLICATION.G_f01(i);
--Insert new relation using Issue Id and course ID
INSERT INTO ISSUE_COURSES(course_id,issue_id) VALUES( ln_course_id,:P13_ISSUE_ID);
END LOOP;
END;If you have a submit/save button , make the process conditional for that button. -
Looping through an array to insert contents into an HTML table
Im trying to loop through a String array and insert the contents into an html table, unfortunately my coding is only filling in the first row in the table and ignores any additional info. Im using webservices that is connecting to a table in the database.
Info = ID + ";" + played + ";" + won + ";" + lost + ";" is the String im pulling into my client.
<table border = "1">
<tr>
<td><b>ID</b></td>
<td><b>played</b></td>
<td><b>won</b></td>
<td><b>lost</b></td>
</tr>
<%
try {
leglessclient.LegendServiceService service = new leglessclient.LegendServiceService();
leglessclient.LegendService port = service.getLegendServicePort();
String Info = port.displayLog();
String[] log = Info.split(";");
out.println("<tr>");
for (int a = 0 ; a < log.length; a++) {
for (int b = 0 ; b < 4; b++){
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
b++;
out.println("</tr>");
out.println("</table>");
} catch (Exception ex) {
// TODO handle custom exceptions here
%>
Any help would be greatly appreciated
thanks!firstly, if you have multiple rows.. you need to start each row with <tr> and end with a </tr>. You just have one in the beginning and end,which will obivously give data in one row.
out.println("<tr>");
for (int a = 0 ; a < log.length; a++) {
for (int b = 0 ; b < 4; b++){
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
out.println("<td>" + (log[a]) +"</td>");
a++;
b++;
out.println("</tr>"); -
Looping through a directory to insert BLOBS
I have about 300GB of jpegs to insert into my database. Does anyone have an example of how to loop through the directories, a directory at a time, to insert all of the images? Thanks.
The best way is to probably use Java it iterate through the directories. You could either store the files in the database (BLOB) or just reference their location (BFILE). Unless you have another 300 or so GB to load the files in the database you will have to reference them. Unless you load a few hundred jpgs, delete them, ... loop. That way you would have the storage requirements. Java handles file access great and because you can wrap the java methods with PL/SQL its a great one two punch. Of course, you will need a java developer (ie. me).
-
Loop Through Excel Files and Load into SQL Server Table
I'm following the example here.
https://www.youtube.com/watch?v=_B83CPqX-N4
I'm pretty sure I did all the steps, but for some reason my project is not running. I'm thinking there is a 32-bit or 64-bit issue lurking in here somewhere.
Here's my error message.
SSIS package "C:\Users\Ryan\Documents\Visual Studio 2010\Projects\Loop through Multiple Excel sheets and load them into a SQL Table\Integration Services Project1\Package.dtsx" starting.
Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
Error: 0xC0209303 at Package, Connection manager "Excel Connection Manager": The requested OLE DB provider Microsoft.ACE.OLEDB.12.0 is not registered. If the 64-bit driver is not installed, run the package in 32-bit mode. Error code: 0x00000000.
An OLE DB record is available. Source: "Microsoft OLE DB Service Components" Hresult: 0x80040154 Description: "Class not registered".
Error: 0xC001002B at Package, Connection manager "Excel Connection Manager": The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
For more information, see http://go.microsoft.com/fwlink/?LinkId=219816
Error: 0xC020801C at Data Flow Task, Excel Source [2]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0209303.
There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error: 0xC0047017 at Data Flow Task, SSIS.Pipeline: Excel Source failed validation and returned error code 0xC020801C.
Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
SSIS package "C:\Users\Ryan\Documents\Visual Studio 2010\Projects\Loop through Multiple Excel sheets and load them into a SQL Table\Integration Services Project1\Package.dtsx" finished: Failure.
The program '[5392] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
I have 32-bit Excel and 64-bit SQL Server. Is that the issue? Can someone tell me what's wrong here?
Thanks!!
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Sa-weeettttttt!! Thanks. I figured that's what it was. For the benefit of others, this link shows you exactly how to make the modification recommended above.
http://help.pragmaticworks.com/dtsxchange/scr/FAQ%20-%20How%20to%20run%20SSIS%20Packages%20using%2032bit%20drivers%20on%2064bit%20machine.htm
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
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.
ThanksYou 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. -
I need to loop through 1 table and read another until a value changes
i need to read a table and sum the quantity field until a reason code changes. how do I go about doing this?
sort itab by reasoncode.
Loop at itab.
quantiy = quanity + itab-quantity.
at end of reasoncode.
jtab-reasoncode = itab-reasoncodee.
jtab-sum = quantity.
append jtab.
clear quantity.
endat
endloop.
or
sort itab by reasoncode.
loop at itab.
at end of reasoncode.
sum.
jtab = itab.
append jtab.
endat.
endloop.
or
let us say itab and jtab are two tables and you want to loop through itab and read jtab for reasoncodes.
if jtab has only one entry for each entry in itab then use read else use loop.
loop at itab.
loop at jtab where reasoncode = itab-reasoncode.
quantiy = quantiy + jtab-quanity.
endloop.
endloop.
or
loop at itab.
read table jtab with key reasoncode = itab-reasoncode.
if sy-subrc eq 0.
endif
endloop. -
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.... -
GeoRaster- loop through each cell and execute spatial query?
Hi,
So what I want to do is, to loop through each cell in a raster and get the ground x,y coordinates. Then based on the x,y value I want to execute a query on a vector layer.
My question is, how do I find each cell coordinate? That I will then use with SDO_GEOR.getModelCoordinate to get the ground coordinates, query vector, etc...
Thanks.I am not sure what you want to do. Why not just use the spatial extent of the GeoRaster object?
Anyway, say sdo_geor.getULTCoordinate returns (r0, c0, b0), and sdo_geor.getSpatialDimSizes returns (rows, cols). The range of the cell coordinates (at the original image level) are:
row: r0 -- r0+rows-1
column: c0 -- c0+cols-1
Regards,
Terry
Maybe you are looking for
-
How do I book mark a page in a downloaded book?
I downloaded this book in PDF form but I cannot bookmark the last page I read so I have to constantly scroll through all the read material to try and find my place. This is a real pain. I cannot get the usual tool page of Adobe so I could even high
-
New Mac, Windows Partition Disappears
I just transferred all of my data from my Intel iMac to my new MacBook Pro by a firewire cable, and everything went off without a hitch except for one thing. I had a 30 GB Windows partition on my Mac, and when I click the alias for it now, it asks fo
-
Hi All We tested JMS receiver CC in SP 12. Its not working. We are getting "JMS error occurred while processing message 'efb85e80-2bd8-11dc-982f-0016357374fe'; error mesage: MQJMS2007: failed to send message to MQ" Any one worked with new SP JMS rece
-
Can't install because of Administrator Password not working
Hi--I can't install anything because my administrator password is not accepted. I get a message that says something like this software requires Administrator or higher level privileges. I've checked it under "Accounts" in System Preferences. I've eve
-
How can I upgrade to Lion OS X if my computer is version 10.4.11
How can I upgrade my MacMini version 10.4.11 to the new Lion OS X so i can update my iPhone 4?