1. Johann Lessmann
  2. PowerBuilder
  3. Monday, 1 October 2018 09:45 AM UTC

Hi,

I'm trying to call a PostgreSQL function that returns a string,
but I get only the first character of the returned string !?!

Does anyone has a hint how to resolve this problem?

Johann

 

this is my  test-code:


--Postgres:----------------------------------------------------

CREATE OR REPLACE FUNCTION get_string()
    RETURNS text
    LANGUAGE 'plpgsql'
AS $BODY$
 BEGIN
  RETURN 'myText';
 END;
$BODY$;

 

--local external functions section in my transaction-object----------------

function string get_string() RPCFUNC

 

---PB-Script ---------------------------------------------------

string ls_text
//ls_text = space(256)
ls_text =  sqlca.get_string()
Messagebox("String", "The returned string is: " + ls_text)

 

-- the resulting Messagebox ---------------------------------------------------

---------------------------
String
---------------------------
The returned string is: m
---------------------------
OK  
---------------------------

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 1 October 2018 15:30 PM UTC
  2. PowerBuilder
  3. # Permalink

You didn't mention the version of PowerBuilder you are using. Official support of PostgreSQL started with 2017-R2 and was improved in 2017-R3.

Not knowing anything about PostgreSQL, I'll go out on a limb and suggest Unicode/Ansi issues.

Comment
  1. John Fauss
  2. Monday, 1 October 2018 18:45 PM UTC
This appears to me to be a Unicode/Ansi issue, as Roland suggests, particularly because the PostgreSQL function's return value ("myText") begins with the lowercase letter "m". If the database is sending Unicode and the as yet undisclosed PB database driver is expecting Ansi, the two-byte "m" might interpret the null code page byte as a string terminator. Some additional information such as the PB version and which PB database driver you are using would be extremely helpful to know.
  1. Helpful
There are no comments made yet.
Johann Lessmann Accepted Answer Pending Moderation
  1. Tuesday, 2 October 2018 06:40 AM UTC
  2. PowerBuilder
  3. # 1

Thank you!

I changed the ODBC-Driver to Unicode and it works :-) 

I don't know why someone selected the ANSI-Driver ….

Comment
There are no comments made yet.
Johann Lessmann Accepted Answer Pending Moderation
  1. Tuesday, 2 October 2018 06:24 AM UTC
  2. PowerBuilder
  3. # 2

Thank you for your hints! I'll check this….

We are using:

PB 2017 R3 Build 1858,

PostgreSQL 10.4, compiled by Visual C++ build 1800, 64-bit

and the PostgreSQL ANSI ODBC Driver (psqlODBC)

 

 

Comment
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.