Splitting a list (loop and insert)
I have a text file with about 65000 records to be looped and
inserted into a
database. I am using cfhttp to read the list and turn it into
a query. I am
then using that query to loop and insert the records into a
database.
However, its too large and the server is timing out. Is there
a break the
list into 2 pieces and do it in serial?
I am using:
<cffunction name="getResidential" access="private"
returntype="void"
output="false" hint="">
<cfargument name="ResFile" type="string"
required="yes">
<cfhttp timeout="6600"
url="
http://www.mywebsite.com/assets/property/#ResFile#"
method="GET"
name="Property" delimiter="|" textqualifier=""
firstrowasheaders="yes" />
<cfloop query="Property">
<cfquery name="loopProperty" datasource="bpopros">
INSERT STATEMENT HERE
</cfquery>
</cfloop>
</cffunction>
Is it possible to do something like:
Function 1
<cfloop from="1" to="40000" index="i">
</cfloop>
Function 2
<cfloop from="40001" to="#Query.RecordCount#"
index="i">
</cfloop>
Any ideas? Thanks
Wally Kolcz
MyNextPet.org
Founder / Developer
586.871.4126
I like your second solution, but wouldn't I need access to
the actual web
server? I need to do this on hosting. I am downloading the
files from a Real
Comp and then looping the data into my client's database for
searching. I
wanted to just use the files as a flat database and just
query or query off
of it, but there is a new file everyday. Only one update
(Sunday) is the
master list of 45-60k records. All the rest (Mon-Sat) are
just small
updates.
"Dan Bracuk" <[email protected]> wrote in
message
news:fdrgde$6qu$[email protected]..
> It's possible, but it's a better idea to look for ways
to do it without
> cold
> fusion.
>
> Food for thought, I have a requirement to move data from
one db to
> another. I
> use Cold Fusion to query the first db, output to text,
and ftp the text
> files
> to another server. I also have a scheduled job that
looks for these text
> files
> and loads them into db2.
>
Similar Messages
-
Hi,
I have requirement in Sp Designer 2010,Get List item URL and insert in another list as one column value.When open another list and click on same item column entry url will show the parent item information.
Here i have create work flow and insert item URL in another list but cant find appropriate item url information.I can easily make item url link through String builder in mail body with using current id and predefine link,but
when try to insert the same type of item link in another list where i cant find string builder for create custom url link,only get valur of Path,URL,Absolute URL and Relative server URL,all these links or not provide me exact
item link dispaly information.
So I opened SharePoint Designer and start creating the workflow associated to the list.
As there is some Field from source related to current item URL I start using it
Encoded Absolute URL – this one should be the one to use
Server Relative URL
URL Path
Unfortunately, none of these options were providing the correct link. Indeed, these options are providing an incorrect path:
Encoded Absolute URL
http://wfe1/Lists/bpf/1_.000
Server Relative URL
/Lists/bpf/1_.000
URL Path
/Lists/bpf/1_.000
As you can see, the item URL is composed by an ID while it should be http://wfe1/Lists/bpf/dispform.aspx?id=1
Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Share Point Application Developer,TCSUnfortunately, [%Current Item:URL%] doesn't seem to be available from a "Site Workflow" associated to a List. I'm finding less advantages to doing a "Site Workflow" when I don't necessarily need to. One problem is the workflow is initiating
twice. I'm thinking I should have just created the workflow as a a "List Workflow."
I am going to try "Association Columns" -- that may work. Anyone have other suggestions? -
Split one column value and insert into multiple columns
hi
am new to plsql .
i want to split a characters from one column and insert into multiple columns
i tried used substr function the symbol ',' vary his place dynamically ,so i can't apply substr function.
for eg: before split
col1 :
col2 :
col3 :
col4 :
colu5: adsdf,fgrty,erfth,oiunth,okujt
after split
col1 :adsd
col2 :fgrty
col3 :erfth
col4 :oiunth
col5 : adsdf,fgrty,erfth,oiunth,okujt
can anyone help me
thanks
Edited by: 800324 on Dec 23, 2010 8:28 AM
Edited by: 800324 on Dec 23, 2010 8:36 AMHow about:
SQL> create table t
2 (col1 varchar2(30)
3 ,col2 varchar2(30)
4 ,col3 varchar2(30)
5 ,col4 varchar2(30)
6 ,col5 varchar2(30)
7 );
Table created.
SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt');
1 row created.
SQL> insert into t (col5) values ('x,y');
1 row created.
SQL> insert into t (col5) values ('a,b,c,d');
1 row created.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf,fgrty,erfth,oiunth,okujt
x,y
a,b,c,d
3 rows selected.
SQL>
SQL> merge into t a
2 using ( with t1 as ( select col5||',' col5
3 from t
4 )
5 select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1
6 , substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2
7 , substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3
8 , substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4
9 , rtrim(col5, ',') col5
10 from t1
11 ) b
12 on ( a.col5 = b.col5 )
13 when matched then update set a.col1 = b.col1
14 , a.col2 = b.col2
15 , a.col3 = b.col3
16 , a.col4 = b.col4
17 when not matched then insert (a.col1) values (null);
3 rows merged.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf fgrty erfth oiunth adsdf,fgrty,erfth,oiunth,okujt
x y x,y
a b c d a,b,c,d
3 rows selected.
SQL> Assuming you're on 9i... -
Procedure with multiple Loops and Insert into table
Hello All,
I am trying to create the Procedure to create a new table for our DWH.
In this Case, I have 2 tables and I need to create Loop for each value from one table and get the respective data from second table based on first table data.
Please find the below example:
First table: TABLE_A
X Y Z
1 a 10
1 b abc
1 c xy
1 e $
2 a 11
2 c asf
2 d tal
2 f ghs
Second Table: TABLE_B
A B C D E F
10 abc xy sd ew 100
10 jhy xy sd ew 100
11 ght asf tal ss ghs
11 ght afr tal ss ghs
O/P Table from Procedure: OUTPUT_TABLE
A B C D E F X
10 abc xy sd ew 100 1
11 ght asf tal ss ghs 2
Business Logic In the Procedure:
CREATE OR REPLACE PROCEDURE OP_TAB_PROCEDURE IS
BEGIN
-- First get the DISTINCT values from the TABLE_A to generate the Loop
FOR ID (SEELCT DISTINCT X FROM TABLE_A_
LOOP
-- For Each ID get the Y ,Z values from TABLE_A other than $ in Z
TEMP:
SELECT Y, Z FROM TABLE_A WHERE X = ID.X AND Z <> '$' ;
Based on above SELECT statement, I need to construct dynamic SQL query to get the data from TABLE_B
OP_EACH_ID:
SELECT * , ID.X AS X FROM TABLE_A WHERE [In this place I need generate sql cond dynamically. For Example, For X=1 in TABLE_A , the where cond must A=10 AND B='abc' AND C='xy'
For X=2 , the Where cond must be WHERE A=11 AND C='asf' AND D='tal' AND F='ghs']
-- I need to INSERT all the values from OP_EACH_ID into OUT_PUT_TABLE
END LOOP ;
END;
I am new to PL/SQL , so please help me on the above case.duplicate post
-
Enable the field in the list display and insert the new value and save it.
Hi
In a report when I am in third list using ALV a field which is disabled should be enabled and have to insert the new value in it and save.
please tell me how to do it using classes and methods and also using ALV's.
Promise to reward points.
Regards
MacHi madan,
Please find the code sample,
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/79b5e890-0201-0010-7f8e-b7c207edf7c2
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ec31e990-0201-0010-f4b6-c02d876ce033
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/117beb90-0201-0010-67a8-fff1482209ae
Regards
Kathirvel -
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 -
The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
pear to be working or at least I am not getting any indication on the inidcator.
Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
Attachments:
regulation_tester_7_loops.vi 244 KBI didn't really have time to dig in and understand your program in depth,
but I have a few tips for you that might things a bit easier:
- You use local variables excessively which really complicates things. Try
not to use them and it will make your life easier.
- If you flowchart the design (very similar to a dataflow diagram, keep in
mind!) you want to gather data, calculate a value from that data, store the
calculation in an array, and loop while the time is in a certain range. So
theres really not much need for a sequence as long as you get rid of the
local variables (sequences also complicate things)
- You loop again if timepassed+1 is still less than some constant. Rather
than messing with locals it seems so much easier to use a shiftregister (if
absolutely necessary) or in this case base it upon the number of iterations
of the loop. In this case it looks like "time passed" is the same thing as
the number of loop iterations, but I didn't check closely. There's an i
terminal in your whileloop to read for the number of iterations.
- After having simplified your design by eliminating unnecessary sequence
and local variables, you should be able to draw out the labview diagram.
Don't try to use the "insert into array" vis since theres no need. Each
iteration of your loop calculates a number which goes into the next position
of the array right? Pass your result outside the loop, and enable indexing
on the terminal so Labview automatically generates the array for you. If
your calculation is a function of previous data, then use a shift register
to keep previous values around.
I wish you luck. Post again if you have any questions. Without a more
detailed understanding of your task at hand it's kind of hard to post actual
code suggestions for you.
-joey
"nelsons" wrote in message
news:[email protected]...
> how do I create a 1d array that takes a single calculation and insert
> the result into the first row and then the next calculation the next
> time the loop passes that point and puts the results in thsecond row
> and so on until the loop is exited.
>
> The attached file is work inprogress, with some dummy data sp that I
> can test it out without having to connect to equipment.
> The second tab is the one that I am having the problem with. the
> output array from the replace element appears to be starting at the
> index position of 1 rather than 0 but that is ok it is still show that
> the new data is placed in incrementing element locations. However the
> main array that I am trying to build that is suppose to take each new
> calculation and place it in the next index(row) does not appear to be
> working or at least I am not getting any indication on the inidcator.
>
> Basically what I am attempting to do is is gather some pulses from
> adevice for a minute, place the results for a calculation, so that it
> displays then do the same again the next minute, but put these result
> in the next row and so on until the specifiied time has expired and
> the loop exits. I need to have all results displayed and keep building
> the array(display until, the end of the test)Eventually I will have to
> include a min max section that displays the min and max values
> calculated, but that should be easy with the min max function.Actually
> I thought this should have been easy but, I gues I can not see the
> forest through the trees. Can any one help to slear this up for me. -
Hi
I am inserting bulk of records to temp tables from flat file using control files and sqlloader. There are million of records in a file. Someone suggested me to split records in the file and insert.
Can anyone suggest an optimum number of records per insert. ie 100,00 / 500,00 / ..No need to split files, that's just a waste of time.
You could try using the direct loading at the top of your control file....
OPTIONS (DIRECT=TRUE)
UNRECOVERABLE
LOAD DATA
INFILE *
.Which bypasses all the transaction log and triggers etc. and gets the data in nice and fast. We've use this method to load millions of records in a matter of seconds. -
Split Oracle 11g Table Partition and Insert new rows
Hi,
I have a doubt that i would like to be clarified. I need to split a partition of a table with more than 800 Million records, but at the same time (during the split operation) i need to insert new records (not in the partition that is being splited). Is there any problem/risk doing this? Is the insert ETL process going to fail ?
Thanks in advance
Greetings.
Nuno
Edited by: user13512889 on 1/Set/2011 3:25Hi Enrique,
Thanks for posting in MSDN.
Based on the description, you want to modify the formula for the A1 and B1 cell when you insert a new rows.
Yes, we can use Worksheet.Change to dermin the change of data on the worksheet then we can modify the formula as we wanted. Here is a sample for your reference:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Range("A1").Formula = "=MAX($A2:$A" & Me.UsedRange.Rows.Count & ")"
Me.Range("B1").Formula = "=MIN($B2:$B" & Me.UsedRange.Rows.Count & ")"
End Sub
You can more detail about Excel VBA developing from link below:
Getting Started with VBA in Excel 2010
Welcome to the Excel 2013 developer reference
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Access data from from two lists based on lookup columns and insert into another
Hi,
I am new in SharePoint and is stuck in some problem.
I want to insert data in to a list by fetching data from 2 lists.
The scenario is :
List A Columns : EmployeeName, EmployeeID, EmployeeSalary
List B Columns : DepartmentName, EmployeeID, ManagerID
EmployeeID is lookup column
I want to fetch data from these 2 lists and insert data into another list:
List C Columns: EmployeeName, EmployeeSalary, DepartmentName
Can someone please explain me all the possible approaches to do the above taskIf ListA and ListB are the lists that you created, it would be better to generate the lists data into one list not seperate lists, as they both represents the property information of one employee.
If they are existing lists, you may have following considerations:
1. if you are a programmer, it would be easier to have a lookup column at ListA, to generate the EmployeeName, EmplyeeSalary, then using ItemAdded event, to generate the DepartmentName column based on EmployeeID column.
2. have a lookup column look at ListA, use workflow, set when item is created, start the workflow automatically, then in the workflow, find ListB related item based on EmployeeID column, to set the DepartmentName column, SharePoint designer workflow
set Item Value activity can do this work, you can research to find more information about how to do this.
Thanks,
Qiao Wei <br/> My blog:http://blog.goobol.com -
How to split the blob byte array and insert in oracle
how to split the blob byte array and insert in oracle
I am having a string which is of more than lenght 4000 so i am using BLOB datatype as input to get the string.
need to split the blob in oracle and store in the different column
The string is of bytearray i need to strore it in each column based on the byte array.this will be my input i need to split the above and store it in different columns in a table.
for spliting say
Column1 -1 byte
Column2-3 byte
Column3-5 byte
ColumnN-5 byte
Table will have corresponding data type
Column1 - number(10,2)
Column2 - Float
Column3 - Float
ColumnN-Float
here Column2 datatype is float but it will always have 3 byte information.
where as Column3 datatype is also float but it will always have 5 byte information.
Say N is Column 120 -
By using inspector, i found a way to create and insert a scrolldown list (*) in a cell ; however it can only be done one line at a time .what i am looking for is to create a bigger scrolldown list ( from 30 to 100 lines ) and in excel we can do it by copy and paste from an other doc...there must be a way with Numbers !!! any ideas ?
(*)...go to inspector/4th icon to he left/format/local menu/and then input the list one by one...and it creates a scrolldown list where you cursor was located in numbers.
please help....If you need to use this kind of objects, my guess is that it would be better to use an other application like libreOffice.
At an user request, I wrote an AppleScript grabbing the list from a table embedded in the Numbers document.
Here is an enhanced version.
--{code}
--[SCRIPT fake-scrolldown-list]
Enregistrer le script en tant que Script : fake-scrolldown-list.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications :Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner une cellule dans une table d'un document Numbers.
Aller au menu Scripts , choisir Numbers puis choisir “fake-scrolldown-list”
Le script extrait la liste d'articles de la table « la_liste » de la feuille contenant la table ci-dessus.
Il demande de choisir un article puis dépose celui-ci dans la cellule sélectionnée.
ATTENTION : À la demande d'un utilisateur, Le script utilise un nom de table localisé.
Je n'aime pas cela parce que de ce fait, lorsque le script est utilisé sur un système Français,
il requiert une table nommée "la_liste" mais lorsqu'il est utilisé sur un système Anglais il requiert la table "the_list".
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: fake-scrolldown-list.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell in a table of a Numbers document.
Go to the Scripts Menu, choose Numbers, then choose “fake-scrolldown-list”
The script extract the list of allowed items from the table “the_list” which must sit in the same sheet that the table embedding the selected cell.
It urge to choose an item then insert it in the selected cell.
CAUTION : I use different names for the required table according to the language in use on user request.
I dislike this feature because a document built by a French user sent to an English one will fail.
On the French system the script ask for the table "la_liste" but it ask for the table "the_list" on an English system.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/12/31
--=====
on run
local dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2, myListe, maybe
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName
Extract the list of allowed values from the dedicated table *)
if my parleAnglais() then
"the_list"
else
"la_liste"
end if
tell table result
set myListe to value of every cell of column 1
end tell
set maybe to choose from list myListe
If we select the Cancel button, exit silently *)
if maybe is false then error number -128
Fill the selected cell with the choosed value *)
tell table tName
set value of cell rowNum1 of column colNum1 to (item 1 of maybe as text)
end tell
end tell -- Numbers…
end run
--=====
set { dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
on get_SelParams()
local d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2
tell application "Numbers" to tell document 1
set d_Name to its name
set s_Name to ""
repeat with i from 1 to the count of sheets
tell sheet i to set maybe to the count of (tables whose selection range is not missing value)
if maybe is not 0 then
set s_Name to name of sheet i
exit repeat
end if -- maybe is not 0
end repeat
if s_Name is "" then
if my parleAnglais() then
error "No sheet has a selected table embedding at least one selected cell !"
else
error "Aucune feuille ne contient une table ayant au moins une cellule sélectionnée !"
end if
end if
tell sheet s_Name to tell (first table where selection range is not missing value)
tell selection range
set {top_left, bottom_right} to {name of first cell, name of last cell}
end tell
set t_Name to its name
tell cell top_left to set {row_Num1, col_Num1} to {address of its row, address of its column}
if top_left is bottom_right then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
tell cell bottom_right to set {row_Num2, col_Num2} to {address of its row, address of its column}
end if
end tell -- sheet…
return {d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end tell -- Numbers
end get_SelParams
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) samedi 31 décembre 2011
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My iDisk is : http://public.me.com/koenigyvan
Please : Search for questions similar to your own before submitting them to the community
For iWork's applications dedicated to iOS, go to :
https://discussions.apple.com/community/app_store/iwork_for_ios -
Split data and insert into different rows
I have a string like 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi,"
I have created a single column table
I have to extract data from first untill comma(,) occurs and insert into the table like the following
sfdsdf
sfdsf
sfsd
qweqeqw
iuoi
Please help me how to do itOr a Single SQL query
SELECT trim(',' from DECODE(ROWNUM,1,SUBSTR(STR,1,INSTR(STR,',',1)),
LENGTH(STR)-LENGTH(REPLACE(STR,','))+1,SUBSTR(STR,INSTR(STR,',',-1,1)),
SUBSTR(STR,INSTR(STR,',',1,ROWNUM-1), INSTR(STR,',',1,ROWNUM)-INSTR(STR,',',1,ROWNUM-1))
)) STR1
FROM (SELECT 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi' STR FROM DUAL),ALL_TABLES
WHERE ROWNUM <= LENGTH(STR)-LENGTH(REPLACE(STR,','))+1
ORDER BY ROWNUM -
Associative array comparison and INSERT upon IF condition
Hi Guys,
I have written this pl sql code to identify non existing sellers and insert their sales channel information into the dimension table (dimensional table update).
Somehow,......nothing is inserted and this script runs for 12 hours+ without any result. the sql autotrace shows no result and the explain plan (button on sql developer throws upon clicking "missing keyword". I have no
information what is going on/wrong. Does anyone spot an error?
UNDEFINE DimSales;
UNDEFINE FactTable;
DEFINE DimSales = 'testsales';
DEFINE FactTable = 'testfact';
DECLARE
v_SellerNo VarChar(9);
v_error_code T_ERRORS.v_error_code%TYPE;
v_error_message T_ERRORS.v_error_message%TYPE;
TYPE assoc_array_str_type1 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
v1 assoc_array_str_type1;
TYPE assoc_array_str_type2 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
v2 assoc_array_str_type2;
BEGIN
--Collect all distinct SellerNo into associative array (hash table)
select distinct SellerNo bulk collect into v1 from &FactTable;
select distinct seller_id bulk collect into v2 from &DimSales;
v_SellerNo := v1.first;
loop
exit when v1 is null;
--1 Check if v_SellerNo already exists in DIM_Sales (if NOT/FALSE, its a new seller and we can insert all records for that seller
if (v2.exists(v_SellerNo)=false) THEN
INSERT INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
(SELECT DISTINCT trim(leading '0' from RS||GS) ,REG BVL,DS,VS,RS,GS,VK from &FactTable where SellerNo =v_SellerNo);
--ELSE
end if;
v_SellerNo := v1.next(v_SellerNo);
end loop;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
--v_error_code := SQLCODE
--v_error_message := SQLERRM
--INSERT INTO t_errors VALUES ( v_error_code, v_error_message);
END;
---------------------------------------------------------------Distinct clause requires a sort. Sorts can be very expensive.
Bulk collects that are not constrained in fetch size, can potentially fetch millions of rows - requiring that data to be wholly read into server memory. I have seen how this can degrade performance so badly that the kernel reboots the server.
Using PL/SQL loops to process and insert/update/delete data is often problematic due to its row-by-row approach - also called slow-by-slow approach. It is far more scalable letting SQL do the "loop" processing, by using joins, sub-selects and so on.
Where the conditional processing is too complex for SQL to handle, then PL/SQL is obviously an alternative to use. Ideally one should process data sets as oppose to rows in PL//SQL. Reduce context switching by using bulk fetches and bulk binds.
But PL/SQL cannot execute in parallel as the SQL it fires off can. If after all the optimisation, the PL/SQL process still needs to hit a million rows to process, it will be slow irrespective of how optimal that PL/SQL approach and design - simply because of the number of rows and the processing overheads per row.
In that case, the PL/SQL code itself need to be parallelised. There are a number of ways to approach this problem - the typical one is to create unique and distinct ranges of rows to process, spawn multiple P/SQL processes, and provide each with a unique range of rows to process. In parallel.
So you need to look close at what you are trying to achieve, what the workloads are, and how to effectively decrease the workloads and increase the processing time of a workload.
For example - finding distinct column values. You can pay for that workload when wanting that distinct list. And each time afterward repeat that workload when wanting that distinct list. Or you can pay for that workload up-front with the DML that creates/updates those values - and use (for example) a materialised view to maintain a ready to use distinct list of values.
Same workload in essence - but paying once for it and up-front as oppose to each time you execute your code that needs to dynamically build that distinct list.
Kent Crotty did tests and showed stunning performance improvements with bulk collect and forall, up to 30x faster:Bulk processing is not a magical silver bullet. It is a tool. And when correctly use, the tool does exactly what it was designed to do.
The problem is using a hammer to drive in screws - instead of a screwdriver. There's nothing "stunning" about using a screwdriver. It is all about using the correct tool.
If the goal of the swap daemon is to free up "idle" chunks of memory, and try to use that memory for things like file cache instead, what does that have to do with bulk processing?The swap daemon reads virtual memory pages from swap space into memory, and writes virtual pages from memory to swap space.
What does it have to do with bulk processing? A bulk fetch reads data from the SGA (buffer cache) into the PGA (private process memory space). The larget the fetch, the more memory is required. If for example 50% of server memory is required for a bulk collection that is 2GB in size, then that will force in-use pages from memory to swap space.. only to be swapped back again as it is needed, thereby forcing other in-use pages to swap. The swap daemon will consume almost all the CPU time swapping hot pages continually in and out of memory. -
PL/SQL LOOP or INSERT MONTH
I have a table below that has START_DATE and END_DATE for each record but not individual row for each month. So, a record can have 6 months payment with start date - '20100101' to end_date 20100630.
I need to find out payment for each month for recon.
I want to add that month field and keep everything else exactly the same as what's in table.
For above example it should add
01-JAN-2010 ................................................ <--- everything else same
01-FEB-2010 ........................
|
|
|
01-JUN-2010 ..........................................................
The helpful fields are START_DATE, END_DATE, NO_OF_MONTHS1 and NO_MONTHS_2. Somethimes, NO_MONTH1 and NO_MONTHS_2 differ. Normally whe they differ, one is 00.
--oracle 10g
--DROP TABLE PAYMENTS;
CREATE TABLE PAYMENTS
CMPNY VARCHAR2,
S_ID VARCHAR2,
NO_MONTHS_1 VARCHAR2,
NO_MONTHS_2 VARCHAR2,
ADJ_CODE VARCHAR2,
START_DATE VARCHAR2,
END_DATE VARCHAR2,
AMOUNT NUMBER
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C002','S001','02','02','20','20090801','20100930','100');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C002','S002','02','02','20','20090801','20100930','100');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S002','01','01','12','20090101','20090131','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','00','04','18','20090101','20090430','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S003','00','02','12','20090501','20090731','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S004','01','01','12','20090101','20090131','50');
commit;
RESULTS should be something like
CREATE TABLE PAYMENTS1
ELIGIBLE_MONTH DATE,
CMPNY VARCHAR2,
S_ID VARCHAR2,
NO_MONTHS_1 VARCHAR2,
NO_MONTHS_2 VARCHAR2,
ADJ_CODE VARCHAR2,
START_DATE VARCHAR2,
END_DATE VARCHAR2,
AMOUNT NUMBER
commit;
--BELOW IS AN EXAMPLE OF HOW THE SOLUTION SHOULD COMEOUT FOR FIRST 3 RECORD IN ABOVE TABLE
---for first record in above table, it should create 6 rows, and apply eligible_month to it
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-JAN-2010','C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-FEB-2010','C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-MAR-2010','C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-APR-2010','C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-MAY-2010','C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-JUN-2010','C001','S001','06','06','20','20100101','20100630','30');
---IT SHOULD CREATE 4 ROWS
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-JAN-2009','C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-FEB-2009','C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-MAR-2009','C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-APR-2009','C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-AUG-2010','C002','S001','02','02','20','20100801','20100930','100');
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-SEP-2010','C002','S001','02','02','20','20100801','20100930','100');Hi,
788729 wrote:
I have a table below that has START_DATE and END_DATE for each record but not individual row for each month. So, a record can have 6 months payment with start date - '20100101' to end_date 20100630.
I need to find out payment for each month for recon.
I want to add that month field and keep everything else exactly the same as what's in table.
For above example it should add
01-JAN-2010 ................................................ <--- everything else same
01-FEB-2010 ........................
|
|
|
01-JUN-2010 ..........................................................This seems to be an easier variation of your last question:
Re: PL/SQL LOOP MONTH
You should have some idea about how to do it by now. Post your best attempt.
The helpful fields are START_DATE, END_DATE, NO_OF_MONTHS1 and NO_MONTHS_2. Somethimes, NO_MONTH1 and NO_MONTHS_2 differ. Normally whe they differ, one is 00.What is the role each of those columns plays in this problem? Which one(s) tell how many rows need to be inserted? Why are the others helpful?
>
>
--oracle 10g
--DROP TABLE PAYMENTS;
CREATE TABLE PAYMENTS
CMPNY VARCHAR2,
S_ID VARCHAR2,
NO_MONTHS_1 VARCHAR2,
NO_MONTHS_2 VARCHAR2,
ADJ_CODE VARCHAR2,
START_DATE VARCHAR2,
END_DATE VARCHAR2,
AMOUNT NUMBER
);Don't use VARCHAR2 columns to store dates; alwyas use DATE (or TIMESTAMP) columns.
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','06','06','20','20100101','20100630','30');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','04','04','12','20090101','20090430','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C002','S001','02','02','20','20090801','20100930','100');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C002','S002','02','02','20','20090801','20100930','100');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S002','01','01','12','20090101','20090131','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S001','00','04','18','20090101','20090430','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S003','00','02','12','20090501','20090731','50');
INSERT INTO PAYMENTS (CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('C001','S004','01','01','12','20090101','20090131','50');
commit;Thanks for posting the CREATE TABLE and INSERT statemnets.
RESULTS should be something like
CREATE TABLE PAYMENTS1
ELIGIBLE_MONTH DATE,
CMPNY VARCHAR2,
S_ID VARCHAR2,
NO_MONTHS_1 VARCHAR2,
NO_MONTHS_2 VARCHAR2,
ADJ_CODE VARCHAR2,
START_DATE VARCHAR2,
END_DATE VARCHAR2,
AMOUNT NUMBER
commit;
--BELOW IS AN EXAMPLE OF HOW THE SOLUTION SHOULD COMEOUT FOR FIRST 3 RECORD IN ABOVE TABLEWhy only 3? Post the results that you want from the sample data. If 3 rows is enough to show what the problem is, why did you post 8 rows above? If 8 rows give a better picture of the problem, why not show the results from 8 rows?
>
---for first record in above table, it should create 6 rows, and apply eligible_month to it
INSERT INTO PAYMENTS (ELIGIBLE_MONTH, CMPNY,S_ID,NO_MONTHS_1,NO_MONTHS_2, START_DATE, END_DATE,AMOUNT) VALUES ('01-JAN-2010','C001','S001','06','06','20','20100101','20100630','30');There are 8 columns listed before the VALUES keyword, but 9 values given after it.
There is no eligible_month column in paymemts. Did you mean payments<b>1</b>?
Do you want a query that produces these INSERT statements as strings, or do you actually want to populate payments1 (or payments)?
If you just want to populate a table, show the contents of the populated table in a form people can read and understand, for example:
ELIGIBLE_MONTH CMPNY S_ID NO_MONTHS_1 NO_MONTHS_2 START_DATE END_DATE AMOUNT
01-JAN-2010 C001 S001 06 06 20100101 20100630 30
01-FEB-2010 C001 S001 06 06 20100101 20100630 30
...When you post formatted text on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
Maybe you are looking for
-
Convert_otf in unicode system
Hello, we have switched a CRM4.0 system from non-unicode to unicode. In this context we became two problems with the result of the function module 'CONVERT_OTF'. We call the function Module following: call function 'CONVERT_OTF' exporting f
-
Will purchase items continue 2 download if I'm watching other stuff on TV?
I know that my iTunes Library will not sync to my TV until I stop watching something on it. Basically, no TV activity if I wanna sync. And since TV can function as an independent device sans Mac, I'm not sure whether if I can watch a TV show or
-
Organizing photos in events that match originals
I cleaned up(crop, delete bad ones, rename files) my photos in "events" but it didn't change in "originals". how do i get that to match?
-
As a number of Oracle Connections created - Performance Issue
Hello, We are using Oracle 9i as a backend and VB 6.0 as Frontend. For one client one connection will be opened in the Database Server, if 200 clients open the application then 200 connections will be opened in the Database Server, due to that perfor
-
What is the secret to creating 3D interactive objects?
Recently, I touched a "squishy" 3D object on a game on an iPad, and now I am wondering: What are these objects and what is the secret to creating them? I am interested in adding some inheritance to my current 2d sprite objects in Visual Studio. When