?
Solved

PB error handling with null values when inserting into DB

Posted on 2003-03-25
10
Medium Priority
?
385 Views
Last Modified: 2013-12-26
Hi folks,

here is the scenario:

PB 8.0.3 Build 9704
Oracle 8.1.7

I have a table where fields are defined as "not null".
When i insert NULL in one of this field, no error is fired (without message) on Powerbuilder side and the record is not inserted.
When i do the insert into SQL Plus i got an error!

Why PowerBuilder doesn't handle this error?
What have to do to catch this error? Is that a bug?

Ok what i can do, before inserting, check if the values are given! But when i forgot to check one value and then this value is null, i will never find the error because no errormessage is fired.


$regards
0
Comment
Question by:bluecomet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 2

Expert Comment

by:NMi
ID: 8201776
... so you say that after that faulty insert your sqlca.sqlcode is not -1 ?!
0
 
LVL 2

Author Comment

by:bluecomet
ID: 8201802
yes, sqlcode is 0.
0
 
LVL 5

Expert Comment

by:berXpert
ID: 8203810
Are you using a datawindow or a SQL statemen in a script?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:EAServer
ID: 8204405
bluecomet
If you are using a datawindow and I will assume you are, the SQLCode will not show the error information.  The datawindow traps database errors in the DBError event.  The default behavior of the DBError event will display a messagebox with the error information.  However, if you return 1 from the DBError event the message will not display.  Check you DBError event code. Also check the return value of your dw.Update().
0
 
LVL 2

Author Comment

by:bluecomet
ID: 8208602
I use an SQL Statement and after the insert and commit i check the sqlcode an it is 0. And the sqlerrtext is empty, but no row is inserted. I think with datawindow will not be the problem, only when we use SQL Statemnt with a null value in a field "not null" an no errors are happend! i think it is a bug? Or not?
0
 
LVL 2

Accepted Solution

by:
EAServer earned 100 total points
ID: 8212001
Nope not a bug!

If you are using an SQL statement, then you need to check the SQLCode after the insert AND after the commit.  Chances are the insert fails, and returns error info via the transaction object, but then you commit which succeeds, mostly because there is nothing to commit, and it wipes out the error information with the success results of the commit.

Remember each SQL statement will return results via the transaction object (SQLCA) and overwrite any error information from the previous SQL statement.
0
 
LVL 2

Author Comment

by:bluecomet
ID: 8223349
I verify directly after the Insert SQL Statement my SQLCA and SqlCode and SqlDBCode are 0 and not showing a message: So what can be the problem?
0
 
LVL 5

Expert Comment

by:berXpert
ID: 8225391
Can you post your insert sentence here? maybe this way we could note which is the problem.
0
 
LVL 2

Author Comment

by:bluecomet
ID: 8225660
Her eis the hole code:


string l_elapsetime, l_localhost, l_objet, l_unit
datetime l_date

l_unit = g_unit
l_elapsetime = f_elapsetime(a_start,cpu())
l_localhost = f_get_localhost()
l_date = f_sysdate_time()
l_objet = a_object.getparent().classname()+"."+a_object.classname()
INSERT INTO "PERFORMANCE_LOG"  
          ( "PL_UNITE",  
            "PL_ORD",  
            "PL_OBJET",  
            "PL_TIME",  
            "PL_DH",
            "PL_ID_USER")  
VALUES (:l_unit,  
            :l_localhost,  
            :l_objet,  
            :l_elapsetime,  
            :l_date,
            :g_id_user);
IF SQLCA.SQLCode = -1 THEN
     MessageBox("Erreur",SQLCA.SQLErrText,Exclamation!)
     return 0
END IF
commit;
IF SQLCA.SQLCode = -1 THEN
     MessageBox("Erreur",SQLCA.SQLErrText,Exclamation!)
     return 0
END IF


return 1

when l_unit is null or another variables, no row is inserted and no errors is fired! Why?
0
 
LVL 2

Author Comment

by:bluecomet
ID: 8549165
Why isn't an error fired when you insert an null value in an not null value field?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

762 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