Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powerbuilder says its NULL, but that's no true when I debug it

Status
Not open for further replies.

montjoile

Programmer
May 23, 2011
23
CO
Hi. I am trying to insert an item to a datawindow linked to a table. One of the fields comes from the selection of a dropdownlistbox, that I save in a string variable and insert it to the datawindow.
Once the user have completed to fill all the fields of the datawindow, I do an update, that should reflect in my table. The problem is that powerbuilder says that the field that comes from the dropdownlistbox is null, but that is no true when I debug my program
This is the code Im using:
///////////////////////////////////////////////////////////////
integer i
for i=1 to dw_2.rowcount()
ls_proc_codigo=dw_2.getitemstring(i, 'seg_proc_codigo')
sle_1.text=ls_proc_codigo

dw_1.setitem(dw_1.insertrow(0), 'seg_ane_codigo', ls_ane_codigo)
dw_1.setitem(dw_1.insertrow(0), 'seg_proc_codigo', string(ls_proc_codigo))
dw_1.setitem(dw_1.insertrow(0), 'seg_ane_nombre', ls_ane_nombre)
dw_1.setitem(dw_1.insertrow(0), 'seg_usr_crea', gs_usuario)
dw_1.setitem(dw_1.insertrow(0), 'seg_fech_crea', gd_sysdate)

//messagebox("ls_proc_codigo", ls_proc_codigo)

if dw_1.update()=1 then
COMMIT using SQLCA;
messagebox("Aviso", "registro actualizado")
ELSE
ROLLBACK using SQLCA;
MessageBox("Error","Save failed" + Char(10) + SQLCA.SQLErrText, information!)
END IF
next
///////////////////////////////////////////////////////////////

When I debug this code, I confirm that ls_proc_codigo is not null, but when I do the datawindow update, the database returns me an error saying that Im trying to insert null in a field where goes ls_proc_codigo (seg_proc_codigo).
I have to say that seg_proc_codigo and seg_ane_codigo are the primary key in the table, and ls_proc_codigo is string, and seg_proc_codigo is varchar

Why powerbuilder is saying ls_proc_codigo is null, and when I debug it, I see thats no true?



 
First off, you need to change the series of 'dw_1.insertrow(0)' statements into something like this: ll_row = dw_1.insertrow(0) and then use ll_row in your setitem commands. They way you have it, a new row is inserted for each setitem command.

Also, verify in the Update properties of the datawindow that the column in question is flagged to update the database when saved.

Matt

"Nature forges everything on the anvil of time"
 
thanks mbalent. that was exactly that was happening. I was inserting a new row.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top