Link to home
Start Free TrialLog in
Avatar of bluecomet
bluecomet

asked on

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
Avatar of NMi
NMi

... so you say that after that faulty insert your sqlca.sqlcode is not -1 ?!
Avatar of bluecomet

ASKER

yes, sqlcode is 0.
Are you using a datawindow or a SQL statemen in a script?
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().
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?
ASKER CERTIFIED SOLUTION
Avatar of EAServer
EAServer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Can you post your insert sentence here? maybe this way we could note which is the problem.
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?
Why isn't an error fired when you insert an null value in an not null value field?