Support Article
Segment creation fails with generating segment SQL error
SA-84019
Summary
Pega Marketing for Communications (PMC) 8.2 is installed on Pega Platform 8.2.2.
The User class (TF-Data-Customer) is created and mapped to a table that is present in an external database.
The Context Dictionary is saved successfully. However, when creating a Segment, the application creates the Segment table in the external database instead of the ExternalMKTData database schema. Hence, error occurs when saving the Segment rule.
Error Messages
Error while generating segment SQL
Trying to save an invalid page: page is not valid
[tp-apr-8080-exec-185] [TABTHREAD2] [ ] [PEGTEST:01.01.01] (mkt_engine_segmentmktutilities) ERROR xxxx-xxx-xxx.xxxx.xxx|xx.xx.xx.xxx Pega01 - SegmentMKTUtilities.GenerateSegmentSQL - Exception determining segment primary key column: com.pega.pegarules.pub.database.NonexistentTableException: Database-NonexistentTable public.MKTSEGTestSegD TFCustData
at com.pega.pegarules.data.internal.store.TableInformationMapImpl.lookupColumnInfo(TableInformationMapImpl.java:602) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.store.TableInformationMapImpl.lookupRdbTableInfo(TableInformationMapImpl.java:448) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.store.TableInformationMapImpl.lookupTableInfo(TableInformationMapImpl.java:392) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.store.TableInformationMapImpl.getDataStoreTableInfo(TableInformationMapImpl.java:361) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.access.DatabaseImpl.getDataStoreTableInfo(DatabaseImpl.java:1879) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.access.DatabaseImpl.getColumnObjForProperty(DatabaseImpl.java:1860) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.access.DatabaseImpl.getColumnObjForProperty(DatabaseImpl.java:3294) ~[prprivate.jar:?]
at com.pega.pegarules.data.internal.access.DatabaseImpl.getColumnForProperty(DatabaseImpl.java:3240) ~[prprivate.jar:?]
at com.pegarules.generated.GenerateSegmentSQL_080101_5076995666310348241.GenerateSegmentSQL08_01_01(GenerateSegmentSQL_080101_5076995666310348241.java:159) ~[?:?]
at com.pegarules.generated.GenerateSegmentSQL_080101_5076995666310348241.invoke(GenerateSegmentSQL_080101_5076995666310348241.java:91) ~[?:?]
at com.pega.pegarules.generation.internal.library.LibraryRuntime.resolveAndinvokeFunctionViaReflection(LibraryRuntime.java:222) ~[prprivate.jar:?]
at com.pega.pegarules.generation.internal.library.LibraryRuntime.invokeLibraryRuntime(LibraryRuntime.java:119) ~[prprivate.jar:?]
at com.pega.pegarules.generation.internal.library.LibraryFunctionUtilityImpl.resolveMethodCall(LibraryFunctionUtilityImpl.java:2924) ~[prprivate.jar:?]
at com.pega.pegarules.session.internal.mgmt.Executable.resolveMethodCall(Executable.java:11481) ~prprivate.jar:?]
at com.pegarules.generated.activity.ra_action_generatesegmentsql_4ba4f875d2c761c341078065aeb40e2d.step8_circum0(ra_action_generatesegmentsql_4ba4f875d2c761c341078065aeb40e2d.java:702) ~[?:?]
at com.pegarules.generated.activity.ra_action_generatesegmentsql_4ba4f875d2c761c341078065aeb40e2d.perform(ra_action_generatesegmentsql_4ba4f875d2c761c341078065aeb40e2d.java:192) ~[?:?]
at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:2695) ~[prprivate.jar:?] at com.pega.pegarules.session.internal.mgmt.Executable.invokeActivity(Executable.java:10961) ~[prprivate.jar:?]
at com.pegarules.generated.activity.ra_action_pypostsave_c3e79c2cf04b956d03883347c3a111fb.step30_circum0(ra_action_pypostsave_c3e79c2cf04b956d03883347c3a111fb.java:2838) ~[?:?]
at com.pegarules.generated.activity.ra_action_pypostsave_c3e79c2cf04b956d03883347c3a111fb.perform(ra_action_pypostsave_c3e79c2cf04b956d03883347c3a111fb.java:613) ~[?:?]
at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:2695) ~[prprivate.jar:?]
at com.pega.pegarules.session.internal.mgmt.Executable.invokeActivity(Executable.java:10961) ~[prprivate.jar:?]
at com.pegarules.generated.activity.ra_action_save_1765956ec9d9264ff34c241ca68fbe82.step26_circum0(ra_action_save_1765956ec9d9264ff34c241ca68fbe82.java:2355) ~[?:?]
at com.pegarules.generated.activity.ra_action_save_1765956ec9d9264ff34c241ca68fbe82.perform(ra_action_save_1765956ec9d9264ff34c241ca68fbe82.java:558) ~[?:?]
at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:2695) ~[prprivate.jar:?] at com.pega.pegarules.session.internal.mgmt.Executable.invokeActivity(Executable.java:10961) ~[prprivate.jar:?]
at com.pegarules.generated.activity.ra_action_wbsave_ab70d2da4859d3e70b63184d28817b5f.step5_circum0(ra_action_wbsa
Steps to Reproduce
- Open the Pega Marketing portal.
- Navigate to Audiences and create a segment.
- Save the segment rule. Error occurs.
Root Cause
An issue in the custom application code or rules.
The User class must be mapped to a table present in the schema which is mapped to the ExternalMKTData database rule in the Pega application. The ExternalMKTData database rule is Pega's entry point to all Marketing artifacts. In this case, the User class is mapped to a table that is present in an external database connected by Pega through a separate database rule. ExternalMKTData is a data-admin-database instance which is used to identify where the user creates segments, batchoutput tables, query user tables, and the location of a number of other key tables.
The user must create a Join between these entities during various points of processing when Pega Marketing is working. Hence, the must be in the same instance. Since using one DB-admin-db instance (ExternalMKTData), it uses one schema repeatedly. It is the expectation that the schema (and database instance) for the user data, the mkt_customer_segments table, and the schema that the user creates segment tables in, are all the same. Therefore, one database instance and one schema hosts all.
Resolution
Perform the following local-change:
Map the User class to a table present in the schema that is mapped to the ExternalMKTData database rule.
The PegaRULES, PegaDATA and ExternalMKTData schemas must exist in the same database because a few of the Pega Marketing features require executing cross schema Join queries (which do not work if the schemas are in different databases).
Published August 19, 2019 - Updated December 2, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.