For Loop in OSB(ALSB)
I have a variable in alsb:
$destinations = <destinations>
<destination>
<DESCRIPTION>
URL1
</DESCRIPTION>
</destination>
<destination>
<DESCRIPTION>
URL2
</DESCRIPTION>
</destination>
</destinations>
I have for each loop in ALSB which loops around this variable for each <destination> in <destinations>.
The problem is, when it is looping, I want to send the corresponding <description>-URL by addressing it as $destinations/destination\[$indexArg\]. It is returning all the <destination> nodes.
However, it is working fine when I use a hardcoded number instead of the variable index.
For Eg:
$destinations/destination[1] is returning the first node (as expected)
<destination>
<DESCRIPTION>
URL1
</DESCRIPTION>
</destination>
But, when I use $destinations/destination\[$indexArg\] all the destination nodes are getting returned.
I understand I am missing something. Any help will be appreciated.
Thanks in advance,
Chandan.
Edited by: user10604890 on May 20, 2009 11:31 PM
Edited by: user10604890 on May 21, 2009 12:10 PM
Edited by: user10604890 on May 21, 2009 12:11 PM
I was asking about the dynamic selection of the node from a variable.
in the $destinations variable to select a particular node with a number.
Eg: $destinations/destination\[$index\]
It works fine if I say, $destinations/destination[1] and selects only the first node.
When I assign a index value there, it gives every destination variable in destinations.
For Each is not what the question is about.
Similar Messages
-
SOA suit 11g uses both ESB and OSB(ALSB)
Hi, I am newbie to SOA suit 11g. Can somebody please explain the use of ESB and OSB(ALSB) both in SOA 11g.In SOA 11g ESB is being used only for mediation.Even OSB(ALSB) has same capability.Then why both needs to be used?Can't we use one of these?
~Pradeephello Pradeep,
there is quite some literature on this hot topic - actually it's one of the most frequently asked question from people who are using OSB and Soa Suite.
if you google "OSB vs Mediator" you will find some useful links:
http://www.scribd.com/doc/23622536/Oracle-SOA-Suite-11g-Mediator-vs-Oracle-Service-Bus-OSB
SOA SUITE 11g - Mediator & OSB
http://oracle-fusion-blogs.com/oracle-fusion-osb-mediator/
and so on.... -
OSB (ALSB) Logging Redirect
Hi all,
how to redirect all the OSB(ALSB) related message logs ( Errors and transport exceptions included ) to a log4j custom file.
Now, given this discussion:
alsb logging
The way to go is, apparently, to
1. create filters at domain level by subsystem (or context_id or whatever else)
2. create a startup class to catch all log messages and to filter in only those ones you are interested in using, in your filter class, filters like " startsWith("ALSB)) " (equivalent of domain filter "Subsystem LIKE ALSB% " )
Now given all the following list of OSB (ALSB) related subsystems
http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/messages/indexa.html
*Is there a better approach then creating a filter class per each subsystem ?*
Regards,
Tony P.There doesn't seem to be 64bit version of OSB at all for Windows. [http://download.oracle.com/docs/cd/E13196_01/platform/suppconfigs/configs_al10gr3/osb10gr3/overview.html]
-
Oracle Service Bus For loop getting out of memory error
I have a business service that is based on a JCA adapter to fetch an undertimed amout of records from a database. I then need to upload those to another system using a webservice designed by an external source. This web service will only accept upto to x amount of records.
The process:
for each object in the Jca Response
Insert object into Service callout Request body
if object index = number of objects in jca response or object index = next batch index
Invoke service callout
Append service callout Response to a total response object (xquery transform)
increase next batch index by Batch size
reset service callout to empty body
endif
end for
replace body with total response object.
If I use the data set that only has 5 records and use a batch size of 2 the process works fine.
If I use a data set with 89 records and a batch size of 2 I get the below out of memory error after about 10 service callouts
the quantity of data in the objects is pretty small, less than 1kB for each JCA Object
Server Name:
AdminServer
Log Name:
ServerLog
Message:
Failed to process response message for service ProxyService Sa/Proxy Services/DataSync:
java.lang.OutOfMemoryError: allocLargeObjectOrArray:
[C, size 67108880 java.lang.OutOfMemoryError: allocLargeObjectOrArray:
[C, size 67108880 at org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1700)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1303) at
org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1234)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emitXmlns(Saver.java:1003)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emitNamespacesHelper(Saver.java:1021)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emitElement(Saver.java:972)
at org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:476)
at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.saveToString(Saver.java:1864)
at org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
at org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
at org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1500)
at com.bea.wli.sb.test.service.ServiceTracer.getXmlData(ServiceTracer.java:968)
at com.bea.wli.sb.test.service.ServiceTracer.addDataType(ServiceTracer.java:944)
at com.bea.wli.sb.test.service.ServiceTracer.addDataType(ServiceTracer.java:924)
at com.bea.wli.sb.test.service.ServiceTracer.addContextChanges(ServiceTracer.java:814)
at com.bea.wli.sb.test.service.ServiceTracer.traceExit(ServiceTracer.java:398)
at com.bea.wli.sb.pipeline.debug.DebuggerTracingStep.traceExit(DebuggerTracingStep.java:156)
at com.bea.wli.sb.pipeline.PipelineContextImpl.exitComponent(PipelineContextImpl.java:1292)
at com.bea.wli.sb.pipeline.MessageProcessor.finishProcessing(MessageProcessor.java:371)
at com.bea.wli.sb.pipeline.RouterCallback.onReceiveResponse(RouterCallback.java:108)
at com.bea.wli.sb.pipeline.RouterCallback.run(RouterCallback.java:183)
at weblogic.work.ContextWrap.run(ContextWrap.java:41)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Subsystem:
OSB Kernel
Message ID:
BEA-382005
It appears to be the service callout that is the problem (it calls another OSB service that logins and performs the data upload to the External service) because If I change the batch size up to 100 the loop will load all the 89 records into the callout request and execute it fine. If I have a small batch size then I run out of memory.
Is there some settings I need to change? Is there a better way in OSB (less memory intensive than service callout in a for loop)?
Thanks.hi,
Could you please let me know if you get rid off this issue as we are also facing the same issue.
Thanks,
SV -
Support of exslt in OSB/ALSB
Hi,
Does OSB/ALSb support extended xslt functions i.e exslt(http://exslt.org/functions)?
When I tried to import/save an xslt having exslt functions, it gives an error
An error occurred compiling the XSLT template: javax.xml.transform.TransformerException: weblogic.apache.xml.utils.WrappedRuntimeException: Could not find variable with the name of val.
and the function is defined in xsl as :
<func:function name="ctvf:convertToNumber">
<xsl:param name="val"/>
<xsl:variable name="strVal" select="string($val)"/>
<xsl:choose>
<xsl:when test="$strVal = 'NaN'">
<func:result select="''"/>
</xsl:when>
<xsl:otherwise>
<func:result select="$strVal"/>
</xsl:otherwise>
</xsl:choose>
</func:function>
where namespaces in the header are as:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:func="http://exslt.org/functions"
Thanks,
RajeshHi all!
Thanx for the answers! I have tried in the past the /text() I tried it again and didn´t worked, some body knows how can I post some screen shots so you can see that I´m using the /text() and maybe with the screen shot you can detect something, also I´m loging the $body in the default branch(cause it is not detecting the value between the tags it goes directly to the Defaul Branch) you will se some differences in the XML since I simplified the XML to make the example and tested this simplified XML it in the TEST Tool in the console and had the same results that with the original evendough I put the /text() at the end
Here is the Body I loged in the default Branch:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<imp:iniciarCambio xmlns:imp="http://bea.com/albpm/MMME/ImpactarCambiosClienteBILLING">
<cambios xmlns:bea="http://bea.com/">
<bea:ListaDeCambios>
<!--1 or more repetitions:-->
<bea:Cambio>
<bea:campoNombre>Cambio1</bea:campoNombre>
<bea:valorAnterior>antes</bea:valorAnterior>
<bea:valorNuevo>despues</bea:valorNuevo>
</bea:Cambio>
</bea:ListaDeCambios>
<bea:companiaId>32</bea:companiaId>
<bea:companiaNombre>MMRedes</bea:companiaNombre>
<bea:companiaTipo>Servicio</bea:companiaTipo>
</cambios>
</imp:iniciarCambio>
</soapenv:Body>>
as you can see it is Servicio and it should have gone to one of the branches instead of the default but it didn´t
Can´t see what I´m doing wrong, but maybe some of you can.
Thanx in advanced!
Gerardo J -
How can I repeat a for loop, once it's terms has been fulfilled???
Well.. I've posted 2 different exceptions about this game today, but I managed to fix them all by myself, but now I'm facing another problem, which is NOT an error, but just a regular question.. HOW CAN I REPEAT A FOR LOOP ONCE IT HAS FULFILLED IT'S TERMS OF RUNNING?!
I've been trying many different things, AND, the 'continue' statement too, and I honestly think that what it takes IS a continue statement, BUT I don't know how to use it so that it does what I want it too.. -.-'
Anyway.. Enought chit-chat. I have a nice functional game running that maximum allows 3 apples in the air in the same time.. But now my question is: How can I make it create 3 more appels once the 3 first onces has either been catched or fallen out the screen..?
Here's my COMPLETE sourcecode, so if you know just a little bit of Java you should be able to figure it out, and hopefully you'll be able to tell me what to do now, to make it repeat my for loop:
Main.java:
import java.applet.*;
import java.awt.*;
@SuppressWarnings("serial")
public class Main extends Applet implements Runnable
private Image buffering_image;
private Graphics buffering_graphics;
private int max_apples = 3;
private int score = 0;
private GameObject player;
private GameObject[] apple = new GameObject[max_apples];
private boolean move_left = false;
private boolean move_right = false;
public void init()
load_content();
setBackground(Color.BLACK);
public void run()
while(true)
if(move_left)
player.player_x -= player.movement_speed;
else if(move_right)
player.player_x += player.movement_speed;
for(int i = 0; i < max_apples; i++)
apple.apple_y += apple[i].falling_speed;
repaint();
prevent();
collision();
try
Thread.sleep(20);
catch(InterruptedException ie)
System.out.println(ie);
private void prevent()
if(player.player_x <= 0)
player.player_x = 0;
else if(player.player_x >= 925)
player.player_x = 925;
private void load_content()
MediaTracker media = new MediaTracker(this);
player = new GameObject(getImage(getCodeBase(), "Sprites/player.gif"));
media.addImage(player.sprite, 0);
for(int i = 0; i < max_apples; i++)
apple[i] = new GameObject(getImage(getCodeBase(), "Sprites/apple.jpg"));
try
media.waitForAll();
catch(Exception e)
System.out.println(e);
public boolean collision()
for(int i = 0; i < max_apples; i++)
Rectangle apple_rect = new Rectangle(apple[i].apple_x, apple[i].apple_y,
apple[i].sprite.getWidth(this),
apple[i].sprite.getHeight(this));
Rectangle player_rect = new Rectangle(player.player_x, player.player_y,
player.sprite.getWidth(this),
player.sprite.getHeight(this));
if(apple_rect.intersects(player_rect))
if(apple[i].alive)
score++;
apple[i].alive = false;
if(!apple[i].alive)
apple[i].alive = false;
return true;
public void update(Graphics g)
if(buffering_image == null)
buffering_image = createImage(getSize().width, getSize().height);
buffering_graphics = buffering_image.getGraphics();
buffering_graphics.setColor(getBackground());
buffering_graphics.fillRect(0, 0, getSize().width, getSize().height);
buffering_graphics.setColor(getForeground());
paint(buffering_graphics);
g.drawImage(buffering_image, 0, 0, this);
public boolean keyDown(Event e, int i)
i = e.key;
if(i == 1006)
move_left = true;
else if(i == 1007)
move_right = true;
return true;
public boolean keyUp(Event e, int i)
i = e.key;
if(i == 1006)
move_left = false;
else if(i == 1007)
move_right = false;
return true;
public void paint(Graphics g)
g.drawImage(player.sprite, player.player_x, player.player_y, this);
for(int i = 0; i < max_apples; i++)
if(apple[i].alive)
g.drawImage(apple[i].sprite, apple[i].apple_x, apple[i].apple_y, this);
g.setColor(Color.RED);
g.drawString("Score: " + score, 425, 100);
public void start()
Thread thread = new Thread(this);
thread.start();
@SuppressWarnings("deprecation")
public void stop()
Thread thread = new Thread(this);
thread.stop();
GameObject.java:import java.awt.*;
import java.util.*;
public class GameObject
public Image sprite;
public Random random = new Random();
public int player_x;
public int player_y;
public int movement_speed = 15;
public int falling_speed;
public int apple_x;
public int apple_y;
public boolean alive;
public GameObject(Image loaded_image)
player_x = 425;
player_y = 725;
sprite = loaded_image;
falling_speed = random.nextInt(10) + 1;
apple_x = random.nextInt(920) + 1;
apple_y = random.nextInt(100) + 1;
alive = true;
And now all I need is you to answer my question! =)package forums;
import java.util.Random;
import javax.swing.Timer;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class VimsiesRetardedAppleGamePanel extends JPanel implements KeyListener
private static final long serialVersionUID = 1L;
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final int MAX_APPLES = 3;
private static final Random RANDOM = new Random();
private int score = 0;
private Player player;
private Apple[] apples = new Apple[MAX_APPLES];
private boolean moveLeft = false;
private boolean moveRight = false;
abstract class Sprite
public final Image image;
public int x;
public int y;
public boolean isAlive = true;
public Sprite(String imageFilename, int x, int y) {
try {
this.image = ImageIO.read(new File(imageFilename));
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Bailing out: Can't load images!");
this.x = x;
this.y = y;
this.isAlive = true;
public Rectangle getRectangle() {
return new Rectangle(x, y, image.getWidth(null), image.getHeight(null));
class Player extends Sprite
public static final int SPEED = 15;
public Player() {
super("C:/Java/home/src/images/player.jpg", WIDTH/2, 0);
y = HEIGHT-image.getHeight(null)-30;
class Apple extends Sprite
public int fallingSpeed;
public Apple() {
super("C:/Java/home/src/images/apple.jpg", 0, 0);
reset();
public void reset() {
this.x = RANDOM.nextInt(WIDTH-image.getWidth(null));
this.y = RANDOM.nextInt(300);
this.fallingSpeed = RANDOM.nextInt(8) + 3;
this.isAlive = true;
private final Timer timer = new Timer(200,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
repaint();
public VimsiesRetardedAppleGamePanel() {
this.player = new Player();
for(int i=0; i<MAX_APPLES; i++) {
apples[i] = new Apple();
setBackground(Color.BLACK);
setFocusable(true); // required to generate key listener events.
addKeyListener(this);
timer.setInitialDelay(1000);
timer.start();
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == e.VK_LEFT) {
moveLeft = true;
moveRight = false;
} else if (e.getKeyCode() == e.VK_RIGHT) {
moveRight = true;
moveLeft = false;
public void keyReleased(KeyEvent e) {
moveRight = false;
moveLeft = false;
public void keyTyped(KeyEvent e) {
// do nothing
public void paintComponent(Graphics g) {
super.paintComponent(g);
//System.err.println("DEBUG: moveLeft="+moveLeft+", moveRight="+moveRight);
if ( moveLeft ) {
player.x -= player.SPEED;
if (player.x < 0) {
player.x = 0;
} else if ( moveRight ) {
player.x += player.SPEED;
if (player.x > getWidth()) {
player.x = getWidth();
//System.err.println("DEBUG: player.x="+player.x);
Rectangle playerRect = player.getRectangle();
for ( Apple apple : apples ) {
apple.y += apple.fallingSpeed;
Rectangle appleRect = apple.getRectangle();
if ( appleRect.intersects(playerRect) ) {
if ( apple.isAlive ) {
score++;
apple.isAlive = false;
g.drawImage(player.image, player.x, player.y, this);
for( Apple apple : apples ) {
if ( apple.isAlive ) {
g.drawImage(apple.image, apple.x, apple.y, this);
g.setColor(Color.RED);
g.drawString("Score: " + score, WIDTH/2-30, 10);
private static void createAndShowGUI() {
JFrame frame = new JFrame("Vimsies Retarded Apple Game");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new VimsiesRetardedAppleGamePanel());
frame.pack();
frame.setSize(WIDTH, HEIGHT);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
createAndShowGUI();
}Hey Vimsie, try resetting a dead apple and see what happens. -
Getting the label of a JButton in a for loop
hi,
I doing a project for my course at the minute and im in need of a bit of help. I have set up 1-d array of buttons and i have layed them out using a for loop. I have also added an annoymous action listener to each button in the loop. It looks something lke this:
b = new JButton[43];
for (int i=1; i<43; i++)
b[i] = new JButton(" ");
b.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent e)
System.out.println("..........");
}); // addActionListener
} // for
I want the "System.out.println( ..." line, to print out the "i" number of the button that was pressed but i cannot figure out how to do it. I cannot put "System.out.println(" "+i);" as it wont recognise i as it is not inside the for loop. Does anyone have any suggestions?
Thanks!!class ButtonExample extends JFrame implements ActionListener{The OP wanted to have anonymous listeners, not a subclassed JFrame
listening to the buttons. I don't know if the following is the best design,
since the poster has revealed so little, but here is how to pass the
loop index to an anonymous class.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonExample {
private JButton[] buttons = new JButton[24];
public JPanel createGUI() {
JPanel gui = new JPanel(new GridLayout(6, 4));
for(int i=0; i<buttons.length; i++) {
final int ii = i; //!! !
buttons[i] = new JButton("button #" + i);
buttons.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
System.out.println("number " + ii);
gui.add(buttons[i]);
return gui;
public static void main(String[] args) {
ButtonExample app = new ButtonExample();
JPanel gui = app.createGUI();
JFrame f = new JFrame("ButtonExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(gui);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true); -
How to pass the sequence number of current loop in a for loop in FPGA vi to the host
PCI-7830R
LV 8.2
What I was trying to do is to use multiple DIO to generate pulse at different sequence. Mode one is to automatically sweep from DIO1 to DIO20; mode 2 is several DIOs generate pulse simoutaneously. So I use a case structure to make the selection, in the mean time, I set up two for loop in each case so that I can use multiple pulse generations. For example, in scanning mode, if I set 2 exposures, it sweeps from 1 to 20 then do it again.
Then I need to get the loop sequence number, i of each scenario. So I put an indicator within the first loop, and create a local variable of it and put in the second one. Running the FPGA vi alone, I can see the indicator change in each case from 0 to N-1, N being the for loop time.But in the host vi, I tried to add this indicator as an element in the read/write invoke method, in the debugging mode, I could only see it directly jump to N-1 without all the changes I saw in FPGA vi.
Is it possible to get this number passed correctly from FPGA vi to the host vi? ThanksThanks for the reply Jared.
Excuse me if it looks incorrect, but I'm new to FPGA programming, so I would have to look into the FIFO you referred to. I used local variables because for one thing I have several different cases containing for loop in each of them, and I only want one indicator for the "i". If I put the indicator out of any for loop, it's only gonna show the last number which is N-1. For the other thing, it seems like property nodes are not allowed in FPGA vi. And by doing this, I can see the i number changing from 0 to N-1 in each case, well, in FPGA vi's front panel. But while I ran the host vi with everything, the indicator in host vi's front panel only showed the last number N-1. It may be the reason you said, it happened too fast before the indicator in host vi can catch it.
What I want to realize is to group the data I collect in host vi, for example, when I choose multiple exposure in each mode, and the FPGA runs 1 through 20 then do it again, I want the data stored in two groups using the loop sequence number as the seperator in file name. So it goes like 1-1, 2-1.......20-1; then 1-2, 2-2,.....20-2. -
How do we use if statement in labview?moreover can i use if statement inside for loop?
how do we use if statement in labview?moreover can i use if statement inside for loop?
The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
Attachments:
For_Loop_with_Case.jpg 21 KB -
Select statement in a for loop
Hi all,
Can a select stmt be used in the body of the for loop/ nested for loop ?
I tries using (even if its very simple for loop) it gives the following error
PL/SQL: ORA-00933: SQL command not properly ended...
code is
DECLARE
CURSOR C1 is select 'Monday' from dual
union all
select 'Tuesday' from dual
union all
select 'Wednesday' from dual
union all
select 'Thursday' from dual
union all
select 'Friday' from dual
union all
select 'Saturday' from dual
union all
select 'Sunday' from dual;
type rec_info is record
name varchar2(20),
FNAME varchar2(20),
LNAME varchar2(20)
type ty_info is table of rec_info;
info ty_info;
type rec_abc is record
day varchar2(3000)
type ty_abc is table of rec_abc;
abc ty_abc;
Cursor C2 is
select t.name, u.first_name, u.last_name
from territories t, users u, territories_users tu
where t.ID = tu.TERRITORY_ID
and tu.USER_ID = u.ID ;
BEGIN
OPEN C1;
Loop
FETCH C1 into abc;
EXIT when C1%notfound;
DBMS_OUTPUT.PUT_LINE(abc);
END LOOP;
CLOSE C1;
OPEN C2;
FETCH C2 BULK COLLECT into info;
CLOSE C2;
for i in info.first .. info.last
LOOP
for j in abc.first .. abc.last
LOOP
select --info(i).name, info(i).FNAME, info(i),LNAME,'AM' "AM/PM",
to_char(c.name)||' '||ct.PRIMARY_ADDRESS_CITY||','||ct.PRIMARY_ADDRESS_STATE||','||ct.PRIMARY_ADDRESS_COUNTRY
from
territories t, territories_users tu,
users u, calls_users cu, calls c,
calls_contacts cc, contacts ct
where
tu.TERRITORY_ID = t.id
and t.name = info(i).name
and u.first_name = info(i).FNAME
and u.last_name = info(i).LNAME
and (c.date_start between trim(next_day(sysdate,abc(j).day)) and trim(next_day(sysdate,abc(j).day)))
and tu.USER_ID = u.id
and cu.USER_ID = u.id
and cu.CALL_ID = c.id
and to_char(c.time_start,'hh24') < '12'
and cc.CALL_ID = c.ID
and cc.CONTACT_ID = ct.id
and rownum < 2
END LOOP;
END LOOP;
END;"Can a select stmt be used in the body of the for loop/ nested for loop "
Yes.... but with an INTO part.....
select c1 , c2 , c3 into var1 , var2 , var3 from table1
Sim -
If statement doesn't affect for loop
I wrote a function within a function to control 2 Tweens.
(the 2nd one isnt in the function, it's called)
My problem is... is that it works for the first time.. the button is hovered over and all the other buttons show themselves and then disappear again, except the one you're over. Then I do it a 2nd time and it doesn't work. why is it only working right one time? and why isn't the if statement I put in the local function affecting the for loop? The 2nd time it takes the button you're hovering over with it and fades it out. (even though the if statement registers according to trace)
this is the code
import fl.transitions.Tween;
import fl.transitions.easing.*;
var shortInst:Array = [btn1, btn2, btn3, exit];
var objTween:Tween;
function mouseOff(e:Event):void {
if (e.currentTarget.alpha !== 0) {
objTween = new Tween(e.currentTarget, "alpha", None.easeOut, 1, 0, 0.25, true);
var eTimer:Timer = new Timer(3000, 1); //timer that only runs once (in ms)
function navFX(e:Event):void {
for (var i:Number = 0; i < shortInst.length; i++) {
objTween = new Tween(shortInst[i], "alpha", None.easeOut, 0, 1, 0.25, true);
eTimer.addEventListener(TimerEvent.TIMER, local);
eTimer.start();
function local(t:TimerEvent):void {
trace("e.target in local func: " + e.target);
for (var i:Number = 0; i < shortInst.length; i++) {
if (shortInst[i] !== e.target) {
shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));is this what you want?
import fl.transitions.Tween;
import fl.transitions.easing.*;
var shortInst:Array = [btn1,btn2,btn3,exit];
var objTween:Tween;
function mouseOff(e:Event):void
if (e.currentTarget.alpha !== 0)
objTween = new Tween(e.currentTarget,"alpha",None.easeOut,1,0,0.25,true);
function navFX(e:Event):void
var eTimer:Timer = new Timer(3000,1); // <- moved that line here
for (var i:Number = 0; i < shortInst.length; i++)
objTween = new Tween(shortInst[i],"alpha",None.easeOut,0,1,0.25,true);
eTimer.addEventListener(TimerEvent.TIMER, local);
eTimer.start();
function local(t:TimerEvent):void
trace("e.target in local func: " + e.target);
for (var i:Number = 0; i < shortInst.length; i++)
if (shortInst[i] !== e.target)
shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));
for (var i:Number = 0; i < shortInst.length; i++)
shortInst[i].alpha = 0;
shortInst[i].addEventListener(MouseEvent.MOUSE_OVER, navFX);
shortInst[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOff); -
Help with Mathscipt and for loop
I have a code in Mathscript/matlab and I need to output the array out. One option is my first code,the other option is using a for loop, but I am only getting the last ouput out. I need to get the whole output out.
Any help.
Thanks
Solved!
Go to Solution.
Attachments:
Help with Mathscript_for loop.vi 115 KB
Help with Mathscript_for loop2.vi 84 KBHere's how it should look like.
Message Edited by altenbach on 10-30-2008 05:12 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
MathscriptInFOR.png 15 KB -
Why use cursor and for loop?
Hi All
So in general why would we use a cursor and a for loop to do update in a stored procedure?
Why wouldnt we just use a single update statement ?
is there compelling reason for using a cursor and a for loop: I am reading some code from a co-worker that the business logic for the select (set need to be updated) is complex but the update logic is simple (just set a flag to (0 or 1 or 2 or 3 or 4).
But eventually the select come down to a key (row_id) so I re-write it using just a single sql statement.
The size of the main table is about 2.6 to 3million rows
Any thoughts on that??
The code below I just do a google for cursor for update example in case for something to play with
-Thanks for all your input
create table f (a number, b varchar2(10));
insert into f values (5,'five');
insert into f values (6,'six');
insert into f values (7,'seven');
insert into f values (8,'eight');
insert into f values (9,'nine');
commit;
create or replace procedure wco as
cursor c_f is
select a,b from f where length(b) = 5 for update;
v_a f.a%type;
v_b f.b%type;
begin
open c_f;
loop
fetch c_f into v_a, v_b;
exit when c_f%notfound;
update f set a=v_a*v_a where current of c_f;
end loop;
close c_f;
end;
exec wco;
select * from f;
drop table f;
drop procedure wco;
Joining multiple tables
create table numbers_en (
id_num number primary key,
txt_num varchar2(10)
insert into numbers_en values (1, 'one' );
insert into numbers_en values (2, 'two' );
insert into numbers_en values (3, 'three');
insert into numbers_en values (4, 'four' );
insert into numbers_en values (5, 'five' );
insert into numbers_en values (6, 'six' );
create table lang (
id_lang char(2) primary key,
txt_lang varchar2(10)
insert into lang values ('de', 'german');
insert into lang values ('fr', 'french');
insert into lang values ('it', 'italian');
create table translations (
id_num references numbers_en,
id_lang references lang,
txt_trans varchar2(10) not null
insert into translations values (1, 'de', 'eins' );
insert into translations values (1, 'fr', 'un' );
insert into translations values (2, 'it', 'duo' );
insert into translations values (3, 'de', 'drei' );
insert into translations values (3, 'it', 'tre' );
insert into translations values (4, 'it', 'quattro');
insert into translations values (6, 'de', 'sechs' );
insert into translations values (6, 'fr', 'six' );
declare
cursor cur is
select id_num,
txt_num,
id_lang,
txt_lang,
txt_trans
from numbers_en join translations using(id_num)
left join lang using(id_lang)
for update of translations.txt_trans;
rec cur%rowtype;
begin
for rec in cur loop
dbms_output.put (
to_char (rec.id_num , '999') || ' - ' ||
rpad (rec.txt_num , 10 ) || ' - ' ||
rpad(nvl(rec.txt_trans, ' '), 10 ) || ' - ' ||
rec.id_lang || ' - ' ||
rpad (rec.txt_lang , 10 )
if mod(rec.id_num,2) = 0 then
update translations set txt_trans = upper(txt_trans)
where current of cur;
dbms_output.put_line(' updated');
else
dbms_output.new_line;
end if;
end loop;
end;
/Edited by: xwo0owx on Apr 25, 2011 11:23 AMAdding my sixpence...
PL/SQL is not that different from a SQL perspective than any other SQL client language like Java or C# or C/C++. PL/SQL simply integrates the 2 languages a heck of a lot better and far more transparent than the others. But make no mistake in that PL/SQL is also a "client" language from a SQL perspective. The (internal) calls PL/SQL make to the SQL engine, are the same (driver) calls made to the SQL engine when using Java and C and the others.
So why a cursor and loops in PL/SQL? For the same reason you have cursors and loops in all these other SQL client languages. There are the occasion that you need to pull data from the SQL engine into the local language to perform some very funky and complex processing that is not possible using the SQL language.
The danger is using client cursor loop processing as the norm - always pulling rows into the client language and crunching it there. This is not very performant. And pretty much impossible to scale. Developers in this case views the SQL language as a mere I/O interface for reading and writing rows. As they would use the standard file I/O read() and write() interface calls.
Nothing could be further from the truth. SQL is a very advance and sophisticated data processing language. And it will always be faster than having to pull rows to a client language and process them there. However, SQL is not Turing complete. It is not the procedural type language that most other languages we use, are. For that reason there are things that we cannot do in SQL. And that should be the only reason for using the client language, like PL/SQL or the others, to perform row crunching using a client cursor loop. -
How to add cursor and for loop
PROCEDURE "TEST" is
bala number;
ins1 number;
ins2 number;
BEGIN
select sum(bal) into bala from (select sum(acp.acp_totbal) bal,acp_instruid from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum!='SG030001'
group by acp_instruid
union
select sum(acp.acp_totbal) bal,acp_instruid from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and acp_acntnum!='SG030001'
and acp_instruid=c_srm_prntinsid
group by acp_instruid)view1;
dbms_output.put_line(bala);
select acp_instruid into ins1 from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum='SG030001';
dbms_output.put_line('principal'||ins1);
select acp_instruid into ins2 from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and acp_acntnum='SG030001'
and acp_instruid=c_srm_prntinsid;
dbms_output.put_line('parent'||ins2);
update cs_acpos_bkp
set acp_totbal=-bala
where acp_instruid=ins2
and acp_acntnum='SG030001';
END;
i have written this code,i need to use cursor and for loops to get more than one rows and update also.
if there are more than 1 rows in cs_strmap_t,then the procedure throws an error stating that it cannot take 2 rows.
Edited by: 850836 on Apr 7, 2011 11:43 PMPROCEDURE "TEST" is
bala number;
ins1 number;
ins2 number;
CURSOR cur_1 IS
select sum(bal) bala from (select sum(acp.acp_totbal) bal,acp_instruid from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum='SG030001'
group by acp_instruid
union
select sum(acp.acp_totbal) bal,acp_instruid from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and acp_acntnum='SG030001'
and acp_instruid=c_srm_prntinsid
group by acp_instruid)view1;
BEGIN
select acp_instruid into ins1 from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum='SG030001';
dbms_output.put_line('principal'||ins1);
select acp_instruid into ins2 from cs_strmap_t map,cs_instru_strips strip,cs_acpos_bkp acp
where c_int_instruid=c_srm_prncplinsid
and acp_acntnum='SG030001'
and acp_instruid=c_srm_prntinsid;
dbms_output.put_line('parent'||ins2);
for var_for in cur_1
loop
update cs_acpos_bkp
set acp_totbal=var_for.bala
where acp_instruid=ins2
and acp_acntnum='SG030001'
and abs(acp_totbal)>abs(bala);
dbms_output.put_line(bala);
end loop;
END;
i wrote the following procedure,but the balance is not getting updated.
Getting this errors when there are more than 1 row in cs_strmap_t table
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: line 22
ORA-06512: at line 2 -
How to ignore error and continue with next value in PL/SQL FOR loop?
hi,
When the DROP INDEX statement fails it have to continue with the next value in FOR loop without exiting from the loop. Can anyone tell me how to do this?
DECLARE
CURSOR aud_cur IS
SELECT key_col_idx FROM audience_work where aud_ref_id between 106 and 109;
BEGIN
FOR aud_row IN aud_cur LOOP
EXECUTE IMMEDIATE
'DROP INDEX ' || aud_row.key_col_idx;
END LOOP;
END;
Thanks,
NobleDECLARE
CURSOR aud_cur
IS
SELECT key_col_idx FROM audience_work where aud_ref_id between 106 and 109;
BEGIN
FOR aud_row IN aud_cur LOOP
begin
EXECUTE IMMEDIATE 'DROP INDEX ' || aud_row.key_col_idx;
exception
when others then
if sqlcode = -01418 then
dbms_output.put_line(' index does not exist ');
else
dbms_output.put_line(sqlcode);
raise;
end if;
end;
END LOOP;
END;
/
Maybe you are looking for
-
Trying To Understand My Masters Situation
I have over 40,000 photos managed by Aperture. They include a mixture of my old iPhoto library and purely Aperture images. They are managed as referenced masters. I wish to move the photos to a new hard drive and have come to a puzzling issue which I
-
Is there a time limit for importing clips?
It seems like any clip that I have thats over 4 minutes causes it to fail. I checked my System settings and the limitation is not selected. In addition is there some kind of event log where I can find out why something has failed?
-
Image stacking (z-index) flex 3.5
Hi This is probably a really simple question, well I hope so, but I cant figure out how to have an image over top of another. The senario is Im making a banner. I want the left image to be layered over top of the right image. Thanks for any advice.
-
Reeal-time 3D graph with multiple plots
Hello, I realise this is a very complicated question and I would appreciate any healp anyone could give. I am trying to: 1- draw a 3D graph with three plots (plots are from coordinates read from XL) 2- do it in real time, so that only one point from
-
I can't find my sound board drive
Hello, I have bought a Sound Blaster Audigy SB0570 (I wrote down the product information from it, before it had been installing on PC) but the driver is not listed, I can't get any sound and the board is properly installed. Could any good soul help m