PB error handling with null values when inserting into DB

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
LVL 2
bluecometAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
EAServerConnect With a Mentor Commented:
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
 
NMiCommented:
... so you say that after that faulty insert your sqlca.sqlcode is not -1 ?!
0
 
bluecometAuthor Commented:
yes, sqlcode is 0.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
berXpertCommented:
Are you using a datawindow or a SQL statemen in a script?
0
 
EAServerCommented:
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
 
bluecometAuthor Commented:
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
 
bluecometAuthor Commented:
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
 
berXpertCommented:
Can you post your insert sentence here? maybe this way we could note which is the problem.
0
 
bluecometAuthor Commented:
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
 
bluecometAuthor Commented:
Why isn't an error fired when you insert an null value in an not null value field?
0
All Courses

From novice to tech pro — start learning today.