Solved

Break error when using Pro*C insert

Posted on 2004-10-13
10
1,181 Views
Last Modified: 2011-10-03
I have a very strange problem.

I have a Pro*c insert statement...

EXEC SQL INSERT INTO....

when I compile I get error

1506-056 (S) Break statement cannot be placed outside a while, do, for, or switch statement.

Not only does the line to which the error points not have a Break statement, there isnt even a break statement in the entire function!!

Anyone come across this before or have any suggestions about any debug I can do?

Julian
0
Comment
Question by:stummj
  • 4
  • 4
  • 2
10 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 12298976
stummj:

check out this link , it has a nice intro about how to execute sql inside proc*c:

http://www-db.stanford.edu/~ullman/fcdb/oracle/or-proc.html



0
 
LVL 23

Expert Comment

by:seazodiac
ID: 12298983
I bet it's still some synax requirement you have not made it right ...
0
 

Author Comment

by:stummj
ID: 12299130
Ive looked in the *.c file and there is indeed a break statement in about the right area, but it isnt in the .pc file
Very strange.
0
 

Author Comment

by:stummj
ID: 12299272
follow up. I now think the fact that I have a break in the .c file is a red herring. It looks like every time a host variable is used, you get this statement at the end of the block...  if (sqlca.sqlcode == 1403) break;

0
 
LVL 22

Expert Comment

by:earth man2
ID: 12299273
try defining the following
EXEC SQL WHENEVER SQLWARNING CONTINUE;
EXEC SQL WHENEVER SQLERROR CONTINUE;
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
ID: 12299296
this is probably it add the following statement
EXEC SQL WHENEVER NOT FOUND CONTINUE;
0
 

Author Comment

by:stummj
ID: 12299571
Amazing!!! OK That works ... but why!
What is it not finding? It isnt a select its an insert.
0
 
LVL 22

Expert Comment

by:earth man2
ID: 12299618
Pro*C is just a program it is just applying  macro processing to produce compilable c code.

If you havn't defined what to do WHENEVER NOT FOUND it is just expanding it's default rule into the c code.

You are supposing Pro*C is more sophisticated than it really is.
0
 
LVL 22

Expert Comment

by:earth man2
ID: 12299651
From Oracle Docs
An INSERT can return NOT FOUND if no rows have been inserted.
0
 

Author Comment

by:stummj
ID: 12299663
Thanks Earthman - where did you find that in the Oracle Docs?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now