Special features of working with PostgreSQL
General recommendations
-
Create triggers, views, and functions using the
DROP ... IF EXISTS
expression (if needed, you can use theCASCADE
command), then theCREATE OR REPLACE
expression. Do not use theCREATE OR REPLACE
command alone. -
Use
"public"
instead of the"dbo"
schema. -
Note that system names are case-sensitive. Use quotes (
""
) for names of tables, columns, and other entities. -
Use the
BOOL
type instead of theBIT
type used in Microsoft SQL. You do not have to use theWHERE "boolColumn" = true
expression to match the value of aBOOL
type field. You can use theWHERE "boolColumn"
orWHERE NOT "boolColumn"
expression instead. -
You can use the short form of the
::TEXT
explicit conversion. -
String matching in PostgreSQL is case-sensitive. You can use the
iLIKE
keyword to execute a case-insensitive matching. Note that matching that uses this keyword is slower than matching that uses theUPPER+LIKE
expression. TheUPPER+LIKE
expression has less strict index applicability rules thaniLIKE
. -
You can use the
CREATE CAST
command to cast types if source code has no implicit type casting. Learn more about the type casting in the official PostgreSQL documentation. -
Create a special procedure parameter to store the current recursion level because PostgreSQL recursive procedures do not have a built-in
NESTLEVEL
function. -
Use the
NAME
type in PostgreSQL instead of theSYSNAME
type used in Microsoft SQL. -
Create rules instead of empty
INSTEAD
triggers. For example:CREATE RULE RU_VwAdministrativeObjects AS
ON UPDATE TO "VwAdministrativeObjects"
DO INSTEAD NOTHING; -
Convert
INT
type toBOOL
type explicitly. Implicit conversion ofINT
type toBOOL
type does not work in PostgreSQL if the correspondingCAST
statement is present and theUPDATE
command is executed. -
Use allowed ways to format string literals. Learn more about string literals in the official PostgreSQL documentation (quote_ident, quote_literal, format).
-
Use the following expression
DECLARE rowsCount BIGINT = 0;
GET DIAGNOSTICS rowsCount = row_count;instead of
@@ROWCOUNT
. -
Use the following expression
EXISTS (
SELECT 1
FROM "SysSSPEntitySchemaAccessList"
WHERE "EntitySchemaUId" = BaseSchema."UId"
) "IsInSSPEntitySchemaAccessList"instead of the following Microsoft SQL expression
(CASE
WHEN EXISTS
(SELECT 1
FROM [SysSSPEntitySchemaAccessList]
WHERE [SysSSPEntitySchemaAccessList].[EntitySchemaUId] = [BaseSchemas].[UId] ) THEN 1
ELSE 0
END) AS [IsInSSPEntitySchemaAccessList]The response field will have a
BOOL
type.
Data type matching
Creatio, Microsoft SQL, and PostgreSQL data type matching
Type value in the Creatio object Designer | Data type | |
---|---|---|
Microsoft SQL | PostgreSQL | |
BLOB |
|
|
Boolean |
|
|
Color |
|
|
CRC |
|
|
Currency |
|
|
Date |
|
|
Date/Time |
|
|
Decimal (0.00000001) |
|
|
Decimal (0.0001) |
|
|
Decimal (0.001) |
|
|
Decimal (0.01) |
|
|
Decimal (0.1) |
|
|
Encrypted string |
|
|
File |
|
|
Image |
|
|
Image Link |
|
|
Integer |
|
|
Lookup |
|
|
Text (250 characters) |
|
|
Text (50 characters) |
|
|
Text (500 characters) |
|
|
Time |
|
|
Unique identifier |
|
|
Unlimited length text |
|
|
See also
Resources
Official PostgreSQL documentation (cast types)
Official PostgreSQL documentation (quote_ident)