Special features of working with PostgreSQL
General recommendations
-
Create triggers, views, and functions using the
DROP ... IF EXISTSexpression (if needed, you can use theCASCADEcommand), then theCREATE OR REPLACEexpression. Do not use theCREATE OR REPLACEcommand 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
BOOLtype instead of theBITtype used in Microsoft SQL. You do not have to use theWHERE "boolColumn" = trueexpression to match the value of aBOOLtype field. You can use theWHERE "boolColumn"orWHERE NOT "boolColumn"expression instead. -
You can use the short form of the
::TEXTexplicit conversion. -
String matching in PostgreSQL is case-sensitive. You can use the
iLIKEkeyword to execute a case-insensitive matching. Note that matching that uses this keyword is slower than matching that uses theUPPER+LIKEexpression. TheUPPER+LIKEexpression has less strict index applicability rules thaniLIKE. -
You can use the
CREATE CASTcommand 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
NESTLEVELfunction. -
Use the
NAMEtype in PostgreSQL instead of theSYSNAMEtype used in Microsoft SQL. -
Create rules instead of empty
INSTEADtriggers. For example:CREATE RULE RU_VwAdministrativeObjects AS
ON UPDATE TO "VwAdministrativeObjects"
DO INSTEAD NOTHING; -
Convert
INTtype toBOOLtype explicitly. Implicit conversion ofINTtype toBOOLtype does not work in PostgreSQL if the correspondingCASTstatement is present and theUPDATEcommand 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
BOOLtype.
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)