Database Reference
In-Depth Information
return 'hello %s !' % name
Finally, let's test how this works:
hannu=# select hello('world');
hello
---------------
hello world !
(1 row)
And yes, it returns exactly what is expected!
Data type conversions
The first and last things happening when a PL function is called by PostgreSQL
are converting argument values between the PostgreSQL and PL types. The Post-
greSQL types need to be converted to the PL types on entering the function, and
then the return value needs to be converted back into the PostgreSQL type.
Except for PL/pgSQL, which uses PostgreSQL's own native types in computations,
the PLs are based on existing languages with their own understanding of what types
(integer, string, date, …) are, how they should behave, and how they are represen-
ted internally. They are mostly similar to PostgreSQL's understanding but quite often
are not exactly the same. PL/Python converts data from PostgreSQL type to Python
types as shown in the following table:
Python
2
Python
3
PostgreSQL
Comments
int2 , int4
int
int
int8
long int
Search WWH ::




Custom Search