- hatem moalla
- PowerBuilder
- Sunday, 25 February 2024 01:18 PM UTC
hello everyone here
in my powerbuilder 19 project, it's about article management. so when i insert a new article it works fine and when I update an article it works fine also but when I insert another article (after the update), i get the sqlstate error 23000 duplicated primary key reference = "the reference of the article that i inserted first" even though that the reference does not exist.
note : reference column is primary key; not auto increment and is not null
here is the script of "new" button
char reference
dwc_article.scrolltorow(dwc_article.insertrow(0))
// Scroll to the newly inserted row
long ll_new_row
ll_new_row = dwc_article.InsertRow(0)
dwc_article.ScrollToRow(ll_new_row)
// Get the current date
date ld_date_creation
ld_date_creation = today()
string ls_formatted_date
ls_formatted_date = String(ld_date_creation, "yyyy-mm-dd")
// Set the current date to the "date_de_creation" column
dwc_article.SetItem(ll_new_row, "date_de_creation", ls_formatted_date)
dwc_article.modify("reference.Protect='0'") // This removes input capability from all columns
dwc_article.modify("name.Protect='0'")
dwc_article.modify("prix.Protect='0'")
dwc_article.modify("date_de_creation.Protect='1'")
and here is the script of "save new article" button
dwc_article.accepttext()
dwc_article.update()
int li_sqlcode
commit using sqlca;
// Check for SQL errors
li_sqlcode = sqlca.sqlcode
if li_sqlcode = 0 then
MessageBox("Success", "The article was successfully added.")
else
MessageBox("Error", "Failed to add the article. SQLCode: ")
end if
// Refresh the report
dwc_report.Retrieve()
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.