1. Albert van Bochove
  2. PowerBuilder
  3. Thursday, 16 November 2023 17:34 PM UTC

Hello everyone, I have a problem when I am debugging my code, it turns out that the code leads me to display an error message that I am getting after the expected error message. When I press my Search button I am getting the following error: "Invalid character value for cast specification", when really I'm expecting another error message. You can inspect my code that I execute inside my Search function:

IF THIS.inv_Payment.ids_Trans.Retrieve(THIS.is_Name,&
THIS.il_IrsCltId,&
THIS.is_Article, &
THIS.is_PayDate) > 0 THEN

// Share data with object

THIS.inv_Payment.ids_Trans.ShareData(dw_select)

// Set button

cb_Search.Default = FALSE
cb_OK.Default = TRUE
commit using sqlca;
RETURN TRUE

ELSE

gnv_App.of_Message("No matching rows found","Check the number, the client's ID or name")

cb_OK.Default = FALSE
cb_Search.Default = TRUE
commit using sqlca;
RETURN FALSE

END IF

 

In the first IF condition, when it does the Retrieve it is giving me an invalid casting error, but I can't see what I am doing wrong, what type of object is it waiting for, when all I am sending as an argument is a string. at can I be doing wrong? How can I fix or troubleshoot my problem?

Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Friday, 17 November 2023 09:55 AM UTC
  2. PowerBuilder
  3. # 1

Hi Albert,

this seems to be an error generated by the database. Check if the retrieval arguments of the datastore you're retrieving match the column types. I suspect "is_PayDate", which is presumably a string but the name suggests a date so it probably fails to cast whatever string you're feeding it into a date datatype.

Comment
  1. Benjamin Gaesslein
  2. Tuesday, 21 November 2023 13:16 PM UTC
It's hard to tell what's going wrong because it's unclear which of your retrieval argument corresponds to your SQL and what the actual datatypes are.



To find out how to execute stored procedures for your DBMS, look up "DECLARE and EXECUTE" in the Powerbuilder help file.
  1. Helpful 1
  1. Albert van Bochove
  2. Wednesday, 22 November 2023 13:54 PM UTC
@Arnd Schmidt, Yes my stored procedure returns a result set.



The result set is generated by the SELECT statements within each block of the IF-ELSE conditions. The SELECT statements retrieve data from the pay_transaction table, joining with other tables (pay_item, pay_status, and irs_customer) to get additional information. The result set includes columns like id, irs_clt_id, name, paydate, amount, regdate, description, and pay_sts_id.



The conditions in the WHERE clauses of the SELECT statements filter the data based on the input parameters (@name, @idstr, @article, and @date). The specific conditions depend on the combination of parameter values and are structured in a way to handle different scenarios.



It's important to note that this stored procedure is using explicit transactions (BEGIN TRAN and COMMIT TRAN). However, the ROLLBACK TRAN statement is missing in my stored procedure.



In summary, yes, the stored procedure returns a result set based on the SELECT statements executed within the different branches of the IF-ELSE conditions.



the format of my date is mm/dd/yyyy



Thanks in advance for any idea. Now I am looking for how to call my stored procedure in my app directly. I want to do it in the moment of my retreive, well instead of my retrieve , that is my idea
  1. Helpful
  1. Arnd Schmidt
  2. Wednesday, 22 November 2023 15:05 PM UTC
You can build a stored procedure base datawindow.

Depending on your settings

select convert(datetime, '27/12/2023')

can fail, but

select convert(datetime, '27/12/2023', 103)

will do the job.

What is the exact and complete db error message that you get?

Can you execute the SP in the PowerBuilder Database Painter?

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.