473,472 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sql while break error

18 New Member
Hi, I have developed a VB script which loops and updates the values in multiple fields by utilising dynamically naming the field name within a loop.

The procedure works correctly in MS Access and I am now trying to port it to SQL. I have managed to get the script to work down to the green highlighted text in the attached Word doc, but from there on I have an issue with a WHILE loop and a BREAK command.

Can anyone assist me with this?
Attached Files
File Type: docx NAR.docx (13.6 KB, 185 views)
Nov 20 '16 #1

✓ answered by jforbes

When you use branching statements, they typically only execute the Next Statement. If you want them to include multiple Statements, you need to use a BEGIN and END to delineate what Statements to include in the Branch statement.

The Example from Break:
Expand|Select|Wrap|Line Numbers
  1. WHILE ((SELECT AVG(ListPrice) FROM dbo.DimProduct) < $300)  
  2. BEGIN  
  3.     UPDATE DimProduct  
  4.         SET ListPrice = ListPrice * 2;  
  5.      IF ((SELECT MAX(ListPrice) FROM dbo.DimProduct) > $500)  
  6.          BREAK;  
  7. END 
The BEGIN and END group the two statements together, then the WHILE can act on both Statements.

Also, for future reference, please use the use the [CODE/] button and post the code inline with your Question, it makes it much, much easier to Address.

1 686
jforbes
1,107 Recognized Expert Top Contributor
When you use branching statements, they typically only execute the Next Statement. If you want them to include multiple Statements, you need to use a BEGIN and END to delineate what Statements to include in the Branch statement.

The Example from Break:
Expand|Select|Wrap|Line Numbers
  1. WHILE ((SELECT AVG(ListPrice) FROM dbo.DimProduct) < $300)  
  2. BEGIN  
  3.     UPDATE DimProduct  
  4.         SET ListPrice = ListPrice * 2;  
  5.      IF ((SELECT MAX(ListPrice) FROM dbo.DimProduct) > $500)  
  6.          BREAK;  
  7. END 
The BEGIN and END group the two statements together, then the WHILE can act on both Statements.

Also, for future reference, please use the use the [CODE/] button and post the code inline with your Question, it makes it much, much easier to Address.
Nov 20 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bfence | last post by:
This should be really simple but I just can't get it to work right. I'm trying to create a report (no code involved on my part) that prints details about different schools each on a different page....
4
by: MZaza | last post by:
That's a calculator and there is an option which should convert the result you got to binary, but when I try to do so I get a Windows error stating that the applications has encountered an error.....
5
by: Adam Pelling | last post by:
I'm getting this error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/neblncbt/public_html/forum/includes/acp/acp_board.php on line 69 Here is the...
1
by: hakitazara | last post by:
i'm using order.php to input the data and I am trying to create an additional data entry page from order.php and name the file as order_process.php When I run the script I get the error message...
4
by: Phillis2013 | last post by:
#include <stdlib.h> #include <stdio.h> #include <ctime> #include <string> #include <iostream> using namespace std; int main() { srand ( time(NULL) ); string face;
2
by: pedrus | last post by:
Hi, I'm trying to compile a program (forgeG assembler) but I stuck with the following errors: makeHash.cc:230:21: error: conflicting declaration ‘std::vector<ClipInfo2>& clipInfo’...
1
by: xobserver | last post by:
hi my frnds i wish someone can help me with this error i have highlighted the errors in block letters i want urgent help plz .. i must give project tomorrow #include<fstream.h>...
5
Ajay Bhalala
by: Ajay Bhalala | last post by:
Hello all, I have write the code (program) for the Single Linked List using C Language. Here is my program... //Program of Single Linked List #include<stdio.h> #include<conio.h>...
3
by: AffinityCreate | last post by:
Hi I am trying to add the DS1307 to my project via I2C using both a keypad and LCD. So far I have been able to get my project working with a passcode entry, led, keypad input and LCD display. I as...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.