Is limiting needed in forall statements?
Hello,
Could you please help me understand what the advantage is (if any) of looping and limiting during forall updates? I saw this simplified version in one the programs here at work and don't understand what the looping and limiting is for.
declare
cursor c1 is
select column1, column2 from tablea;
type aaa is table of c1%rowtype;
var1 aaa;
begin
open c1;
loop
fetch bulk collect into var1 limit 2500;
forall i in var1.first .. var1.last
update tableb
set column2 = var1(i).column2
where column1 = var1(i).column1;
exit when var1.count < 2500;
end loop;
close c1;
end;
arizona9952 wrote:
Hello,
Could you please help me understand what the advantage is (if any) of looping and limiting during forall updates? I saw this simplified version in one the programs here at work and don't understand what the looping and limiting is for.The advantage is that you can control the amount of memory your process needs to consume (PGA). There is a finite amount on every system, the amount available to you will depend on a number of factors (do some research if you're interested in this).
In my opinion you should always be using LIMITs when performing bulk operations.
As an aside, the code you've posted could be done as a single UPDATE statement (or MERGE), in about 95% of the cases you'll be better off with a single SQL statement if you can get away with it.
Similar Messages
-
BULKING and FORALL statement does not pass values to non DML statements.
Hi
I've got million rows that i need to manapulate and insert into various procedures depending on the bussiness rule to be applied, but my dilemma is that the BULIKNG with a combination of a FORALL statement its not compatible(only considers straightforward DML calls) or the the FORALL does not like other SQL statements or calls as it prefers only DML's.
Below is code fragment that is problamatic as the compiler keeps sending me this error: PLS-00201: identifier 'INDX' must be declared
I want to manupulate data on the implicity cursor and call a procedure to do other stuff which don't use INSERT/DELETE or UPDATE statements.
Declare
TYPE tab_person_id is of table of number(15);
l_person_id tab_person_id;
BEGIN
SELECT person_id
BULK COLLECT INTO l_person_id
FROM person_details; /*-Million records-*/
FORALL indx IN l_tdtl.FIRST..l_tdtl.LAST
pj_pkg.ins_intf
(p_user => p_user,
p_typ_cd => '00',
p_person_id => l_person(indx)
Commit;
END;
How do I pass this value 'l_person(indx)' on the package procudure ?
Thanks
Amos@prabodh:
SQL> declare
2 TYPE tab_person_id is of table of number(15) index by pls_integer;
3 begin
4 null;
5 end;
6 /
TYPE tab_person_id is of table of number(15) index by pls_integer;
ERROR at line 2:
ORA-06550: line 2, column 23:
PLS-00103: Encountered the symbol "OF" when expecting one of the following:
( array limited new private range record VARRAY_ char_base
number_base decimal date_base clob_base blob_base bfile_base
table ref object fixed varying opaque sparse
The symbol "OF" was ignored.Check What you are posting.
@ qwestion: What is your Database Version? It is a implementation restriction. -
How can I run two DML in one FORALL statement?
How can I run 1) select 2) update in one FORALL for each item as below?
OPEN FXCUR;
LOOP
FETCH FXCUR BULK COLLECT INTO v_ims_trde_oids LIMIT 1000;
EXIT WHEN v_ims_trde_oids.COUNT() = 0;
FORALL i IN v_ims_trde_oids.FIRST .. v_ims_trde_oids.LAST
SELECT EXTRACTVALUE(XMLTYPE(CNTNT),'/InboundGTMXML/ProcessingIndicators/ClientCLSEligibleIndicator') INTO v_cls_ind
FROM IMS_TOMS_MSGE WHERE ims_trde_oid = v_ims_trde_oids(i);
IF v_cls_ind IS NOT NULL THEN
v_cls_ind := '~2136|S|'||v_cls_ind||'|';
UPDATE ims_alctn_hstry SET CHNGE_DATA_1 =concat(CHNGE_DATA_1,v_cls_ind)
WHERE ims_trde_hstry_id = (select max(ims_trde_hstry_id) from ims_alctn_hstry where ims_trde_oid=v_ims_trde_oids(i));
DBMS_OUTPUT.PUT_LINE('Trade oid: '||v_ims_trde_oids(i)||' CLS Eligible Indicator: '||v_cls_ind);
END IF;
END LOOP;
CLOSE FXCUR;Your help will be appreciated.
Thanks
Edited by: PhoenixBai on Aug 6, 2010 6:05 PMI came through this forum while googling on the issue of 'using two DML's in one FORALL statement.
Thanks for all the useful information guys.
I need to extend this functionality a bit.
My present scenario is as follows:
FOR I in 1..collection1.count Loop
BEGIN
insert into tab1(col1)
values collection1(I) ;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR('ERROR AT'||collection1(I));
END;
BEGIN
UPDATE tab2
SET col1 = collection1(I);
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR('ERROR AT'||collection1(I));
END;
commit;
END LOOP;
I need to use the FORALL functionality in this scenario, but without using the SAVE EXCEPTIONS clause keeping in mind that I also need to get value in the
collection that led to the error.Also, the each INSERT statement has to be followed by an UPDATE and then the cycle goes on(Hence I cannot use 2 FORALL statements for INSERT and UPDATE coz then all the INSERT will be performed at once and similarly the UPDATEs). So I created something like this:
DECLARE
l_stmt varchar2(1000);
BEGIN
l_stmt := 'BEGIN '||
'insert into tab1(col1) '||
'values collection1(I) ; '||
'EXCEPTION '||
'WHEN OTHERS THEN '||
'RAISE_APPLICATION_ERROR(''ERROR AT''|| :1); '||
'END; '||
'BEGIN '||
'UPDATE tab2 '||
'SET col1 = :1; '||
'EXCEPTION '||
'WHEN OTHERS THEN '||
'RAISE_APPLICATION_ERROR(''ERROR AT''|| :1); '||
'END;'
FORALL I in 1..collection1.count
EXECUTE IMMEDIATE l_stmt USING Collection1(SQL%BULK_EXCEPTIONS(1).ERROR_INDEX);
END;
Will this approach work? Or is there any better aproach to this? I am trying to avoid the traditional FOR ..LOOP to achieve better performance of query -
Update query using FORALL statement
Hi ALL,
I have two tables Table: Mater_A(20 Cloumns) and Temp_A(20 Columns).
Both are almost identical. The Master_A is master table that has to be updated daily based on the temporary table Temp_A.
Everyday , i expect around 100000 records(same records with modified valus ) in Temp_A that has to be updated in Master_A. So i have to make the query as optimized as possible.
For this,I have created a cursor that has all records from table Temp_A.
Then i am using FORALL statement to update the data. But it throws exception something like that:
Error: PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
Error: PLS-00382: expression is of wrong type
It states that i have to create a separate type for each column that i want to update.
I have created procedure like this:
Open C_Temp_A;
Loop
Fetch C_Temp_A Bulk Collect into v_C_Temp_A limit 5000;
Exit When C_Temp_A%NOTFOUND;
Begin
ForAll i in v_C_Temp_A.first.. v_C_Temp_A.Last
Update Master_A mst Set mst.Column2= v_C_Temp_A(i).t_Column2,
mst.Column3= v_C_Temp_A(i).t_Column3,mst.Column4= v_C_Temp_A(i).t_Column4........to all columns
where mst.Column1= v_C_Temp_A(i).t_Column1;
End;
End Loop;
Close C_Temp_A;
Please help me to solve this or suggest me any other alternative to reduce the processing time.Why cant you use like :(Or I misread?)
SQL> select * from a;
ID C2
1 100
SQL> select * from b;
ID C2
1 1000
SQL> merge into b
2 using(select * from a) a
3 on (b.id = a.id)
4 when matched then
5 update
6 set b.c2 = a.c2;
1 row merged.
SQL> select * from b;
ID C2
1 100 -
Need a select statement to trim a single value out of a column
I have a column which can and does contain single and multiple values. For instance, there could be a single value, value, or it could look like this value, value, with there being a comma and a space between the two values. I need a select statement that will only and always return the value to the left or in the case of a single value with no comma, just that value. TIA
If your single value has no comma, just the value, then you need an extra DECODE to resolve that case.
SELECT DECODE(INSTR(text,','),0,text,SUBSTR(text,1,INSTR(text,',')-1))
FROM (SELECT 'value1' text
FROM dual
UNION
SELECT 'value2, value3'
TEXT from dual)TTFN
John -
Limits to the SQL Statement when creating External Dictionaries
Limits to the SQL Statement when creating External Dictionaries
Does RC not provide the ability to concatenate multiple db columns into a single dictionary field? When trying a query like: SELECT Col1 + Col2 AS NewCol1 FROM Tbl1 we get an error("Unknown internal error") after clicking to save/create the new dictionary. This is on version 2008.3What if you created a buffer table in your external database, that is populated by your field-merging query, and then invoke that from Newscale? The temporary table would be updatable by newscale (although, presumably, you wouldn't actually have newscale update it), so then it'd accept that connection.
For example, I think you could do something like that by creating a View in MS SQL Server. Likewise, in other database brands you could create a Trigger that would update the buffer table each time data in the real tables are changed. -
Binds collections and forall statement
version 9.2.0.6
I would like to make this more dynamic in that the collection cList can be used only once and be used by all bind variables. The variable stmt would be dynamically generated in that case it would insert into any number of tables.
Can this be done?
Is this feature available in a newer version of Oracle?
create table d2 nologging as
select
rownum rn
,substr(dbms_random.string('x',5),1,10) v1
,sysdate d1
,round(dbms_random.value(1,10)) n1
,substr(dbms_random.string('x',5),1,10) v2
,rpad(' ',4000,' ') as concat
from dual connect by level <= 100;
-- no rows for our test
create table d3 nologging as
select
from d2 where 1 = 2;
-- setup for our test
update d2
set image = rpad(nvl(to_char(rn),' '),10,' ')
|| rpad(nvl(v1,' '),20,' ')
|| rpad(nvl(to_char(d1,'DD-MON-YYYY HH24:MI:SS'),' '),34,' ')
|| rpad(nvl(to_char(n1),' '),10,' ')
|| rpad(nvl(v2,' '),10,' ')
-- test got all locations right
select
to_number(rtrim(substr(image,1,10)))
,rtrim(substr(image,11,20))
,to_date(rtrim(substr(image,30,34)),'DD-MON-YYYY HH24:MI:SS')
,to_number(rtrim(substr(image,65,10))) AS n1
,rtrim(substr(image,75,10))
from d2;
-- here is where we do the work
declare
type charList is table of varchar2(4000);
cList charList;
d2l d2_list;
errors NUMBER;
dml_errors EXCEPTION;
PRAGMA exception_init(dml_errors, -24381);
sqlStmt varchar2(32000);
cursor cur is select image from d2;
bcLimit number := 23;
begin
sqlStmt := 'insert into d3 (rn,v1,d1,n1,v2)'
|| 'values (to_number(rtrim(substr(:a,1,10)))
,rtrim(substr(:a,11,20))
,to_date(rtrim(substr(:a,30,34)),''DD-MON-YYYY HH24:MI:SS'')
,to_number(rtrim(substr(:a,65,10)))
,rtrim(substr(:a,75,10)))';
open cur;
loop
fetch cur bulk collect into cList limit bcLimit;
exit when cList.count = 0;
begin
-- very very unfortunately the code is unable to have one using clause variable be applied to all bind variables
-- note the number of cList uses having the bind variables all name the same does not help
-- using only one gets a ORA-1008 error :(
FORALL i IN cList.FIRST..cList.LAST SAVE EXCEPTIONS execute immediate sqlstmt using cList(i),cList(i),cList(i),cList(i),cList(i);
-- FORALL i IN cList.FIRST..cList.LAST SAVE EXCEPTIONS execute immediate sqlstmt using cList(i); --< DOES NOT WORK :( I WISH IT WOULD!
EXCEPTION
WHEN dml_errors THEN
errors := SQL%BULK_EXCEPTIONS.COUNT;
dbms_output.put_line('number of errors is ' || errors);
FOR i IN 1..errors LOOP
dbms_output.put_line('Error ' || i || ' occurred during iteration ' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
dbms_output.put_line('Could not insert ' || cList(SQL%BULK_EXCEPTIONS(i).ERROR_INDEX));
dbms_output.put_line(SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
END LOOP;
end;
end loop;
close cur;
dbms_output.put_line('h2');
end;
/The CREATE TABLE you post for table D2 has no column called 'image'. It would help somewhat if you posted a working example.
Also I am not clear why the INSERT INTO D3 statement in the anonymous block needs to be dynamic. -
I am trying to use FORALL to bulk bind INSERT statements to improve performance.
I replace a FOR .. LOOP command with FORALL as detailed in 8i documentation, and remove the END LOOP.
Yet I get an error when compiling -
"PLS-00707: unsupported construct or internal error [2603]"
Please can someone help me if you've used the command before!FORALL adds certain limitations on what you can insert. You can only insert arrays of 'basic' types, like integers. You can't use %ROWTYPES or records. The documentation wasn't especially clear when I tried this, but it is worth persevering as it is much quicker.
Oh, and it is a new addition to PL/SQL so I wouldn't discount the possibility that it's an internal error... -
Help needed with if statement in a method
Hi I�ve created 2 string arrays. One holds a one digit user id no. and the other holds a 4 digit pin number. I�ve then written a method which should take the userId no that has been sent to the method in the UserCode parameter find the same number in the custid array if it does it should then check the same position of the pin array and check that the pin number matches the pin no. the method has received in PINCode parameter.
At the moment my method receives the parameters checks the userId no. but doesn�t move on and check the PIN array.
Any help would be great as I�ve been staring at this for days now and I can�t see the wood from the trees!
public boolean checkPinAndUserId(String pinCode, String userCode)
boolean found = false;
for (int i = 0; i < userId.length; i++)
if (userCode.equals(userId))
if (pinCode.equals(pin[i]))
found = true;
return found;I've posted my code in full so hopefully everyone can see exactly what I have been doing.
Note - my code uses the observer/observable model. The method I am having the problem with the if statement is in the class HSBC as are the string arrays. in the class ATM in the action performed PINInput button events section, when the pin count reaches 4 it sends the parameters over to the HSBC checkpin&userid method.
I've used the System.out.println() statements to see what's going on and it receives the parameters checkes the userid array but does not move on to check that the pin parameter matches the pin array?
Any help would be great - Hope this helps.
* @(#)BankAssignment.java 1.0 03/04/06
* This apllication l
package myprojects.bankassignment;
import java.awt.*; // import the component library
import java.awt.event.*; // import the evnet library
import javax.swing.*;
import java.util.*;
class Correct1v16 extends Frame // make a new application
public Correct1v16() // this is the constructor method
HSBC HSBCobj = new HSBC();
public static void main(String args[]) // this invokes the constructor of the class and creates a runable object 'mainframe'
Correct1v16 mainFrame = new Correct1v16(); // the constructor call of the class which creates an object of that class
class HSBC implements Observer, ActionListener
Frame f5;
JLabel refill, launch;
TextField tRefill, tLaunch;
JButton refillbut, launchbut;
int count;
String [] userId=new String [10];
String [] pin=new String [10];
public boolean authenticate = false;
int i;
public HSBC()
drawFrame();
Atm Atmobj = new Atm(this);
System.out.println("Starting HSBC constructor");
public void drawFrame()
System.out.println("Start HSBC drawframe method...");
f5=new Frame("HSBC");
f5.setLayout(new FlowLayout());
f5.setSize(200, 200);
f5.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
f5.dispose();
System.exit(0);
refill=new JLabel("Refill ATM");
launch=new JLabel("Launch new ATM");
tRefill=new TextField(20);
tLaunch=new TextField(10);
refillbut=new JButton("Refill ATM");
refillbut.addActionListener(this);
launchbut=new JButton("Launch new ATM");
launchbut.addActionListener(this);
f5.add(refill);
f5.add(tRefill);
f5.add(refillbut);
f5.add(launch);
f5.add(tLaunch);
f5.add(launchbut);
f5.setVisible(true);
//*********** POPULATE THE ARRAYS */
pin[0]="1234";
pin[1]="2345";
pin[2]="3456";
pin[3]="4567";
pin[4]="5678";
pin[5]="6789";
pin[6]="7890";
pin[7]="8901";
pin[8]="9012";
pin[9]="0123";
userId[0]="0";
userId[1]="1";
userId[2]="2";
userId[3]="3";
userId[4]="4";
userId[5]="5";
userId[6]="6";
userId[7]="7";
userId[8]="8";
userId[9]="9";
}// end drawframe method
// public Atm atmLink = (Atm)o;
public void update(Observable gm1, Object o)
Atm atmLink = (Atm)o;
tRefill.setText("Refill ATM ?");
atmLink.refill();
}//end update method
public void actionPerformed(ActionEvent ae)
if(ae.getSource() == refillbut)
// Atm Atmobj.refill();
// tRefill.setText("text area");
// atmLink.refill();
// Atmobj.refill();
// setChanged();
// notifyObservers();
if(ae.getSource() == launchbut)
tLaunch.setText("new ATM opened");
Atm Atmobj1 = new Atm(this);
//******** THIS METHOD RECEIVES THE PARAMETERS FROM THE ATM METHOD (LINE 580) (PINCODE AND USERCODE) BUT
//******** IT ONLY THE ARRAY CALLED USERID (WHICH HOLDS THE USER CODE MATCHES ONE OF THE USERID'S)
//******** I DO WANT IT TO DO THIS BUT I ALSO WANT IT TO MOVE ON AND CHECK THE PINCODE WITH THE PIN ARRAY)
//******** IF THEY ARE BOTH TRUE I WANT IT TO RETURN TRUE - ELSE FALSE. */
public boolean checkPinAndUserId(String pinCode, String userCode)
boolean found = false;
System.out.println("in checkpin method");
for (int i = 0; i < userId.length; i++)
System.out.println("in the userid array" + userId);
if (userCode.equals(userId[i]))
System.out.println("checking user code array");
if (pinCode.equals(pin[i]))
System.out.println("checking the pin array" + pinCode);
System.out.println("pin[i] = "+pin[i]);
found = true;
return found;
}// end HSBC class
class Atm extends Observable implements ActionListener
Frame f1;
TextField t3, t5;
JTextArea display = new JTextArea("Welcome to HSBC Bank. \n Please enter your User Identification number \n", 5, 40);
JPanel p1, p2, p3,p4;
private JButton but1, but2, but3, but4,but5,but6,but7,but8,but9,but0,enter,
cancel,fivepounds,tenpounds,twentypounds,fiftypounds,clearbut, refillbut;
int state = 1;
public String pinCode ="";
public String userCode ="";
int userCodeCount = 0;
int PINCount = 0;
String withdrawAmount = "";
int atmBalance =200;
private HSBC HSBCobj;
//ATM constructor that receives the HSBCobj g1 reference to where the HSBC class
// in in the program
// Calls the drawATMFrame method
// add the observer to the HSBCobj reference so that the ATM can tell HSBC that
// something has changed
public Atm(HSBC g1)
HSBCobj = g1;
drawATMFrame();
System.out.println("Starting Atm constructor");
addObserver(HSBCobj);
// this is the method that draws the ATM interface
// also apply the Border Layout to the frame
public void drawATMFrame()
f1=new Frame("ATM");
f1.setLayout(new BorderLayout());
f1.setSize(350, 250);
f1.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
f1.dispose();
System.exit(0);
// declare & instantiate all the buttons that will be used on the ATM
but1 =new JButton("1");
but1.addActionListener(this);
but2 =new JButton("2");
but2.addActionListener(this);
but3 =new JButton("3");
but3.addActionListener(this);
but4 =new JButton("4");
but4.addActionListener(this);
but5 =new JButton("5");
but5.addActionListener(this);
but6 =new JButton("6");
but6.addActionListener(this);
but7 =new JButton("7");
but7.addActionListener(this);
but8 =new JButton("8");
but8.addActionListener(this);
but9 =new JButton("9");
but9.addActionListener(this);
but0 =new JButton("0");
but0.addActionListener(this);
enter=new JButton("Enter");
enter.addActionListener(this);
cancel=new JButton("Cancel/ \n Restart");
cancel.addActionListener(this);
fivepounds =new JButton("?5");
fivepounds.addActionListener(this);
tenpounds = new JButton("?10");
tenpounds.addActionListener(this);
twentypounds = new JButton("?20");
twentypounds.addActionListener(this);
fiftypounds = new JButton("?50");
fiftypounds.addActionListener(this);
clearbut = new JButton("Clear");
clearbut.addActionListener(this);
refillbut = new JButton("Refill");
refillbut.addActionListener(this);
//declare & instantiate a textfield
t3=new TextField(5);
// instantiate 4 JPanels
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
// add some buttons to p1
p1.add(but1);
p1.add(but2);
p1.add(but3);
p1.add(but4);
p1.add(but5);
p1.add(but6);
p1.add(but7);
p1.add(but8);
p1.add(but9);
p1.add(but0);
//add the text area field to p2
p2.add(display);
// apply the grid layout to p3
GridLayout layout3 = new GridLayout(4,1,5,5);
p3.setLayout(layout3);
p3.add(fivepounds);
p3.add(tenpounds);
p3.add(twentypounds);
p3.add(fiftypounds);
// apply grid layout to p4
GridLayout layout4 = new GridLayout(4,1,5, 5);
p4.setLayout(layout4);
p4.add(clearbut);
p4.add(enter);
p4.add(cancel);
p4.add(refillbut);
//add the panels to the different parts of the screen
f1.add("North", display);
f1.add("Center", p1);
f1.add("East", p4);
f1.add("West", p3);
f1.setVisible(true);
}// end drawATMframe method
public void actionPerformed(ActionEvent ae)
if(state == 1)
getUserIdNo(ae);
else if(state == 2)
doPINInput(ae);
else
withdrawCash(ae);
}// end action performed method
//******** STATE 1 events
//******** USER ID INPUT
public void getUserIdNo (ActionEvent ae)
if (ae.getSource() == but1)
display.append("*");
userCode = userCode + "1";
userCodeCount++;
if (ae.getSource() == but2)
display.append("*");
userCode = userCode + "2";
userCodeCount++;
if (ae.getSource() == but3)
display.append("*");
userCode = userCode + "3";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but4)
display.append("*");
userCode = userCode = "4";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but5)
display.append("*");
userCode = userCode + "5";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but6)
display.append("*");
userCode = userCode + "6";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but7)
display.append("*");
userCode = userCode + "7";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but8)
display.append("*");
userCode = userCode + "8";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but9)
display.append("*");
userCode = userCode + "9";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == but0)
display.append("*");
userCode = userCode + "0";
userCodeCount++;
System.out.println("user id ="+userCode);
if (ae.getSource() == cancel)
display.setText("Welcome to HSBC Bank.\n Please enter your User Identification number \n");
userCode = "";
state = 2;
if (ae.getSource() == clearbut)
display.setText("Please enter your user ID number again\n");
userCode = "";
userCodeCount = 0;
if (ae.getSource() == refillbut)
refill();
if (ae.getSource() == enter)
display.setText("Please enter your PIN \n");
state = 2;
System.out.println(" User id enter button = " + userCode);
if (userCodeCount == 1)
display.setText("Please enter your PIN \n");
userCode = "";
userCodeCount = 0;
state = 2;
//******** STATE 2
//******** PIN INPUT
public void doPINInput(ActionEvent ae)
if (ae.getSource() == but1)
{ pinCode = pinCode.concat("1");
display.append("*");
PINCount++;
if (ae.getSource() == but2)
{ pinCode = pinCode.concat("2");
display.append("*");
PINCount++;
if (ae.getSource() == but3)
{ pinCode = pinCode.concat("3");
display.append("*");
PINCount++;
if (ae.getSource() == but4)
{ pinCode = pinCode.concat("4");
display.append("*");
PINCount++;
if (ae.getSource() == but5)
{ pinCode = pinCode.concat("5");
display.append("*");
PINCount++;
if (ae.getSource() == but6)
{ pinCode = pinCode.concat("6");
display.append("*");
PINCount++;
if (ae.getSource() == but7)
{ pinCode = pinCode.concat("7");
display.append("*");
PINCount++;
if (ae.getSource() == but8)
{ pinCode = pinCode.concat("8");
display.append("*");
PINCount++;
if (ae.getSource() == but9)
{ pinCode = pinCode.concat("9");
display.append("*");
PINCount++;
if (ae.getSource() == but0)
{ pinCode = pinCode.concat("0");
display.append("*");
PINCount++;
if (ae.getSource() == clearbut)
display.setText("Please enter your PIN number again \n");
pinCode = "";
PINCount = 0;
if (ae.getSource() == cancel)
display.setText("Welcome to HSBC Bank.\n Please enter your User Identification number \n");
state = 1;
pinCode ="";
PINCount = 0;
if (ae.getSource() == refillbut)
refill();
/// ************************ THIS BUTTON SENDS THE PIN & USER CODE OVER TO THE MAIN BANK
/// ************************ (LINE 152)
if (ae.getSource() == enter)
// if(HSBCobj.checkPinAndUserId(pinCode, userCode))
// display.setText("How much would you like to withdraw \n");
// else
// display.setText("Your UserId and Pin code do not match");
if(PINCount ==4)
if(HSBCobj.checkPinAndUserId(userCode,pinCode))
display.setText("Enter the amount you \n want to withdraw \n ?");
PINCount=0;
else
display.setText("Your User Identification Number \n and PIN number do not match! \n please try again\n");
//*********** STATE 3 events
//*********** withdrawCash
public void withdrawCash(ActionEvent ae)
// if (ae.getSource() == but1)
// display.append("1");
/// withdrawAmount = withdrawAmount+1;
// pinCode = pinCode.concat("2");
// System.out.println("Withdrawal Amount = "+withdrawAmount);
if(ae.getSource( ) == but1)
withdrawAmount = withdrawAmount + "1";
display.setText(withdrawAmount);
if(ae.getSource( ) == but2)
withdrawAmount = withdrawAmount + "2";
display.setText(withdrawAmount);
if(ae.getSource( ) == but3)
withdrawAmount = withdrawAmount + "3";
display.setText(withdrawAmount);
if(ae.getSource( ) == but4)
withdrawAmount = withdrawAmount + "4";
display.setText(withdrawAmount);
if(ae.getSource( ) == but5)
withdrawAmount = withdrawAmount + "5";
display.setText(withdrawAmount);
if(ae.getSource( ) == but6)
withdrawAmount = withdrawAmount + "6";
display.setText(withdrawAmount);
if(ae.getSource( ) == but7)
withdrawAmount = withdrawAmount + "7";
display.setText(withdrawAmount);
if(ae.getSource( ) == but8)
withdrawAmount = withdrawAmount + "8";
display.setText(withdrawAmount);
if(ae.getSource( ) == but9)
withdrawAmount = withdrawAmount + "9";
display.setText(withdrawAmount);
if(ae.getSource( ) == but0)
withdrawAmount = withdrawAmount + "0";
display.setText(withdrawAmount);
if (ae.getSource() == fivepounds)
withdrawAmount = withdrawAmount + "5";
display.setText(withdrawAmount);
atmBalance();
if (ae.getSource() == tenpounds)
withdrawAmount = withdrawAmount + "10";
display.setText(withdrawAmount);
atmBalance();
if (ae.getSource() == twentypounds)
withdrawAmount = withdrawAmount + "20";
display.setText(withdrawAmount);
atmBalance();
if (ae.getSource() == fiftypounds)
withdrawAmount = withdrawAmount + "50";
display.setText(withdrawAmount);
atmBalance();
// if (ae.getSource() == tenpounds)
// display.append("10");
// withdrawAmount = 10;
// pinCode = pinCode.concat("2");
// System.out.println("10 pound button pressed");
// atmBalance();
if (ae.getSource() == enter)
atmBalance();
if (ae.getSource() == refillbut)
System.out.println("refill but pressed");
refill();
if (ae.getSource() == clearbut)
System.out.println("clear but pressed");
display.setText("Enter the amount you want to withdraw \n ?");
withdrawAmount="";
if (ae.getSource() == cancel)
display.setText("Welcome to HSBC Bank.\n Please enter your User Identification number \n");
withdrawAmount="";
pinCode ="";
PINCount = 0;
userCode = "";
userCodeCount = 0;
state = 1;
}// end withdraw cash input method
// checks balace of atm and withdraws cash. Also notifies onserver if atm balance is low
public void atmBalance()
String s = withdrawAmount;
int n = Integer.parseInt(s);
if ( atmBalance >= n)
atmBalance = atmBalance - n;
System.out.println("atm balance = "+ atmBalance);
display.setText("Thankyou for using HSBC. \nYou have withdrawn ?"+n);
if (atmBalance<40)
System.out.println("atm balance is less than 40 - notify HSBC" );
setChanged();
notifyObservers(this);
/// note the refil should send a message to the controller
// advising a refil is needed. The Bank will send an engineer
// out who will fill the atm up
}// end atmBalance method
/// note the refil should send a message to the controller
/// then th coontroller will send a message to this method to fill machine
/// (this is simulating a clerk filling atm)
public void refill()
System.out.println("in refill method" );
atmBalance = 200;
System.out.println("Atm has been refilled. Atm balance = " + atmBalance);
// setChanged();
// notifyObservers(this);
}// end refill method
// NOTE SURE ABOUT THIS - DO I USE THE UPDATE METHOD TO NOTIFY HSBC THAT ATM REQUIRES FILLING
// THIS IS THE WRONG PART OF THE PROGRAM (SHOULD BE IN HSBC) - IGNORE
public void update(Observable gm1, Object gameObj)
display.setText("Congratulations");
}//end update method
}// end Atm method
}// end Assignment2 class -
Hi,
From the SQL statement below, i need help in explaining what does the line "WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+))" do?
This statement was written by a vendor and now i have problem displaying some new data. Only a portion of what i need is displayed.
SELECT "LIMS_SYS"."RESULT"."DESCRIPTION",
"LIMS_SYS"."RESULT_TEMPLATE_LIMIT"."NUMERIC_LIMIT",
"LIMS_SYS"."RESULT"."FORMATTED_RESULT",
"LIMS_SYS"."RESULT"."CONCLUSION",
"LIMS_SYS"."RESULT_USER"."U_RESULT_SEQUENCE" ,
"LIMS_SYS"."RESULT"."RESULT_ID"
FROM "LIMS_SYS"."RESULT",
"LIMS_SYS"."RESULT_TEMPLATE_LIMIT",
"LIMS_SYS"."RESULT_USER",
"LIMS_SYS"."ALIQUOT",
"LIMS_SYS"."SAMPLE",
"LIMS_SYS"."SDG",
"LIMS_SYS"."TEST"
WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+)) and
( "LIMS_SYS"."RESULT"."RESULT_ID" = "LIMS_SYS"."RESULT_USER"."RESULT_ID" ) and
( "LIMS_SYS"."SDG"."SDG_ID" = "LIMS_SYS"."SAMPLE"."SDG_ID" ) and
( "LIMS_SYS"."SAMPLE"."SAMPLE_ID" = "LIMS_SYS"."ALIQUOT"."SAMPLE_ID" ) and
( "LIMS_SYS"."ALIQUOT"."ALIQUOT_ID" = "LIMS_SYS"."TEST"."ALIQUOT_ID" ) and
( "LIMS_SYS"."TEST"."TEST_ID" = "LIMS_SYS"."RESULT"."TEST_ID" ) and
( ( LIMS_SYS."SDG"."SDG_ID" = :sdg_id ) AND
( LIMS_SYS."RESULT"."STATUS" <> 'X' ) AND
( LIMS_SYS."RESULT"."REPORTED" = 'T' ) AND
( LIMS_SYS."RESULT_USER"."U_RESULT_CATEGORY" in ( 'Metal' , 'Mean Metal', 'Range Metal')) )
Thanks for all your help.Hi,
After WHERE .......... is indicates an OUTER Join condition.
In this type of join, system retrieves the data for matched and
as well as unmatched.
Example:
EMP table have a column DEPTNO with the data 10, 20, 30 (total rows=14)
DEPT table have a column DEPTNO with the data 10, 20, 30, 40, 50 (total rows=5)
If the WHERE clause contained EMP.DEPTNO(+) = DEPT.DEPTNO
then the output contain the data relative to 10, 20, 30, 40, 50 (total rows = 16)
i.e. 14 rows (with matching data) and 2 rows (with unmatching data)
Regards,
Sailaja -
JDBC:KPRB string size limits-NEED HELP!
Hello All.
Please, I need your help.
I have the problems in Oracle 9.2.0.6 with stored java and jdbc:kprb internal driver.
I try to put string(more than 32K) into LONG-type field using following java class:
import oracle.sql.CLOB;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.io.Reader;
import java.io.CharArrayReader;
public class LongTest {
public static void insertLong()
throws Exception {
Connection con = DriverManager.getConnection("jdbc:default:connection:");
//generate large string
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < 100000; i++) {
stringBuffer.append("qwerty");
String st = stringBuffer.toString();
//put large string to long-type field
PreparedStatement pst = null;
try {
pst = con.prepareStatement("insert into TEST_LONG (ldata) values (?)");
pst.setString(1, st);
pst.execute();
} finally {
if (pst != null) {pst.close();}
But I get error from jdbc:kprb about limitation of data size for this type(LONG).
But it works well in oracle 10.2.0.1...
Has anybody a solution of how to do this in oracle 9.2.0.6???
thanx!Hi,
THis is a known limitation in the 92 RDBMS solved in 10g.
Kuassi http://db360.blogspot.com -
Need help in Statement level triggers.
Hi All,
I would like to clarify few things about statement level triggers. here are my doubts,
1. does a statement level trigger have access to the column values of each row that the trigger affects? if so provide me with some examples.
Thanks,
james.Not by default. If you need to see the column values in an after-statement trigger, you need to use a row-level trigger to accumulate the values in a package variable. This approach would use a before-statement trigger to clear the variable (a table of records based on the rowtype of the table, usually), the after-row trigger to add a row's column values, and then the after-statement trigger to loop through the PL/SQL table (array, collection, etc.) and do whatever is needed.
-
Need a sql statement to remove data?
Hello,
I need your help regarding my query.
I need to put a sql statement in a shell script that will delete records from a table that is > than 3 months old and if not, do nothing.
The table has a DATE column as shown below:
LOG_ID NOT NULL VARCHAR2(8)
LOG_TYPE NOT NULL VARCHAR2(8)
LOG_MESSAGE NOT NULL VARCHAR2(255)
LOG_DATE DATE
I'm a novoice at sql and request you to provide me a sql statement that will do the above.
Much appreciated!
Regards,SQL> select sysdate from dual;
SYSDATE
14-JUL-09
SQL> select add_months(sysdate,-3) from dual;
ADD_MONTH
14-APR-09
SQL> select add_months(sysdate,-3)-1 from dual;
ADD_MONTH
13-APR-09
DELETE FROM {table_name} WHERE HIREDATE<={pick the date format from above accordingly} -
Doing a Trace on the ARXADLMT Approval Limits form No Select statement i
Hi I want to see the all the SQL statements executed when I open the AR Approval Limits form(ARXADLMT). So I enabled the TRACE from the Menu(supplying password) , then opened then form and did a Query-> Execute. (The base table for the block is AR_APPROVAL_USER_LIMITS.Then I turned off the trace exited applications and went to the USER_DUMP_DEST directory of the database. From here tkprofed the latest trace file .When I look at the output file I cant see any Select statements at all. At least I should be seeing a select on the base table AR_APPROVAL_USER_LIMITS. Maybe I havent understood this process well enough- what am I doing wrong.Why is the trace not containing the select statement?
Edited by: [email protected] on 13/06/2010 03:18>
... From here tkprofed the latest trace file ...
>
Pl post details of your OS and EBS versions. The latest trace file may not be the correct one. Pl search the trace files for "AR_APPROVAL_USER_LIMITS" to find the right trace file.
How To Trace From Form, Report, Program And Others In Oracle Applications (Doc ID 130182.1)
https://supporthtml.oracle.com/ep/faces/secure/km/DocumentDisplay.jspx?id=130182.1&h=Y
HTH
Srini -
Help needed with Update statements.
Hello All,
I am trying to learn Berkeley XMLDB and facing problem to query the inserted XML file. I have a small XML file with the following contents:
<?xml version="1.0" standalone="yes"?>
<Bookstore>
<Book>
<book_ID>1</book_ID>
<title>Harry Potter and the Order of the Phoenix</title>
<subtitle>A Photographic History</subtitle>
<author>
<author_fname>J.K.</author_fname>
<author_lname>Rowling</author_lname>
</author>
<price>9.99</price>
<year_published>2004</year_published>
<publisher>Scholastic, Inc.</publisher>
<genre>Fiction</genre>
<quantity_in_stock>28997</quantity_in_stock>
<popularity>20564</popularity>
</Book>
</Bookstore>
When I try to update the TITLE of this node I have the following error message:
C:\Users\Chandra\Desktop\BDB>javac -classpath .;"C:\Program Files\Sleepycat Soft
ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
erkeley DB XML 2.1.8\jar\db.jar" bdb.java
bdb.java:75: illegal start of expression
public static final String STATEMENT1 = "replace value of node collection("twopp
ro.bdbxml")/Bookstore/Book/bookid/title with 'NEWBOOK'";
^
bdb.java:80: ')' expected
System.out.println("Done query: " + STATEMENT1);
^
2 errors
But when I remove the update statements and just try to display the TITLE of this node, I dont see any outputs. Please help me to catch up with my mistakes. Below is source code I am using to run this functionality.
Thanks.
import java.io.File;
import java.io.FileNotFoundException;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlInputStream;
import com.sleepycat.dbxml.XmlManager;
import com.sleepycat.dbxml.XmlUpdateContext;
import com.sleepycat.dbxml.XmlDocument;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlResults;
import com.sleepycat.dbxml.XmlValue;
public class bdb{
public static void main(String[] args)
Environment myEnv = null;
File envHome = new File("D:/xmldata");
try {
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exits, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
envConf.setRunRecovery(true);
// subsystem.
myEnv = new Environment(envHome, envConf);
// Do BDB XML work here.
} catch (DatabaseException de) {
// Exception handling goes here
} catch (FileNotFoundException fnfe) {
// Exception handling goes here
} finally {
try {
if (myEnv != null) {
myEnv.close();
} catch (DatabaseException de) {
// Exception handling goes here
XmlManager myManager = null;
XmlContainer myContainer = null;
// The document
String docString = "D:/xmldata/test.xml";
// The document's name.
String docName = "cia";
try {
myManager = new XmlManager(); // Assumes the container currently exists.
myContainer =
myManager.createContainer("twoppro.bdbxml");
myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
XmlInputStream theStream =
myManager.createLocalFileInputStream(docString); // Do the actual put
myContainer.putDocument(docName, // The document's name
theStream, // The actual document.
theContext, // The update context
// (required).
null); // XmlDocumentConfig object
theStream.delete();
// Update the title
public static final String STATEMENT1 = "*replace value of node collection("twoppro.bdbxml")/Bookstore/Book/[bookid=1]/title with 'NEWBOOK'";*
XmlQueryContext context = myManager.createQueryContext();
XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
System.out.println("Try to execute query: " +
System.out.println("Done query: " + STATEMENT1);
queryExpression1.execute(context);
// Get a query context
XmlQueryContext context = myManager.createQueryContext();
// Set the evaluation type to Lazy.
context.setEvaluationType(XmlQueryContext.Lazy);
// Declare the query string
String queryString =
"for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
+ "*return $u/title";*
// Prepare (compile) the query
XmlQueryExpression qe = myManager.prepare(queryString, context);
XmlResults results = qe.execute(context);
System.out.println("ok");
System.out.println(results);
} catch (XmlException e) {
// Error handling goes here. You may want to check
// for XmlException.UNIQUE_ERROR, which is raised
// if a document with that name already exists in
// the container. If this exception is thrown,
// try the put again with a different name, or
// use XmlModify to update the document.
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes hereThanks Rucong. The change you suggested did helped me to run the program correct. But I also have the display function to retrive the results and my program is parsed without any output.
C:\Users\C\Desktop\BDB>Clientbuild.bat
C:\Users\C\Desktop\BDB>javac -classpath .;"C:\Program Files\Sleepycat Soft
ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
erkeley DB XML 2.1.8\jar\db.jar" bdb.java
C:\Users\C\Desktop\BDB>Client.bat
C:\Users\C\Desktop\BDB>java -classpath .;"C:\Program Files\Sleepycat Softw
are\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\Be
rkeley DB XML 2.1.8\jar\db.jar" bdb
See there is no OUPUT displayed. Is there somethinglike a 'print' I have to use in this java code.
Any ideas ? Below is the code I am using now
import java.io.File;
import java.io.FileNotFoundException;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlInputStream;
import com.sleepycat.dbxml.XmlManager;
import com.sleepycat.dbxml.XmlUpdateContext;
import com.sleepycat.dbxml.XmlDocument;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlResults;
import com.sleepycat.dbxml.XmlValue;
public class bdb{
public static void main(String[] args)
Environment myEnv = null;
File envHome = new File("D:/xmldata");
try {
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exits, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
envConf.setRunRecovery(true);
// subsystem.
myEnv = new Environment(envHome, envConf);
// Do BDB XML work here.
} catch (DatabaseException de) {
// Exception handling goes here
} catch (FileNotFoundException fnfe) {
// Exception handling goes here
} finally {
try {
if (myEnv != null) {
myEnv.close();
} catch (DatabaseException de) {
// Exception handling goes here
XmlManager myManager = null;
XmlContainer myContainer = null;
// The document
String docString = "D:/xmldata/test.xml";
// The document's name.
String docName = "cia";
try {
myManager = new XmlManager(); // Assumes the container currently exists.
myContainer =
myManager.createContainer("twoppro.bdbxml");
myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
XmlInputStream theStream =
myManager.createLocalFileInputStream(docString); // Do the actual put
myContainer.putDocument(docName, // The document's name
theStream, // The actual document.
theContext, // The update context
// (required).
null); // XmlDocumentConfig object
theStream.delete();
// Update the title
String STATEMENT1 = "for $n in collection('twoppro.bdbxml')/Bookstore/Book[book_ID=1]/title return replace value of node $n with 'NEWBOOK'";
XmlQueryContext context = myManager.createQueryContext();
XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
System.out.println("Done query: " + STATEMENT1);
queryExpression1.execute(context);
// Get a query context
XmlQueryContext thiscontext = myManager.createQueryContext();
// Set the evaluation type to Lazy.
context.setEvaluationType(XmlQueryContext.Lazy);
// Declare the query string
String queryString =
"for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
+ "return $u/title";
// Prepare (compile) the query
XmlQueryExpression qe = myManager.prepare(queryString, thiscontext);
XmlResults results = qe.execute(thiscontext);
System.out.println("ok");
System.out.println(results);
} catch (XmlException e) {
// Error handling goes here. You may want to check
// for XmlException.UNIQUE_ERROR, which is raised
// if a document with that name already exists in
// the container. If this exception is thrown,
// try the put again with a different name, or
// use XmlModify to update the document.
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes here
Thanks.
Maybe you are looking for
-
Unable to embed data in any of the components
I have an xlf file that contains a series of charts, tables and other components with data embedded in them. As I get new data, I update the previous data. But, currently I am unable to embed data in the existing charts or any other new components th
-
I am using a iPhone 6 but it has got red screen
I am using a iPhone 6 but it has got red screen. Pls suggest to fix it.
-
How do you monitor required JAR(s) being downloaded?
Hi there, I'm currently re-developing an existing signed applet (Swing / 1.4) to offer advanced image manipulation features. As a result there is a massive increase in the size of download and the amount of JARs to be downloaded from 1 (app 50kb) to
-
Why isn't Photoshop accepting my serial number?
I had Photoshop CS4 installed on my laptop for two years without any major issues. The laptop recently broke so I got a new one and I cannot install Photoshop there because it says my serial number is invalid. How can this be? It worked fine before a
-
HT4757 EOS 6D - iphoto - viewer- not compatible
I have OX Lion10.7.5 with Iphoto 8.1.2 (424) and iPhoto does not accept CR2 (RAW) from EOS6D, neither do viewer- What can I do? Many Thanks. Thierry