• Topic
  • Discussion
  • ODS.VirtRDFViewODSeCRM(Last) -- DAVWikiAdmin? , 2017-06-29 07:34:30 Edit WebDAV System Administrator 2017-06-29 07:34:30

    eCRM RDF Views script

    To reload the transient eCRM RDF Views, run the following script:


    use DB;
    
    SPARQL drop silent quad map virtrdf:ecrmDemo1
    ;
    
    SPARQL drop silent quad map virtrdf:ecrmDemo2
    ;
    
    SPARQL drop silent quad map virtrdf:ecrmDemo3
    ;
    
    create procedure DB.DBA.exec_no_error(in expr varchar)
    {
    	declare state, message, meta, result any;
    	exec(expr, state, message, vector(), 0, meta, result);
    }
    ;
    
    GRANT SELECT ON eCRM.DBA.SFA_SALES_QUOTA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_COMPANIES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CONTACTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_EMPLOYMENTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_LEADS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_OPPORTUNITIES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_DOCUMENTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_INFLUENCERS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_TEAMS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_NOTES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_COMPETITORS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ISSUES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CUSTOM_FIELD_DEFS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CUSTOM_FIELDS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CASES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ORDERS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ORDER_ITEMS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATEGORIES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCT_ATTRIBUTE_DEFS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCT_ATTRIBUTES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATALOGS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATALOG_PRODUCTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_MODULES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_REGISTRY TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_ORGANIZATIONS_DATA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_MESSAGES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_COUNTRIES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_PROVINCES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_TIMEZONES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_MIME_TYPES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_MIME_EXTENSIONS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_CNAMES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_QUOTAS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_ROLES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_ACCOUNTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_USERDATA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_GROUPDATA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_MEMBERS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_SESSIONS_DATA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_SESSION_DATA TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_LIST_MEMBERS_DEFS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_CLASSES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_ORG_CLASSES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_CLASS_METHODS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_CLASS_VIEWS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_ROLE_PRIVILEGES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_USER_PRIVILEGES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_HISTORY TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_USERS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_SALES_QUOTA  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_COMPANIES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CONTACTS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_EMPLOYMENTS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_LEADS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_OPPORTUNITIES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ACTIVITIES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_MAIL_MESSAGES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_DOCUMENTS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_INFLUENCERS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_TEAMS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_NOTES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_COMPETITORS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ISSUES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CUSTOM_FIELD_DEFS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CUSTOM_FIELDS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_CASES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ORDERS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.SFA_ORDER_ITEMS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATEGORIES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCT_ATTRIBUTE_DEFS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCTS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_PRODUCT_ATTRIBUTES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATALOGS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.PM_CATALOG_PRODUCTS  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_COUNTRIES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.XSYS_PROVINCES  TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_PROCESSES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_PROCESSES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_OBJECTS TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_RULES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_RULES TO "SPARQL"
    ;
    GRANT SELECT ON eCRM.DBA.AP_QUEUE TO "SPARQL"
    ;
    create function DB.DBA.ECRM_CONTACT_NAME (in fname varchar, in lname varchar)
    {
    	declare tmp varchar;
    	tmp := 'Noname';
    	if (fname is not null)
    		tmp := fname;
    	if (lname is not null)
    		tmp := trim(concat(tmp, ' ', lname));
    	return tmp;
    }
    ;
    grant execute on DB.DBA.ECRM_CONTACT_NAME to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_CONTACT_NAME_INV_1 (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, '%s %s', 0);
    		if (parts is not null)
    			return parts[0];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_CONTACT_NAME_INV_1 to SPARQL_SELECT                                                 
    ;
    create function DB.DBA.ECRM_CONTACT_NAME_INV_2 (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, '%s %s', 0);
    		if (parts is not null)
    			return parts[1];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_CONTACT_NAME_INV_2 to SPARQL_SELECT                                                 
    ;
    
    create function DB.DBA.ECRM_DBPEDIA_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('http://dbpedia.org/resource/%U', name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_DBPEDIA_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_DBPEDIA_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, 'http://dbpedia.org/resource/%U', 0);
    		if (parts is not null)
    			return parts[0];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_DBPEDIA_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    
    create function DB.DBA.ECRM_TEL_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('tel:%s', name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_TEL_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_TEL_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, 'tel:%s', 0);
    		if (parts is not null)
    			return parts[0];
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_TEL_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    
    create function DB.DBA.ECRM_CALLTO_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('callto:%s', name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_CALLTO_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_CALLTO_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, 'callto:%s', 0);
    		if (parts is not null)
    			return parts[0];
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_CALLTO_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    create function DB.DBA.ECRM_MBOX_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('mailto:%s', name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_MBOX_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_MBOX_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, 'mailto:%s', 0);
    		if (parts is not null)
    			return parts[0];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_MBOX_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    
    create function DB.DBA.ECRM_USER_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('http://%s/dataspace/%U', registry_get ('URIQADefaultHost'), name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_USER_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_USER_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, sprintf('http://%s/dataspace/%%U', registry_get ('URIQADefaultHost')), 0);
    		if (parts is not null)
    			return parts[0];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_USER_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    
    create function DB.DBA.ECRM_ORDER_ID_LIT (in id integer)
    {
        return cast(id as varchar);
    }
    ;
    
    grant execute on DB.DBA.ECRM_ORDER_ID_LIT to SPARQL_SELECT
    ;
    
    create function DB.DBA.ECRM_ORDER_ID_LIT_INVERSE (in id_lit varchar)
    {
      if (id_lit is not null)
        {
            return atoi(id_lit);
        }
      return NULL;
    }
    ;
    
    grant execute on DB.DBA.ECRM_ORDER_ID_LIT_INVERSE to SPARQL_SELECT
    ;
    
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:SalesQuota "http://^{URIQADefaultHost}^/ecrm/SalesQuota/%d/%d#this" (in ORG_ID integer, in SALES_QUOTA_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Company "http://^{URIQADefaultHost}^/ecrm/Company/%U/%U/%d#this" (in COMPANY_NAME varchar, in COMPANY_ID number, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Contact "http://^{URIQADefaultHost}^/ecrm/Contact/%U/%d#this" (in CONTACT_ID number, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Employment "http://^{URIQADefaultHost}^/ecrm/Employment/%U/%U/%U/%d#this" (in DEPARTMENT varchar, in COMPANY_ID varchar, in CONTACT_ID number, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Lead "http://^{URIQADefaultHost}^/ecrm/Lead/%U/%d/%U#this" (in SNAME varchar, in ORG_ID integer, in LEAD_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:CustomFieldDef "http://^{URIQADefaultHost}^/ecrm/CustomFieldDef/%d/%d#this" (in ORG_ID integer, in EMPLOYMENT_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:CustomField "http://^{URIQADefaultHost}^/ecrm/CustomField/%d/%U/%d#this" (in ORG_ID integer, in EMPLOYMENT_ID number, in ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Opportunity "http://^{URIQADefaultHost}^/ecrm/Opportunity/%d/%U#this" (in ORG_ID integer, in OPPORTUNITY_ID number) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Case "http://^{URIQADefaultHost}^/ecrm/Case/%d/%U#this" (in ORG_ID integer, in CASE_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Note "http://^{URIQADefaultHost}^/ecrm/Note/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Activity "http://^{URIQADefaultHost}^/ecrm/Activity/%d/%U/%U#this" (in ORG_ID integer, in ACT_ID varchar, in OBJ_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:MailMessage "http://^{URIQADefaultHost}^/ecrm/MailMessage/%d/%U/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar, in EMPLOYMENT_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Document "http://^{URIQADefaultHost}^/ecrm/Document/%d/%U/%U" (in ORG_ID integer, in EMPLOYMENT_ID varchar, in EMPLOYMENT_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Influencer "http://^{URIQADefaultHost}^/ecrm/Influencer/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Team "http://^{URIQADefaultHost}^/ecrm/Team/%d/%U/%U#this" (in ORG_ID integer, in OPPORTUNITY_ID number, in CONTACT_ID number) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Competitor "http://^{URIQADefaultHost}^/ecrm/Competitor/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Issue "http://^{URIQADefaultHost}^/ecrm/Issue/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Order "http://^{URIQADefaultHost}^/ecrm/Order/%d/%U#this" (in ORG_ID integer, in ORDER_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:OrderItem "http://^{URIQADefaultHost}^/ecrm/OrderItem/%d/%U#this" (in ORG_ID integer, in ORDER_ITEM_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Category "http://^{URIQADefaultHost}^/ecrm/Category/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID  varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ProductAttributeDef "http://^{URIQADefaultHost}^/ecrm/ProductAttributeDef/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Product "http://^{URIQADefaultHost}^/ecrm/Product/%d/%U#this" (in ORG_ID integer, in PRODUCT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ProductAttribute "http://^{URIQADefaultHost}^/ecrm/ProductAttribute/%d/%U/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar, in ORG_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Catalog "http://^{URIQADefaultHost}^/ecrm/Catalog/%d/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:CatalogProduct "http://^{URIQADefaultHost}^/ecrm/CatalogProduct/%d/%U/%U#this" (in ORG_ID integer, in EMPLOYMENT_ID varchar, in EMPLOYMENT_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Module "http://^{URIQADefaultHost}^/ecrm/Module/%d#this" (in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Registry "http://^{URIQADefaultHost}^/ecrm/Registry/%U#this" (in ORG_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:OrganizationsData "http://^{URIQADefaultHost}^/ecrm/OrganizationsData/%d/%U#this" (in ORG_ID integer, in DNS_ZONE varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Message "http://^{URIQADefaultHost}^/ecrm/Message/%d/%U#this" (in ORG_ID integer, in MSG_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Country "http://^{URIQADefaultHost}^/ecrm/Country/%U#this" (in COUNTRY_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:CompanyAddress "http://^{URIQADefaultHost}^/ecrm/CompanyAddress/%U/%d#this" (in COMPANY_ID number, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ContactAddress "http://^{URIQADefaultHost}^/ecrm/ContactAddress/%U/%d#this" (in COMPANY_ID number, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:LeadAddress "http://^{URIQADefaultHost}^/ecrm/LeadAddress/%U/%d#this" (in COMPANY_ID varchar, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:OrderAddress "http://^{URIQADefaultHost}^/ecrm/OrderAddress/%U/%d#this" (in COMPANY_ID varchar, in ORG_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Province "http://^{URIQADefaultHost}^/ecrm/Province/%U/%U#this" (in COUNTRY_ID varchar, in PROV_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Timezone "http://^{URIQADefaultHost}^/ecrm/Timezone/%U#this" (in COUNTRY_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:MimeType "http://^{URIQADefaultHost}^/ecrm/MimeType/%d#this" (in COUNTRY_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:MimeExtension "http://^{URIQADefaultHost}^/ecrm/MimeExtension/%d/%U#this" (in COUNTRY_ID integer, in COUNTRY_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Cname "http://^{URIQADefaultHost}^/ecrm/Cname/%U#this" (in COUNTRY_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Quota "http://^{URIQADefaultHost}^/ecrm/Quota/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Role "http://^{URIQADefaultHost}^/ecrm/Role/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Account "http://^{URIQADefaultHost}^/ecrm/Account/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:UserData "http://^{URIQADefaultHost}^/ecrm/UserData/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:GroupData "http://^{URIQADefaultHost}^/ecrm/GroupData/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Member "http://^{URIQADefaultHost}^/ecrm/Member/%d/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer, in COUNTRY_ID3 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:SessionsData "http://^{URIQADefaultHost}^/ecrm/SessionsData/%U#this" (in COUNTRY_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:SessionData "http://^{URIQADefaultHost}^/ecrm/SessionData/%U/%d#this" (in COUNTRY_ID varchar, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ListMembersDef "http://^{URIQADefaultHost}^/ecrm/ListMembersDef/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:Class "http://^{URIQADefaultHost}^/ecrm/Class/%U#this" (in COUNTRY_ID varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:OrgClass "http://^{URIQADefaultHost}^/ecrm/OrgClass/%d/%U#this" (in COUNTRY_ID integer, in COUNTRY_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ClassMethod "http://^{URIQADefaultHost}^/ecrm/ClassMethod/%U/%U#this" (in COUNTRY_ID varchar, in COUNTRY_ID2 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:ClassView "http://^{URIQADefaultHost}^/ecrm/ClassView/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:RolePrivelege "http://^{URIQADefaultHost}^/ecrm/RolePrivelege/%d/%d/%U/%U#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer, in COUNTRY_ID3 varchar, in COUNTRY_ID4 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:UserPrivelege "http://^{URIQADefaultHost}^/ecrm/UserPrivelege/%d/%d/%U/%U#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer, in COUNTRY_ID3 varchar, in COUNTRY_ID4 varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:History "http://^{URIQADefaultHost}^/ecrm/History/%d/%d#this" (in COUNTRY_ID integer, in COUNTRY_ID2 integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:XSys_User "http://^{URIQADefaultHost}^/ecrm/XSys_User/%d/%U/%d#this" (in ORG_ID integer, in ACCOUNT_NAME varchar, in ACCOUNT_ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:AP_Process "http://^{URIQADefaultHost}^/ecrm/AP_Process/%d/%U#this" (in ORG_ID integer, in AP_ID number) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:AP_Rule "http://^{URIQADefaultHost}^/ecrm/AP_Rule/%d/%U/%d#this" (in ORG_ID integer, in AP_ID number, in RSEQ integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:AP_Queue "http://^{URIQADefaultHost}^/ecrm/AP_Queue/%d#this" (in ID integer) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:SalesRep "http://^{URIQADefaultHost}^/ecrm/SalesRep/%d/%U#this" (in ORG_ID integer, in SALESREP varchar) option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:isDefinedBy "http://www.openlinksw.com/ontology/ecrm#" () option (BIJECTION)
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create literal class ecrm:OrderLabel "%d" (in ORDER_NO varchar) option (BIJECTION)
    ;
    
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:vendor_iri using
    	function DB.DBA.ECRM_VENDOR_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_VENDOR_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    create function DB.DBA.ECRM_VENDOR_URI (in name varchar)
    {
    	if (name is not NULL)
    		return sprintf('http://data.openlinksw.com/oplweb/vendor/%U', name);
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_VENDOR_URI to SPARQL_SELECT                                                 
    ;                                                                                                      
    create function DB.DBA.ECRM_VENDOR_URI_INVERSE (in name varchar)
    {
    	declare parts any;
    	if (isstring(name))
    	{
    		parts := sprintf_inverse(name, 'http://data.openlinksw.com/oplweb/vendor/%U', 0);
    		if (parts is not null)
    			return parts[0];	
    	}
    	return NULL;
    }
    ;
    grant execute on DB.DBA.ECRM_VENDOR_URI_INVERSE to SPARQL_SELECT                                                 
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:sioc_user_iri using
    	function DB.DBA.ECRM_USER_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_USER_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:mbox_iri using
    	function DB.DBA.ECRM_MBOX_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_MBOX_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:tel_iri using
    	function DB.DBA.ECRM_TEL_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_TEL_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:callto_iri using
    	function DB.DBA.ECRM_CALLTO_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_CALLTO_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create iri class ecrm:dbpedia_iri using
    	function DB.DBA.ECRM_DBPEDIA_URI (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_DBPEDIA_URI_INVERSE (in name varchar) returns varchar
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create literal class ecrm:contact_name_literal using
    	function DB.DBA.ECRM_CONTACT_NAME (in fname varchar, in lname varchar) returns varchar ,
    	function DB.DBA.ECRM_CONTACT_NAME_INV_1 (in name varchar) returns varchar ,
    	function DB.DBA.ECRM_CONTACT_NAME_INV_2 (in name varchar) returns varchar 
    	option(BIJECTION) .
    ;
    SPARQL prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    create literal class ecrm:order_lit using
      function DB.DBA.ECRM_ORDER_ID_LIT (in id integer) returns varchar ,
      function DB.DBA.ECRM_ORDER_ID_LIT_INVERSE (in id_iri varchar) returns integer
      option (BIJECTION) .
    ;
    
    SPARQL
    prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    prefix sioc: <http://rdfs.org/sioc/ns#>
    prefix OpenLink: <http://www.openlinksw.com/schemas/oplweb#>
    prefix gr: <http://purl.org/goodrelations/v1#>
    prefix foaf: <http://xmlns.com/foaf/0.1/>
    prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
    prefix cal: <http://www.w3.org/2002/12/cal/ical#>
    prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
    prefix product: <http://www.swop-project.eu/ontologies/pmo/product.owl#>
    prefix owl: <http://www.w3.org/2002/07/owl#>
    prefix relationship: <http://purl.org/vocab/relationship/>
    alter quad storage virtrdf:DefaultQuadStorage
    from eCRM.DBA.SFA_SALES_QUOTA as sales_quotas
    from eCRM.DBA.SFA_COMPANIES as companies text literal companies.DESCRIPTION
    from eCRM.DBA.SFA_CONTACTS as contacts text literal contacts.NAME_FIRST
    from eCRM.DBA.SFA_EMPLOYMENTS as employments
    from eCRM.DBA.SFA_LEADS as leads text literal leads.SUBJECT
    from eCRM.DBA.SFA_OPPORTUNITIES as opportunities text literal opportunities.OPPORTUNITY_NAME
    from eCRM.DBA.SFA_ACTIVITIES as activities
    from eCRM.DBA.SFA_MAIL_MESSAGES as messages
    from eCRM.DBA.SFA_DOCUMENTS as documents
    from eCRM.DBA.SFA_INFLUENCERS as influencers
    from eCRM.DBA.SFA_TEAMS as teams
    from eCRM.DBA.SFA_NOTES as notes text literal notes.DESCRIPTION
    from eCRM.DBA.SFA_COMPETITORS as competitors
    from eCRM.DBA.SFA_ISSUES as issues
    from eCRM.DBA.SFA_CUSTOM_FIELD_DEFS as custom_field_defs
    from eCRM.DBA.SFA_CUSTOM_FIELDS as custom_fields
    from eCRM.DBA.SFA_CASES as cases text literal cases.SUMMARY
    from eCRM.DBA.SFA_ORDERS as orders text literal orders.EMAIL
    from eCRM.DBA.SFA_ORDER_ITEMS as order_items
    from eCRM.DBA.PM_CATEGORIES as categories
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTE_DEFS as product_attribute_defs
    from eCRM.DBA.PM_PRODUCTS as products text literal products.DESCRIPTION
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTES as product_attributes
    from eCRM.DBA.PM_CATALOGS as catalogs
    from eCRM.DBA.PM_CATALOG_PRODUCTS as catalog_products
    from eCRM.DBA.XSYS_MODULES as modules
    from eCRM.DBA.XSYS_REGISTRY as registries
    from eCRM.DBA.XSYS_ORGANIZATIONS_DATA as organizations_data
    from eCRM.DBA.XSYS_MESSAGES as xsysmessages
    from eCRM.DBA.XSYS_COUNTRIES as countries
    from eCRM.DBA.XSYS_PROVINCES as provinces
    from eCRM.DBA.XSYS_TIMEZONES as timezones
    from eCRM.DBA.XSYS_MIME_TYPES as mimetypes
    from eCRM.DBA.XSYS_MIME_EXTENSIONS as mimeexts
    from eCRM.DBA.XSYS_CNAMES as cnames
    from eCRM.DBA.XSYS_QUOTAS as quotas
    from eCRM.DBA.XSYS_ROLES as roles
    from eCRM.DBA.XSYS_ACCOUNTS as accounts
    from eCRM.DBA.XSYS_USERDATA as userdatas
    from eCRM.DBA.XSYS_GROUPDATA as groupdatas
    from eCRM.DBA.XSYS_MEMBERS as members
    from eCRM.DBA.XSYS_SESSIONS_DATA as sessionsdatas
    from eCRM.DBA.XSYS_SESSION_DATA as sessiondatas
    from eCRM.DBA.XSYS_LIST_MEMBERS_DEFS as list_members_defs
    from eCRM.DBA.XSYS_CLASSES as classes
    from eCRM.DBA.XSYS_ORG_CLASSES as org_classes
    from eCRM.DBA.XSYS_CLASS_METHODS as class_methods
    from eCRM.DBA.XSYS_CLASS_VIEWS as class_views
    from eCRM.DBA.XSYS_ROLE_PRIVILEGES as role_priveleges
    from eCRM.DBA.XSYS_USER_PRIVILEGES as user_priveleges
    from eCRM.DBA.XSYS_HISTORY as history
    from eCRM.DBA.XSYS_USERS as xsys_users
    from eCRM.DBA.AP_PROCESSES as ap_processes
    from eCRM.DBA.AP_RULES as ap_rules
    from eCRM.DBA.AP_QUEUE as ap_queues
    where (^{companies.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{contacts.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{leads.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{products.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{orders.}^.SHIP_COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    {
    	create virtrdf:ecrmDemo1 as graph iri ("http://^{URIQADefaultHost}^/ecrm") option (order 1501)
        {
    		ecrm:CompanyAddress (companies.COMPANY_ID, companies.ORG_ID)
    			a vcard:work;
    			rdfs:label 'Address' ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			vcard:Country companies.COUNTRY_NAME;
    			vcard:Region companies.PROVINCE;
    			vcard:Locality companies.CITY;
    			vcard:Pcode companies.POSTAL_CODE;
    			vcard:Street companies.ADDRESS1;
    			vcard:Extadd companies.ADDRESS2 .
    			
    		ecrm:ContactAddress (contacts.CONTACT_ID, contacts.ORG_ID)
    			a vcard:Address;
    			rdfs:label 'Address' ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			vcard:Country contacts.COUNTRY_NAME;
    			vcard:Region contacts.PROVINCE;
    			vcard:Locality contacts.CITY;
    			vcard:Pcode contacts.POSTAL_CODE;
    			vcard:Street contacts.ADDRESS1;
    			vcard:Extadd contacts.ADDRESS2 .
    			
    		ecrm:LeadAddress (leads.LEAD_ID, leads.ORG_ID)
    			a vcard:Address;
    			rdfs:label 'Address' ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			vcard:Country leads.COUNTRY_NAME;
    			vcard:Region leads.PROVINCE;
    			vcard:Locality leads.CITY;
    			vcard:Pcode leads.POSTAL_CODE;
    			vcard:Street leads.ADDRESS1;
    			vcard:Extadd leads.ADDRESS2 .
    			
    		ecrm:OrderAddress (orders.ORDER_ID, orders.ORG_ID)
    			a vcard:Address;
    			rdfs:label 'Ship Address' ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			vcard:Country orders.SHIP_COUNTRY_NAME;
    			vcard:Region orders.SHIP_PROVINCE;
    			vcard:Locality orders.SHIP_CITY;
    			vcard:Pcode orders.SHIP_POSTAL_CODE;
    			vcard:Street orders.SHIP_ADDRESS1;
    			vcard:Extadd orders.SHIP_ADDRESS2 .	
    	
    		ecrm:Country (countries.COUNTRY_NAME)
    			a ecrm:Country
    				as virtrdf:Country-Countrys2 ;
    			a geo:SpatialThing
    				as virtrdf:Country-Countrys ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			rdfs:label countries.COUNTRY_NAME ;
    			geo:lat    countries.LAT ;
    			geo:long   countries.LNG ;
    			owl:sameAs ecrm:dbpedia_iri (countries.COUNTRY_NAME) ;
    			ecrm:countryID countries.COUNTRY_ID
    				as virtrdf:Country-COUNTRY_ID ;
    			ecrm:countryID3 countries.COUNTRY_ID3
    				as virtrdf:Country-COUNTRY_ID3 ;
    			ecrm:isoCode countries.ISO_CODE
    				as virtrdf:Country-ISO_CODE ;
    			ecrm:countryName countries.COUNTRY_NAME
    				as virtrdf:Country-COUNTRY_NAME .
    				
    		ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    			ecrm:is_province_of ecrm:Country (countries.COUNTRY_NAME)
    				where (^{countries.}^.COUNTRY_ID = ^{provinces.}^.COUNTRY_ID)
    				as virtrdf:ecrmProvince-is_province_of .
    
    		ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    			a ecrm:Province
    				as virtrdf:ecrmProvince-Provinces2 ;
    			a geo:SpatialThing
    				as virtrdf:ecrmProvince-Provinces ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			owl:sameAs ecrm:dbpedia_iri (provinces.PROVINCE_NAME) ;
    			geo:lat    provinces.LAT ;
    			geo:long   provinces.LNG ;
    			rdfs:label provinces.PROVINCE_NAME ;
    			ecrm:provinceID provinces.PROVINCE_ID
    				as virtrdf:Province-PROVINCE_ID ;
    			ecrm:provinceName provinces.PROVINCE_NAME
    				as virtrdf:ecrmProvince-PROVINCE_NAME .
    
    		ecrm:Country (countries.COUNTRY_NAME)
    			ecrm:has_province ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    				where (^{provinces.}^.COUNTRY_ID = ^{countries.}^.COUNTRY_ID)
    				as virtrdf:ecrmCountry-has_province .
    
    		ecrm:SalesQuota (sales_quotas.ORG_ID, sales_quotas.QUOTA_ID)
    			a ecrm:SalesQuota
    			    as virtrdf:SalesQuota-SalesQuotas ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{sales_quotas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:SalesQuota-ORG_ID ;
    			ecrm:has_user ecrm:UserData(members.ORG_ID, sales_quotas.USER_ID)
    				as virtrdf:SalesQuota-USER_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{sales_quotas.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{sales_quotas.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:SalesQuota-OWNER_ID ;
    			ecrm:fromDate sales_quotas.FROM_DATE
    				as virtrdf:SalesQuota-FROM_DATE ;
    			ecrm:toDate sales_quotas.TO_DATE
    				as virtrdf:SalesQuota-TO_DATE ;
    			ecrm:quotaValue sales_quotas.QUOTA_VALUE
    				as virtrdf:SalesQuota-QUOTA_VALUE ;
    			ecrm:objectives sales_quotas.OBJECTIVES
    				as virtrdf:SalesQuota-OBJECTIVES .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:SalesQuota (sales_quotas.ORG_ID, sales_quotas.QUOTA_ID)
    				where (^{sales_quotas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:SalesQuota-is_ecrm_org_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:SalesQuota (sales_quotas.ORG_ID, sales_quotas.QUOTA_ID)
    				where (^{sales_quotas.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{sales_quotas.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:SalesQuota-account_manager .
    
    		ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    			a  ecrm:Company
    				as virtrdf:Company-Companys2 ;
    			a gr:BusinessEntity
    				as virtrdf:grBusinessEntity-Companys ;
    			a  foaf:Organization
    				as virtrdf:Company-Companys ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			rdfs:label companies.COMPANY_NAME ;
    			rdfs:comment companies.DESCRIPTION ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{companies.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Company-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{companies.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{companies.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Company-OWNER_ID ;
    			ecrm:FREETEXT_ID companies.FREETEXT_ID
    				as virtrdf:Company-FREETEXT_ID ;
    			foaf:name companies.COMPANY_NAME
    				as virtrdf:foafCompany-COMPANY_NAME ;
    			gr:legalName companies.COMPANY_NAME
    				as virtrdf:foafCompany-COMPANY_NAME2 ;
    			ecrm:industry companies.INDUSTRY_NAME
    				as virtrdf:Company-INDUSTRY_NAME ;
    			foaf:homepage companies.URL
    				as virtrdf:foafCompany-URL ;
    			foaf:phone ecrm:tel_iri(companies.PHONE_NUMBER)
    				as virtrdf:foafCompany-PHONE_NUMBER ;
    			ecrm:phoneExtension companies.PHONE_EXTENSION
    				as virtrdf:Company-PHONE_EXTENSION ;
    			ecrm:faxNumber ecrm:tel_iri(companies.FAX_NUMBER)
    				as virtrdf:Company-FAX_NUMBER ;
    			ecrm:faxExtension companies.FAX_EXTENSION
    				as virtrdf:Company-FAX_EXTENSION ;
    			ecrm:mobileNumber ecrm:tel_iri(companies.MOBILE_NUMBER)
    				as virtrdf:Company-MOBILE_NUMBER ;
    			foaf:mbox ecrm:mbox_iri(companies.EMAIL)
    				as virtrdf:foafCompany-EMAIL ;
    			ecrm:email_text companies.EMAIL
    				as virtrdf:Companies-EMAIL-TEXT ;
    			ecrm:country ecrm:Country(companies.COUNTRY_NAME)
    				as virtrdf:Company-COUNTRY ;
    			ecrm:province ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    				where (^{companies.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Company-PROVINCE ;
    			ecrm:city ecrm:dbpedia_iri (companies.CITY)
    				as virtrdf:Company-dbpedia_CITY ;
    			ecrm:postalCode companies.POSTAL_CODE
    				as virtrdf:Company-POSTAL_CODE ;
    			ecrm:address1 companies.ADDRESS1
    				as virtrdf:Company-ADDRESS1 ;
    			ecrm:address2 companies.ADDRESS2
    				as virtrdf:Company-ADDRESS2 ;
    			vcard:ADR ecrm:CompanyAddress (companies.COMPANY_ID, companies.ORG_ID)
    				as virtrdf:Company-ADR ;
    			ecrm:description companies.DESCRIPTION
    				as virtrdf:Company-DESCRIPTION .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				where (^{companies.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Company-is_ecrm_org_of .
    				
    		ecrm:Country (companies.COUNTRY_NAME)
    			ecrm:is_country_of
    				ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				as virtrdf:Company-is_country_of .
    				
    		ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    			ecrm:is_province_of
    				ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				where (^{companies.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Company-is_province_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				where (^{companies.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{companies.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Company-account_manager .
    
    		ecrm:CustomFieldDef (custom_field_defs.ORG_ID, custom_field_defs.FIELD_ID)
    			a ecrm:CustomFieldDefs
    				as virtrdf:CustomFieldDef-CustomFieldDefs ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			rdfs:label custom_field_defs.FIELD_NAME;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{custom_field_defs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:CustomFieldDef-ORG_ID ;
    			ecrm:has_class ecrm:Class(custom_field_defs.CLASS_ID)
    				as virtrdf:CustomFieldDef-CLASS_ID ;
    			ecrm:fieldName custom_field_defs.FIELD_NAME
    				as virtrdf:CustomFieldDef-FIELD_NAME ;
    			ecrm:fieldType custom_field_defs.FIELD_TYPE
    				as virtrdf:CustomFieldDef-FIELD_TYPE .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:CustomFieldDef (custom_field_defs.ORG_ID, custom_field_defs.FIELD_ID)
    				where (^{custom_field_defs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:CustomFieldDef-is_ecrm_org_of .
    				
    		ecrm:Class(custom_field_defs.CLASS_ID)
    			ecrm:is_class_of
    				ecrm:CustomFieldDef (custom_field_defs.ORG_ID, custom_field_defs.FIELD_ID)
    				as virtrdf:CustomFieldDef-is_class_of .
    
    		ecrm:CustomField (custom_fields.ORG_ID, custom_fields.OBJ_ID, custom_fields.FIELD_ID)
    			a ecrm:CustomField
    				as virtrdf:CustomField-CustomFields ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{custom_fields.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:CustomField-ORG_ID ;
    			ecrm:OBJ_ID custom_fields.OBJ_ID
    				as virtrdf:CustomField-OBJ_ID ;
    			ecrm:has_field ecrm:CustomFieldDef(custom_fields.ORG_ID, custom_fields.FIELD_ID)
    				as virtrdf:CustomField-FIELD_ID ;
    			ecrm:fieldValue custom_fields.FIELD_VALUE
    				as virtrdf:CustomField-FIELD_VALUE .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:CustomField (custom_fields.ORG_ID, custom_fields.OBJ_ID, custom_fields.FIELD_ID)
    				where (^{custom_fields.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:CustomField-is_ecrm_org_of .
    				
    		ecrm:CustomFieldDef(custom_fields.ORG_ID, custom_fields.FIELD_ID)
    			ecrm:is_custom_field_def_of
    				ecrm:CustomField (custom_fields.ORG_ID, custom_fields.OBJ_ID, custom_fields.FIELD_ID)
    				as virtrdf:CustomField-is_custom_field_def_of .
    
    		ecrm:Note (notes.ORG_ID, notes.NOTE_ID)
    			a ecrm:Note
    				as virtrdf:Note-Notes ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			rdfs:comment notes.DESCRIPTION;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE) 
    				where (^{notes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Note-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{notes.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{notes.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Note-OWNER_ID ;
    			ecrm:FREETEXT_ID notes.FREETEXT_ID
    				as virtrdf:Note-FREETEXT_ID ;
    			ecrm:OBJ_ID notes.OBJ_ID
    				as virtrdf:Note-OBJ_ID ;
    			ecrm:REL_ID notes.REL_ID
    				as virtrdf:Note-REL_ID ;
    			ecrm:DESCRIPTION notes.DESCRIPTION
    				as virtrdf:Note-DESCRIPTION .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Note (notes.ORG_ID, notes.NOTE_ID)
    				where (^{notes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Note-is_ecrm_org_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Note (notes.ORG_ID, notes.NOTE_ID)
    				where (^{notes.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{notes.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Note-account_manager .
    
    		ecrm:Employment (employments.DEPARTMENT, employments.COMPANY_ID, employments.CONTACT_ID, employments.ORG_ID)
    			a ecrm:Employment
    				as virtrdf:Employment-Employments ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{employments.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Employment-ORG_ID ;
    			rdfs:label employments.TITLE;
    			ecrm:has_company ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				where (^{employments.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{employments.}^.ORG_ID = ^{companies.}^.ORG_ID)
    				as virtrdf:Employment-COMPANY_ID ;
    			ecrm:has_contact ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{employments.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{employments.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Employment-CONTACT_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{employments.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{employments.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Employment-OWNER_ID ;
    			ecrm:EMPLOYMENT_ID employments.EMPLOYMENT_ID
    				as virtrdf:Employment-EMPLOYMENT_ID ;
    			ecrm:department employments.DEPARTMENT
    				as virtrdf:Employment-Department ;
    			ecrm:title employments.TITLE
    				as virtrdf:Employment-TITLE ;
    			ecrm:phoneNumber ecrm:tel_iri(employments.PHONE_NUMBER)
    				as virtrdf:Employment-PHONE_NUMBER ;
    			ecrm:phoneExtension employments.PHONE_EXTENSION
    				as virtrdf:Employment-PHONE_EXTENSION ;
    			ecrm:faxNumber ecrm:tel_iri(employments.FAX_NUMBER)
    				as virtrdf:Employment-FAX_NUMBER ;
    			ecrm:faxExtension employments.FAX_EXTENSION
    				as virtrdf:Employment-FAX_EXTENSION ;
    			ecrm:mobileNumber ecrm:tel_iri(employments.MOBILE_NUMBER)
    				as virtrdf:Employment-MOBILE_NUMBER ;
    			ecrm:email_text employments.EMAIL
    				as virtrdf:Employments-EMAIL-TEXT ;
    			foaf:mbox ecrm:mbox_iri(employments.EMAIL)
    				as virtrdf:Employment-EMAIL .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Employment (employments.DEPARTMENT, employments.COMPANY_ID, employments.CONTACT_ID, employments.ORG_ID)
    				where (^{employments.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Employment-is_ecrm_org_of .
    				
    		ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    			ecrm:is_contact_of
    				ecrm:Employment (employments.DEPARTMENT, employments.COMPANY_ID, employments.CONTACT_ID, employments.ORG_ID)
    				where (^{employments.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{employments.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Employment-is_coontact_of .
    				
    		ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    			ecrm:is_company_of
    				ecrm:Employment (employments.DEPARTMENT, employments.COMPANY_ID, employments.CONTACT_ID, employments.ORG_ID)
    				where (^{employments.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{employments.}^.ORG_ID = ^{companies.}^.ORG_ID)
    				as virtrdf:Employment-is_company_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Employment (employments.DEPARTMENT, employments.COMPANY_ID, employments.CONTACT_ID, employments.ORG_ID)
    				where (^{employments.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{employments.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Employment-account_manager .
    
    		ecrm:Contact (contacts.CONTACT_ID, contacts.ORG_ID)
    			a ecrm:Contact
    				as virtrdf:Contact-Contacts2 ;
    			a foaf:Person
    				as virtrdf:Contact-Contacts ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{contacts.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Contact-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{contacts.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{contacts.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Contact-OWNER_ID ;
    			rdfs:label ecrm:contact_name_literal(contacts.NAME_FIRST, contacts.NAME_LAST);
    			rdfs:comment contacts.DESCRIPTION ;
    			ecrm:FREETEXT_ID contacts.FREETEXT_ID
    				as virtrdf:Contact-FREETEXT_ID ;
    			foaf:title contacts.NAME_TITLE
    				as virtrdf:foafContact-NAME_TITLE ;
    			foaf:firstName contacts.NAME_FIRST
    				as virtrdf:foafContact-NAME_FIRST ;
    			foaf:givenname contacts.NAME_MIDDLE
    				as virtrdf:foafContact-NAME_MIDDLE ;
    			foaf:surname contacts.NAME_LAST
    				as virtrdf:foafContact-NAME_LAST ;
    			foaf:birthday contacts.BIRTH_DATE
    				as virtrdf:foafContact-BIRTH_DATE ;
    			ecrm:contactType contacts.CONTACT_TYPE_TITLE
    				as virtrdf:Contact-CONTACT_TYPE_TITLE ;
    			ecrm:manager ecrm:sioc_user_iri(contacts.MANAGER_NAME)
    				as virtrdf:Contact-MANAGER_NAME ;
    			sioc:User ecrm:sioc_user_iri(contacts.MANAGER_NAME)
    				as virtrdf:siocContact-MANAGER_NAME ;
    			ecrm:business contacts.BUSINESS
    				as virtrdf:Contact-BUSINESS ;
    			foaf:interest contacts.INTEREST
    				as virtrdf:foafContact-INTEREST ;
    			ecrm:open contacts."OPEN"
    				as virtrdf:Contact-OPEN ;
    			ecrm:sourceTitle contacts.SOURCE_TITLE
    				as virtrdf:Contact-SOURCE_TITLE ;
    			foaf:phone ecrm:tel_iri(contacts.PHONE_NUMBER)
    				as virtrdf:foafContact-PHONE_NUMBER ;
    			ecrm:phoneExtension contacts.PHONE_EXTENSION
    				as virtrdf:Contact-PHONE_EXTENSION ;
    			ecrm:phone2Number ecrm:tel_iri(contacts.PHONE2_NUMBER)
    				as virtrdf:Contact-PHONE2_NUMBER ;
    			ecrm:phone2Extension contacts.PHONE2_EXTENSION
    				as virtrdf:Contact-PHONE2_EXTENSION ;
    			ecrm:faxNumber ecrm:tel_iri(contacts.FAX_NUMBER)
    				as virtrdf:Contact-FAX_NUMBER ;
    			ecrm:faxExtension contacts.FAX_EXTENSION
    				as virtrdf:Contact-FAX_EXTENSION ;
    			ecrm:mobileNumber ecrm:tel_iri(contacts.MOBILE_NUMBER)
    				as virtrdf:Contact-MOBILE_NUMBER ;
    			foaf:mbox ecrm:mbox_iri(contacts.EMAIL)
    				as virtrdf:foafContact-EMAIL ;
    			ecrm:email_text contacts.EMAIL
    				as virtrdf:Contact-EMAIL ;
    			ecrm:country ecrm:Country(contacts.COUNTRY_NAME)
    				as virtrdf:Contact-COUNTRY_NAME ;
    			ecrm:province ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    				where (^{contacts.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Contact-PROVINCE ;
    			ecrm:city ecrm:dbpedia_iri (contacts.CITY)
    				as virtrdf:Contact-dbpedia_CITY ;
    			ecrm:postalCode contacts.POSTAL_CODE
    				as virtrdf:Contact-POSTAL_CODE ;
    			ecrm:address1 contacts.ADDRESS1
    				as virtrdf:Contact-ADDRESS1 ;
    			ecrm:address2 contacts.ADDRESS2
    				as virtrdf:Contact-ADDRESS2 ;
    			vcard:ADR ecrm:ContactAddress (contacts.CONTACT_ID, contacts.ORG_ID)
    				as virtrdf:Contact-ADR ;
    			ecrm:description contacts.DESCRIPTION
    				as virtrdf:Contact-DESCRIPTION .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Contact (contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{contacts.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Contact-is_ecrm_org_of .
    				
    		ecrm:Country (contacts.COUNTRY_NAME)
    			ecrm:is_country_of
    				ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				as virtrdf:Contacts-is_country_of .
    				
    		ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    			ecrm:is_province_of
    				ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{contacts.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Contact-is_province_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{contacts.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{contacts.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Contact-account_manager .
    
    		ecrm:Lead (leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    			a ecrm:Lead
    				as virtrdf:Lead-Leads2 ;
    			a foaf:Person
    				as virtrdf:Lead-Leads ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			vcard:ADR ecrm:LeadAddress (leads.LEAD_ID, leads.ORG_ID)
    				as virtrdf:Lead-ADR ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{leads.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Lead-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{leads.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{leads.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Lead-OWNER_ID ;
    			rdfs:label leads.SUBJECT;
    			ecrm:FREETEXT_ID leads.FREETEXT_ID
    				as virtrdf:Lead-FREETEXT_ID ;
    			ecrm:subject leads.SUBJECT
    				as virtrdf:Lead-SUBJECT ;
    			foaf:title leads.NAME_TITLE
    				as virtrdf:foafLead-NAME_TITLE ;
    			foaf:firstName leads.NAME_FIRST
    				as virtrdf:foafLead-NAME_FIRST ;
    			foaf:givenname leads.NAME_MIDDLE
    				as virtrdf:Lead-NAME_MIDDLE ;
    			foaf:surname leads.NAME_LAST
    				as virtrdf:foafLead-NAME_LAST ;
    			ecrm:company leads.COMPANY_NAME
    				as virtrdf:Lead-COMPANY_NAME ;
    			ecrm:has_company ecrm:Company(leads.COMPANY_NAME, leads.COMPANY_ID, leads.ORG_ID)
    				as virtrdf:Lead-COMPANY_ID ;
    			ecrm:REL_ID leads.REL_ID
    				as virtrdf:Lead-REL_ID ;
    			ecrm:leadTitle leads.TITLE
    				as virtrdf:Lead-TITLE ;
    			ecrm:status leads.STATUS
    				as virtrdf:Lead-STATUS ;
    			ecrm:rating leads.RATING
    				as virtrdf:Lead-RATING ;
    			foaf:phone ecrm:tel_iri(leads.PHONE_NUMBER)
    				as virtrdf:foafLead-PHONE_NUMBER ;
    			ecrm:phoneExtension leads.PHONE_EXTENSION
    				as virtrdf:Lead-PHONE_EXTENSION ;
    			ecrm:mobileNumber ecrm:tel_iri(leads.MOBILE_NUMBER)
    				as virtrdf:Lead-MOBILE_NUMBER ;
    			ecrm:faxNumber ecrm:tel_iri(leads.FAX_NUMBER)
    				as virtrdf:Lead-FAX_NUMBER ;
    			ecrm:faxExtension leads.FAX_EXTENSION
    				as virtrdf:Lead-FAX_EXTENSION ;
    			foaf:mbox ecrm:mbox_iri(leads.EMAIL)
    				as virtrdf:foafLead-EMAIL ;
    			ecrm:email_text leads.EMAIL
    				as virtrdf:Leads-EMAIL ;
    			ecrm:country ecrm:Country(leads.COUNTRY_NAME)
    				as virtrdf:Lead-COUNTRY_NAME ;
    			ecrm:province ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    				where (^{leads.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Lead-PROVINCE ;
    			ecrm:city ecrm:dbpedia_iri (leads.CITY)
    				as virtrdf:Lead-dbpedia_CITY ;
    			ecrm:postalCode leads.POSTAL_CODE
    				as virtrdf:Lead-POSTAL_CODE ;
    			ecrm:address1 leads.ADDRESS1
    				as virtrdf:Lead-ADDRESS1 ;
    			ecrm:address2 leads.ADDRESS2
    				as virtrdf:Lead-ADDRESS2 .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Lead (leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    				where (^{leads.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Lead-is_ecrm_org_of .
    				
    		ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    			ecrm:is_company_of
    				ecrm:Lead (leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    				where (^{leads.}^.COMPANY_NAME = ^{companies.}^.COMPANY_NAME and ^{leads.}^.ORG_ID = ^{companies.}^.ORG_ID)
    				as virtrdf:Lead-is_company_of .
    				
    		ecrm:Country (leads.COUNTRY_NAME)
    			ecrm:is_country_of
    				ecrm:Lead(leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    				as virtrdf:Lead-is_country_of .
    				
    		ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
    			ecrm:is_province_of
    				ecrm:Lead(leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    				where (^{leads.}^.PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    				as virtrdf:Lead-is_province_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Lead(leads.SUBJECT, leads.ORG_ID, leads.LEAD_ID)
    				where (^{leads.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{leads.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Lead-account_manager .
    
    		ecrm:Opportunity (opportunities.ORG_ID, opportunities.OPPORTUNITY_ID)
    			a ecrm:Opportunity
    				as virtrdf:Opportunity-Opportunitys2 ;
    			a cal:Vevent
    				as virtrdf:Opportunity-Opportunitys ;
    			rdfs:label opportunities.OPPORTUNITY_NAME;
    		    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{opportunities.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Opportunity-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{opportunities.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{opportunities.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Opportunity-OWNER_ID ;
    			ecrm:FREETEXT_ID opportunities.FREETEXT_ID
    				as virtrdf:Opportunity-FREETEXT_ID ;
    			ecrm:opportunityName opportunities.OPPORTUNITY_NAME
    				as virtrdf:Opportunity-OPPORTUNITY_NAME ;
    			sioc:User ecrm:sioc_user_iri(opportunities.MANAGER_NAME)
    				as virtrdf:siocOpportunity-MANAGER_NAME ;
    			ecrm:manager ecrm:sioc_user_iri(opportunities.MANAGER_NAME)
    				as virtrdf:Opportunity-MANAGER_NAME ;
    			ecrm:has_company ecrm:Company(opportunities.COMPANY_NAME, opportunities.COMPANY_ID, opportunities.ORG_ID)
    				as virtrdf:Opportunity-COMPANY_ID ;
    			ecrm:company opportunities.COMPANY_NAME
    				as virtrdf:Opportunity-COMPANY_NAME ;
    			ecrm:has_contact ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{opportunities.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{opportunities.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Opportunity-CONTACT_ID ;
    			ecrm:contactName opportunities.CONTACT_NAME
    				as virtrdf:Opportunity-CONTACT_NAME ;
    			ecrm:companyRelID opportunities.COMPANY_REL_ID
    				as virtrdf:Opportunity-COMPANY_REL_ID ;
    			ecrm:contactRelID opportunities.CONTACT_REL_ID
    				as virtrdf:Opportunity-CONTACT_REL_ID ;
    			ecrm:forecast opportunities.FORECAST
    				as virtrdf:Opportunity-FORECAST ;
    			ecrm:estimateClose opportunities.ESTIMATE_CLOSE
    				as virtrdf:Opportunity-ESTIMATE_CLOSE ;
    			cal:dtstart opportunities.START_DATE
    				as virtrdf:calOpportunity-START_DATE ;
    			ecrm:startDate opportunities.START_DATE
    				as virtrdf:Opportunity-START_DATE ;
    			ecrm:status opportunities.STATUS
    				as virtrdf:Opportunity-STATUS ;
    			ecrm:code opportunities.CODE
    				as virtrdf:Opportunity-CODE ;
    			ecrm:stageTitle opportunities.STAGE_TITLE
    				as virtrdf:Opportunity-STAGE_TITLE ;
    			ecrm:sourceTitle opportunities.SOURCE_TITLE
    				as virtrdf:Opportunity-SOURCE_TITLE ;
    			ecrm:closedAmount opportunities.CLOSED_AMOUNT
    				as virtrdf:Opportunity-CLOSED_AMOUNT ;
    			cal:dtend opportunities.CLOSED_DATE
    				as virtrdf:calOpportunity-CLOSED_DATE ;
    			ecrm:closedDate opportunities.CLOSED_DATE
    				as virtrdf:Opportunity-CLOSED_DATE ;
    			ecrm:propability opportunities.PROBABILITY
    				as virtrdf:Opportunity-PROBABILITY ;
    			ecrm:potential opportunities.POTENTIAL
    				as virtrdf:Opportunity-POTENTIAL .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Opportunity (opportunities.ORG_ID, opportunities.OPPORTUNITY_ID)
    				where (^{opportunities.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Opportunity-is_ecrm_org_of .
    				
    		ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    			ecrm:is_contact_of
    				ecrm:Opportunity (opportunities.ORG_ID, opportunities.OPPORTUNITY_ID)
    				where (^{opportunities.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{opportunities.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Opportunity-is_contact_of .
    				
    		ecrm:Company (opportunities.COMPANY_NAME, opportunities.COMPANY_ID, opportunities.ORG_ID)
    			ecrm:is_company_of
    				ecrm:Opportunity (opportunities.ORG_ID, opportunities.OPPORTUNITY_ID)
    				as virtrdf:Opportunity-is_company_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Opportunity (opportunities.ORG_ID, opportunities.OPPORTUNITY_ID)
    				where (^{opportunities.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{opportunities.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Opportunity-account_manager .
    
    		ecrm:Case (cases.ORG_ID, cases.CASE_ID)
    			a ecrm:Case
    				as virtrdf:Case-Cases2 ;
    			a cal:Vevent
    				as virtrdf:Case-Cases ;
    			rdfs:label cases.SUMMARY;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{cases.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Case-ORG_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{cases.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{cases.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Case-OWNER_ID ;
    			ecrm:FREETEXT_ID cases.FREETEXT_ID
    				as virtrdf:Case-FREETEXT_ID ;
    			ecrm:summary cases.SUMMARY
    				as virtrdf:Case-SUMMARY ;
    			ecrm:status cases.STATUS
    				as virtrdf:Case-STATUS ;
    			cal:priority cases.PRIORITY
    				as virtrdf:calCase-PRIORITY ;
    			ecrm:priority cases.PRIORITY
    				as virtrdf:Case-PRIORITY ;
    			cal:dtstart cases.OPEN_DATE
    				as virtrdf:calCase-OPEN_DATE ;
    			ecrm:openDate cases.OPEN_DATE
    				as virtrdf:Case-OPEN_DATE ;
    			cal:dtclose cases.LAST_ACTION_DATE
    				as virtrdf:calCase-LAST_ACTION_DATE ;
    			ecrm:lastActionDate cases.LAST_ACTION_DATE
    				as virtrdf:Case-LAST_ACTION_DATE ;
    			ecrm:daysOld cases.DAYS_OLD
    				as virtrdf:Case-DAYS_OLD ;
    			ecrm:has_company ecrm:Company(cases.COMPANY_NAME, cases.COMPANY_ID, cases.ORG_ID)
    				as virtrdf:Case-COMPANY_ID ;
    			ecrm:company cases.COMPANY_NAME
    				as virtrdf:Case-COMPANY_NAME ;
    			ecrm:has_contact ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    				where (^{cases.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{cases.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Case-CONTACT_ID ;
    			ecrm:contactName cases.CONTACT_NAME
    				as virtrdf:Case-CONTACT_NAME ;
    			cal:url cases.URI
    				as virtrdf:calCase-URI ;
    			ecrm:uri cases.URI
    				as virtrdf:Case-URI ;
    			ecrm:application cases.APPLICATION
    				as virtrdf:Case-APPLICATION ;
    			ecrm:appVer cases.APPVER
    				as virtrdf:Case-APPVER ;
    			ecrm:phoneNumber ecrm:tel_iri(cases.PHONE_NUMBER)
    				as virtrdf:Case-PHONE_NUMBER ;
    			ecrm:relationship cases.RELATIONSHIP
    				as virtrdf:Case-RELATIONSHIP ;
    			ecrm:email ecrm:mbox_iri(cases.EMAIL)
    				as virtrdf:Case-EMAIL-FOAF ;
    			ecrm:email_text cases.EMAIL
    				as virtrdf:Case-EMAIL ;
    			ecrm:client ecrm:vendor_iri(cases.CLIENT)
    				as virtrdf:Case-CLIENT ;
    			ecrm:clientVersion cases.CLIENT_VERSION
    				as virtrdf:Case-CLIENT_VERSION ;
    			ecrm:office cases.OFFICE
    				as virtrdf:Case-OFFICE ;
    			ecrm:consultant cases.CONSULTANT
    				as virtrdf:Case-CONSULTANT ;
    			OpenLink:DbmsFamilyVendor ecrm:vendor_iri(cases.DB_VENDOR)
    				as virtrdf:Case-DB_VENDOR ;
    			ecrm:dbVer cases.DB_VER
    				as virtrdf:Case-DB_VER ;
    			ecrm:misTsID cases.MIS_TS_ID
    				as virtrdf:Case-MIS_TS_ID ;
    			ecrm:oplClient cases.OPL_CLIENT
    				as virtrdf:Case-OPL_CLIENT ;
    			ecrm:oplVer cases.OPL_VER
    				as virtrdf:Case-OPL_VER ;
    			ecrm:server ecrm:vendor_iri(cases.SERVER)
    				as virtrdf:Case-SERVER ;
    			ecrm:serverVersion cases.SERVER_VERSION
    				as virtrdf:Case-SERVER_VERSION ;
    			ecrm:downloadDate cases.DOWNLOAD_DATE
    				as virtrdf:Case-DOWNLOAD_DATE ;
    			ecrm:jobTitle cases.JOB_TITLE
    				as virtrdf:Case-JOB_TITLE ;
    			ecrm:source cases.SOURCE
    				as virtrdf:Case-SOURCE ;
    			ecrm:year cases.YEAR
    				as virtrdf:Case-YEAR ;
    			ecrm:month cases.MONTH
    				as virtrdf:Case-MONTH ;
    			ecrm:quarter cases.QUARTER
    				as virtrdf:Case-QUARTER ;
    			ecrm:whenOrder cases.WHEN_ORDER
    				as virtrdf:Case-WHEN_ORDER ;
    			ecrm:internalStatus cases.INTERNAL_STATUS
    				as virtrdf:Case-INTERNAL_STATUS ;
    			ecrm:financialYear cases.FINANCIAL_YEAR
    				as virtrdf:Case-FINANCIAL_YEAR ;
    			ecrm:contactRelID cases.CONTACT_REL_ID
    				as virtrdf:Case-CONTACT_REL_ID ;
    			ecrm:companyRelID cases.COMPANY_REL_ID
    				as virtrdf:Case-COMPANY_REL_ID .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Case (cases.ORG_ID, cases.CASE_ID)
    				where (^{cases.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Case-is_ecrm_org_of .
    				
    		ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
    			ecrm:is_contact_of
    				ecrm:Case (cases.ORG_ID, cases.CASE_ID)
    				where (^{cases.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{cases.}^.ORG_ID = ^{contacts.}^.ORG_ID)
    				as virtrdf:Case-is_contact_of .
    				
    		ecrm:Company (cases.COMPANY_NAME, cases.COMPANY_ID, cases.ORG_ID)
    			ecrm:is_company_of
    				ecrm:Case (cases.ORG_ID, cases.CASE_ID)
    				as virtrdf:Case-is_company_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Case (cases.ORG_ID, cases.CASE_ID)
    				where (^{cases.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{cases.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Case-account_manager .
    
    		ecrm:Activity (activities.ORG_ID, activities.ACT_ID, activities.OBJ_ID)
    			a ecrm:Activity
    				as virtrdf:Activity-Activitys2 ;
    			a cal:Vevent
    				as virtrdf:Activity-Activitys ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{activities.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Activity-ORG_ID ;
    			ecrm:ACTIVITY_ID activities.ACTIVITY_ID
    				as virtrdf:Activity-ACTIVITY_ID ;
    			ecrm:ACT_ID activities.ACT_ID
    				as virtrdf:Activity-ACT_ID ;
    			ecrm:OBJ_ID activities.OBJ_ID
    				as virtrdf:Activity-OBJ_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{activities.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{activities.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Activity-OWNER_ID .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Activity (activities.ORG_ID, activities.ACT_ID, activities.OBJ_ID)
    				where (^{activities.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Activity-is_ecrm_org_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Activity (activities.ORG_ID, activities.ACT_ID, activities.OBJ_ID)
    				where (^{activities.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{activities.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Activity-account_manager .
    
    		ecrm:MailMessage (messages.ORG_ID, messages.MAIL_MSG_ID, messages.OBJ_ID)
    			a ecrm:MailMessage
    				as virtrdf:MailMessage-MailMessages ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{messages.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:MailMessage-ORG_ID ;
    			ecrm:MAIL_MESSAGE_ID messages.MAIL_MESSAGE_ID
    				as virtrdf:MailMessage-MAIL_MESSAGE_ID ;
    			ecrm:MAIL_MSG_ID messages.MAIL_MSG_ID
    				as virtrdf:MailMessage-MAIL_MSG_ID ;
    			ecrm:OBJ_ID messages.OBJ_ID
    				as virtrdf:MailMessage-OBJ_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{messages.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{messages.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:MailMessage-OWNER_ID .
    				
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:MailMessage (messages.ORG_ID, messages.MAIL_MSG_ID, messages.OBJ_ID)
    				where (^{messages.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:MailMessage-is_ecrm_org_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:MailMessage (messages.ORG_ID, messages.MAIL_MSG_ID, messages.OBJ_ID)
    				where (^{messages.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{messages.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:MailMessage-account_manager .
    
    		ecrm:Document (documents.ORG_ID, documents.DOC_ID, documents.OBJ_ID)
    			a ecrm:Document
    				as virtrdf:Document-Documents2 ;
    			a foaf:Document
    				as virtrdf:Document-Documents ;
    			rdfs:isDefinedBy ecrm:isDefinedBy () ;
    			ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    				where (^{documents.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Document-ORG_ID ;
    			ecrm:documentId documents.DOCUMENT_ID
    				as virtrdf:Document-DOCUMENT_ID ;
    			ecrm:DOC_ID documents.DOC_ID
    				as virtrdf:Document-DOC_ID ;
    			ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    				where (^{documents.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{documents.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Document-OWNER_ID ;
    			ecrm:OBJ_ID documents.OBJ_ID
    				as virtrdf:Document-OBJ_ID ;
    			ecrm:item documents.ITEM
    				as virtrdf:Document-ITEM ;
    			ecrm:reference documents.REFERENCE
    				as virtrdf:Document-REFERENCE .
    		
    		ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    			ecrm:ecrm_organization_of
    				ecrm:Document (documents.ORG_ID, documents.DOC_ID, documents.OBJ_ID)
    				where (^{documents.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    				as virtrdf:Document-is_ecrm_org_of .
    				
    		ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    			ecrm:account_manager
    				ecrm:Document (documents.ORG_ID, documents.DOC_ID, documents.OBJ_ID)
    				where (^{documents.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{documents.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    				as virtrdf:Document-account_manager .
    	} .
    } .
    ;
    
    SPARQL
    prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    prefix sioc: <http://rdfs.org/sioc/ns#>
    prefix OpenLink: <http://www.openlinksw.com/schemas/oplweb#>
    prefix foaf: <http://xmlns.com/foaf/0.1/>
    prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
    prefix cal: <http://www.w3.org/2002/12/cal/ical#>
    prefix product: <http://www.swop-project.eu/ontologies/pmo/product.owl#>
    prefix owl: <http://www.w3.org/2002/07/owl#>
    prefix relationship: <http://vocab.org/relationship/#>
    prefix gr: <http://purl.org/goodrelations/v1#>
    alter quad storage virtrdf:DefaultQuadStorage
    from eCRM.DBA.SFA_SALES_QUOTA as sales_quotas
    from eCRM.DBA.SFA_COMPANIES as companies text literal companies.DESCRIPTION
    from eCRM.DBA.SFA_CONTACTS as contacts text literal contacts.NAME_FIRST
    from eCRM.DBA.SFA_EMPLOYMENTS as employments
    from eCRM.DBA.SFA_LEADS as leads text literal leads.SUBJECT
    from eCRM.DBA.SFA_OPPORTUNITIES as opportunities text literal opportunities.OPPORTUNITY_NAME
    from eCRM.DBA.SFA_ACTIVITIES as activities
    from eCRM.DBA.SFA_MAIL_MESSAGES as messages
    from eCRM.DBA.SFA_DOCUMENTS as documents
    from eCRM.DBA.SFA_INFLUENCERS as influencers
    from eCRM.DBA.SFA_TEAMS as teams
    from eCRM.DBA.SFA_NOTES as notes text literal notes.DESCRIPTION
    from eCRM.DBA.SFA_COMPETITORS as competitors
    from eCRM.DBA.SFA_ISSUES as issues
    from eCRM.DBA.SFA_CUSTOM_FIELD_DEFS as custom_field_defs
    from eCRM.DBA.SFA_CUSTOM_FIELDS as custom_fields
    from eCRM.DBA.SFA_CASES as cases text literal cases.SUMMARY
    from eCRM.DBA.SFA_ORDERS as orders text literal orders.EMAIL
    from eCRM.DBA.SFA_ORDER_ITEMS as order_items
    from eCRM.DBA.PM_CATEGORIES as categories
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTE_DEFS as product_attribute_defs
    from eCRM.DBA.PM_PRODUCTS as products text literal products.DESCRIPTION
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTES as product_attributes
    from eCRM.DBA.PM_CATALOGS as catalogs
    from eCRM.DBA.PM_CATALOG_PRODUCTS as catalog_products
    from eCRM.DBA.XSYS_MODULES as modules
    from eCRM.DBA.XSYS_REGISTRY as registries
    from eCRM.DBA.XSYS_ORGANIZATIONS_DATA as organizations_data
    from eCRM.DBA.XSYS_MESSAGES as xsysmessages
    from eCRM.DBA.XSYS_COUNTRIES as countries
    from eCRM.DBA.XSYS_PROVINCES as provinces
    from eCRM.DBA.XSYS_TIMEZONES as timezones
    from eCRM.DBA.XSYS_MIME_TYPES as mimetypes
    from eCRM.DBA.XSYS_MIME_EXTENSIONS as mimeexts
    from eCRM.DBA.XSYS_CNAMES as cnames
    from eCRM.DBA.XSYS_QUOTAS as quotas
    from eCRM.DBA.XSYS_ROLES as roles
    from eCRM.DBA.XSYS_ACCOUNTS as accounts
    from eCRM.DBA.XSYS_USERDATA as userdatas
    from eCRM.DBA.XSYS_GROUPDATA as groupdatas
    from eCRM.DBA.XSYS_MEMBERS as members
    from eCRM.DBA.XSYS_SESSIONS_DATA as sessionsdatas
    from eCRM.DBA.XSYS_SESSION_DATA as sessiondatas
    from eCRM.DBA.XSYS_LIST_MEMBERS_DEFS as list_members_defs
    from eCRM.DBA.XSYS_CLASSES as classes
    from eCRM.DBA.XSYS_ORG_CLASSES as org_classes
    from eCRM.DBA.XSYS_CLASS_METHODS as class_methods
    from eCRM.DBA.XSYS_CLASS_VIEWS as class_views
    from eCRM.DBA.XSYS_ROLE_PRIVILEGES as role_priveleges
    from eCRM.DBA.XSYS_USER_PRIVILEGES as user_priveleges
    from eCRM.DBA.XSYS_HISTORY as history
    from eCRM.DBA.XSYS_USERS as xsys_users
    from eCRM.DBA.AP_PROCESSES as ap_processes
    from eCRM.DBA.AP_RULES as ap_rules
    from eCRM.DBA.AP_QUEUE as ap_queues
    where (^{companies.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{contacts.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{leads.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{products.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{orders.}^.SHIP_COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    {
            create virtrdf:ecrmDemo2 as graph iri ("http://^{URIQADefaultHost}^/ecrm") option (order 1502)
            {
    	    	ecrm:Issue (issues.ORG_ID, issues.ISSUE_ID)
                    a ecrm:Issue
                        as virtrdf:Issue-Issues ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{issues.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Issue-ORG_ID ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label issues.SUBJECT;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{issues.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{issues.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Issue-OWNER_ID ;
                    ecrm:has_opportunity ecrm:Opportunity(issues.ORG_ID, issues.OPPORTUNITY_ID)
                        as virtrdf:Issue-OPPORTUNITY_ID ;
                    ecrm:REL_ID issues.REL_ID
                        as virtrdf:Issue-REL_ID ;
                    ecrm:subject issues.SUBJECT
                        as virtrdf:Issue-SUBJECT ;
                    ecrm:reference issues.REFERENCE
                        as virtrdf:Issue-REFERENCE ;
                    ecrm:priority issues.PRIORITY
                        as virtrdf:Issue-PRIORITY ;
                    ecrm:issueDate issues.ISSUE_DATE
                        as virtrdf:Issue-ISSUE_DATE ;
                    ecrm:status issues.STATUS
                        as virtrdf:Issue-STATUS ;
                    ecrm:userName issues.USER_NAME
                        as virtrdf:Issue-USER_NAME ;
                    ecrm:docTitle issues.DOC_TITLE
                        as virtrdf:Issue-DOC_TITLE .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Issue (issues.ORG_ID, issues.ISSUE_ID)
    					where (^{issues.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Issue-is_ecrm_org_of .
    					
    			ecrm:Opportunity(issues.ORG_ID, issues.OPPORTUNITY_ID)
                    ecrm:is_opportunity_of
    					ecrm:Issue (issues.ORG_ID, issues.ISSUE_ID)
                        as virtrdf:Issue-is_opportunity_of .
                        
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Issue (issues.ORG_ID, issues.ISSUE_ID)
    					where (^{issues.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{issues.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Issue-account_manager .
    
                ecrm:Order (orders.ORG_ID, orders.ORDER_ID)
                    a ecrm:Order
                        as virtrdf:Order-Orders ;
                    ecrm:order_id_stext ecrm:order_lit (orders.ORDER_ID) 
    		 			as virtrdf:Orders-order_lit ;
    		 		rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label ecrm:OrderLabel (orders.ORDER_NO) ;
    				vcard:ADR ecrm:OrderAddress (orders.ORDER_ID, orders.ORG_ID)
                    	as virtrdf:Order-ADR ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{orders.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Order-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{orders.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{orders.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Order-OWNER_ID ;
                    ecrm:FREETEXT_ID orders.FREETEXT_ID
                        as virtrdf:Order-FREETEXT_ID ;
                    ecrm:has_company ecrm:Company(orders.COMPANY_NAME, orders.COMPANY_ID, orders.ORG_ID)
                        as virtrdf:Order-COMPANY_ID ;
    				#cannot guess manufacturer from schema       
    				#gr:hasManufacturer ecrm:Company(orders.COMPANY_NAME, orders.COMPANY_ID, orders.ORG_ID)
    				#    as virtrdf:Order-COMPANY_ID22 ;
                    ecrm:companyName orders.COMPANY_NAME
                        as virtrdf:Order-COMPANY_NAME ;
                    ecrm:has_contact ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
                        where (^{orders.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{orders.}^.ORG_ID = ^{contacts.}^.ORG_ID)
                        as virtrdf:Order-CONTACT_ID ;
                    ecrm:contactName orders.CONTACT_NAME
                        as virtrdf:Order-CONTACT_NAME ;
                    ecrm:orderNo orders.ORDER_NO
                        as virtrdf:Order-ORDER_NO ;
                    ecrm:shipFirstName orders.SHIP_FNAME
                        as virtrdf:Order-SHIP_FNAME ;
                    ecrm:shipSecondName orders.SHIP_SNAME
                        as virtrdf:Order-SHIP_SNAME ;
                    ecrm:phoneNumber ecrm:tel_iri(orders.PHONE_NUMBER)
                        as virtrdf:Order-PHONE_NUMBER ;
                    ecrm:phoneExtension orders.PHONE_EXTENSION
                        as virtrdf:Order-PHONE_EXTENSION ;
                    foaf:mbox ecrm:mbox_iri(orders.EMAIL)
                        as virtrdf:Order-EMAIL ;
                    ecrm:email_text orders.EMAIL
                        as virtrdf:Order-EMAIL-TEXT ;
                    ecrm:shipCountry ecrm:Country(orders.SHIP_COUNTRY_NAME)
                        as virtrdf:Order-SHIP_COUNTRY_NAME ;
                    ecrm:shipProvince ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
                    	where (^{orders.}^.SHIP_PROVINCE = ^{provinces.}^.PROVINCE_NAME)
                        as virtrdf:Order-SHIP_PROVINCE ;
                    ecrm:shipCity ecrm:dbpedia_iri (orders.SHIP_CITY)
                        as virtrdf:Order-SHIP_dbpedia_CITY ;
                    ecrm:shipPostalCode orders.SHIP_POSTAL_CODE
                        as virtrdf:Order-SHIP_POSTAL_CODE ;
                    ecrm:shipAddress1 orders.SHIP_ADDRESS1
                        as virtrdf:Order-SHIP_ADDRESS1 ;
                    ecrm:shipAddress2 orders.SHIP_ADDRESS2
                        as virtrdf:Order-SHIP_ADDRESS2 ;
                    ecrm:salesRep ecrm:SalesRep(orders.ORG_ID, orders.SALESREP)
                        as virtrdf:Order-SALESREP ;
                    ecrm:orderDate orders.ORDER_DATE
                        as virtrdf:Order-ORDER_DATE ;
                    ecrm:orderValue orders.ORDER_VALUE
                        as virtrdf:Order-ORDER_VALUE ;
                    ecrm:refund orders.REFUND
                        as virtrdf:Order-REFUND ;
                    ecrm:year orders.YEAR
                        as virtrdf:Order-YEAR ;
                    ecrm:month orders.MONTH
                        as virtrdf:Order-MONTH ;
                    ecrm:quarter orders.QUARTER
                        as virtrdf:Order-QUARTER ;
                    ecrm:financialYear orders.FINANCIAL_YEAR
                        as virtrdf:Order-FINANCIAL_YEAR ;
                    ecrm:CONTACT_REL_ID orders.CONTACT_REL_ID
                        as virtrdf:Order-CONTACT_REL_ID ;
                    ecrm:COMPANY_REL_ID orders.COMPANY_REL_ID
                        as virtrdf:Order-COMPANY_REL_ID .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Order (orders.ORG_ID, orders.ORDER_ID)
    					where (^{orders.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Order-is_ecrm_org_of .
    					
    			ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
                    ecrm:is_contact_of
    					ecrm:Order (orders.ORG_ID, orders.ORDER_ID)
                        where (^{orders.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{orders.}^.ORG_ID = ^{contacts.}^.ORG_ID)
                        as virtrdf:Order-is_contact_of .
                        
                ecrm:Company(orders.COMPANY_NAME, orders.COMPANY_ID, orders.ORG_ID)
                    ecrm:has_order
    				    ecrm:Order (orders.ORG_ID, orders.ORDER_ID)
                        as virtrdf:Order-is_company_of .
                        
                ecrm:Country (orders.SHIP_COUNTRY_NAME)
                    ecrm:is_ship_country_of
    				    ecrm:Order(orders.ORG_ID, orders.ORDER_ID)
    				    as virtrdf:Order-is_country_of .
    				    
    			ecrm:Province (provinces.COUNTRY_ID, provinces.PROVINCE_NAME)
                    ecrm:is_shipprovince_of
    					ecrm:Order(orders.ORG_ID, orders.ORDER_ID)
    					where (^{orders.}^.SHIP_PROVINCE = ^{provinces.}^.PROVINCE_NAME)
    					as virtrdf:Order-is_province_of .
    
                ecrm:SalesRep (orders.ORG_ID, orders.SALESREP)
                    a ecrm:SalesRep
                        as virtrdf:SalesRep-SalesRep ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:is_sales_rep_of
                        ecrm:Order(orders.ORG_ID, orders.ORDER_ID)
                        as virtrdf:SalesRep-is_of ;
                    foaf:name orders.SALESREP
                        as virtrdf:SalesRep-Name .
    
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Order(orders.ORG_ID, orders.ORDER_ID)
    					where (^{orders.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{orders.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Order-account_manager .
    
                ecrm:OrderItem (order_items.ORG_ID, order_items.ORDER_ITEM_ID)
                    a ecrm:OrderItem
                        as virtrdf:OrderItem-OrderItems ;
                    a gr:ProductOrServicesSomeInstancesPlaceholder
                        as virtrdf:OrderItem-ProductOrServicesSomeInstancesPlaceholder ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    		    	rdfs:label order_items.PRODUCT_NAME;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{order_items.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:OrderItem-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{order_items.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{order_items.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:OrderItem-OWNER_ID ;
                    ecrm:has_order ecrm:Order(order_items.ORG_ID, order_items.ORDER_ID)
                        as virtrdf:OrderItem-ORDER_ID ;
                    ecrm:has_product ecrm:Product(order_items.ORG_ID, order_items.PRODUCT_ID)
                        as virtrdf:OrderItem-PRODUCT_ID ;
                    ecrm:productName order_items.PRODUCT_NAME
                        as virtrdf:OrderItem-PRODUCT_NAME ;
                    ecrm:client order_items.CLIENT
                        as virtrdf:OrderItem-CLIENT ;
                    ecrm:server ecrm:dbpedia_iri (order_items.SERVER)
                        as virtrdf:OrderItem-SERVER ;
                    ecrm:dbms ecrm:dbpedia_iri (order_items.DBMS)
                        as virtrdf:OrderItem-DBMS ;
                    ecrm:discount order_items.DISCOUNT
                        as virtrdf:OrderItem-DISCOUNT ;
                    ecrm:unitPrice order_items.UNIT_PRICE
                        as virtrdf:OrderItem-UNIT_PRICE ;
                    ecrm:qty order_items.QTY
                        as virtrdf:OrderItem-QTY .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:OrderItem (order_items.ORG_ID, order_items.ORDER_ITEM_ID)
    					where (^{order_items.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:OrderItem-is_ecrm_org_of .
    					
                ecrm:Order(order_items.ORG_ID, order_items.ORDER_ID)
                    ecrm:is_order_of
    				    ecrm:OrderItem (order_items.ORG_ID, order_items.ORDER_ITEM_ID)
    				    as virtrdf:OrderItem-is_order_of .
    				    
                ecrm:Product(order_items.ORG_ID, order_items.PRODUCT_ID)
                    ecrm:is_product_of
    				    ecrm:OrderItem (order_items.ORG_ID, order_items.ORDER_ITEM_ID)
    				    as virtrdf:OrderItem-is_product_of .
    				    
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:OrderItem (order_items.ORG_ID, order_items.ORDER_ITEM_ID)
    					where (^{order_items.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{order_items.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:OrderItem-account_manager .
    
                ecrm:Category (categories.ORG_ID, categories.CATEGORY_ID)
                    a ecrm:Category
                        as virtrdf:Category-Categorys ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{categories.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Category-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{categories.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{categories.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Category-OWNER_ID ;
                    ecrm:FREETEXT_ID categories.FREETEXT_ID
                        as virtrdf:Category-FREETEXT_ID ;
    				rdfs:label categories.CATEGORY_NAME;
                    ecrm:categoryName categories.CATEGORY_NAME
                        as virtrdf:Category-CATEGORY_NAME ;
                    ecrm:description categories.DESCRIPTION
                        as virtrdf:Category-DESCRIPTION .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Category (categories.ORG_ID, categories.CATEGORY_ID)
    					where (^{categories.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Category-is_ecrm_org_of .
    					
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Category (categories.ORG_ID, categories.CATEGORY_ID)
    					where (^{categories.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{categories.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Category-account_manager .
    					
                ecrm:OrganizationsData (organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    a  ecrm:OrganizationsData
                        as virtrdf:OrganizationsData-OrganizationsDatas2 ;
                    a  foaf:Organization
                        as virtrdf:OrganizationsData-OrganizationsDatas ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    rdfs:label organizations_data.DNS_ZONE;
                    ecrm:dnsZone organizations_data.DNS_ZONE
                        as virtrdf:OrganizationsData-DNS_ZONE ;
                    ecrm:status organizations_data.STATUS
                        as virtrdf:OrganizationsData-STATUS ;
                    ecrm:data organizations_data.DATA
                        as virtrdf:OrganizationsData-DATA ;
                    ecrm:spaceTotal organizations_data.SPACE_TOTAL
                        as virtrdf:OrganizationsData-SPACE_TOTAL ;
                    ecrm:spaceUsed organizations_data.SPACE_USED
                        as virtrdf:OrganizationsData-SPACE_USED ;
                    ecrm:userLicenses organizations_data.USER_LICENSES
                        as virtrdf:OrganizationsData-USER_LICENSES .
    
                ecrm:ProductAttributeDef (product_attribute_defs.ORG_ID, product_attribute_defs.ATTRIBUTE_ID)
                    a ecrm:ProductAttributeDef
                        as virtrdf:ProductAttributeDef-ProductAttributeDefs ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{product_attribute_defs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:ProductAttributeDef-ORG_ID ;
                    ecrm:has_category ecrm:Category(product_attribute_defs.ORG_ID, product_attribute_defs.CATEGORY_ID)
                        as virtrdf:ProductAttributeDef-CATEGORY_ID ;
                    ecrm:attributeName product_attribute_defs.ATTRIBUTE_NAME
                        as virtrdf:ProductAttributeDef-ATTRIBUTE_NAME ;
                    ecrm:attributeType product_attribute_defs.ATTRIBUTE_TYPE
                        as virtrdf:ProductAttributeDef-ATTRIBUTE_TYPE .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:ProductAttributeDef (product_attribute_defs.ORG_ID, product_attribute_defs.ATTRIBUTE_ID)
    					where (^{product_attribute_defs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:ProductAttributeDef-is_ecrm_org_of .
    					
                ecrm:Category(product_attribute_defs.ORG_ID, product_attribute_defs.CATEGORY_ID)
                    ecrm:is_ctegory_of
    				    ecrm:ProductAttributeDef (product_attribute_defs.ORG_ID, product_attribute_defs.ATTRIBUTE_ID)
    				    as virtrdf:ProductAttributeDef-is_category_of .
    
                ecrm:Product (products.ORG_ID, products.PRODUCT_ID)
    				a ecrm:Product
    					as virtrdf:ecrmProduct-Products ;
    				a product:Product
    					as virtrdf:Product-Products ;
    				a gr:ProductOrService as virtrdf:grProductOrService-Products ;
    					ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{products.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Product-ORG_ID ;
    				rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label products.PRODUCT_NAME ;
    				rdfs:comment products.DESCRIPTION ;
    				gr:description products.DESCRIPTION ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{products.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{products.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Product-OWNER_ID ;
                    ecrm:FREETEXT_ID products.FREETEXT_ID
    					as virtrdf:Product-FREETEXT_ID ;
                    ecrm:productName products.PRODUCT_NAME
                        as virtrdf:Product-PRODUCT_NAME ;
                    ecrm:has_category ecrm:Category(products.ORG_ID, products.CATEGORY_ID)
                        as virtrdf:Product-CATEGORY_ID ;
                    ecrm:unitOfMeasure products.UNIT_OF_MEASURE
                        as virtrdf:Product-UNIT_OF_MEASURE ;
                    ecrm:units products.UNITS
                        as virtrdf:Product-UNITS ;
                    product:unit products.UNITS
                        as virtrdf:Product-productUNITS ;
                    ecrm:manufacturer products.MANUFACTURER
                        as virtrdf:Product-MANUFACTURER ;
                    gr:hasManufacturer  ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{products.}^.MANUFACTURER = ^{companies.}^.COMPANY_NAME and ^{products.}^.ORG_ID = ^{companies.}^.ORG_ID)
    		 			as virtrdf:grhasManufacturer-MANUFACTURER ;		     
                    ecrm:has_manufacturer ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{products.}^.MANUFACTURER = ^{companies.}^.COMPANY_NAME and ^{products.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Product-MANUFACTURER2 ;
                    ecrm:validFrom products.VALID_FROM
                        as virtrdf:Product-VALID_FROM ;
                    ecrm:validUntil products.VALID_UNTIL
                        as virtrdf:Product-VALID_UNTIL ;
                    ecrm:country ecrm:Country(products.COUNTRY_NAME)
                        as virtrdf:Product-COUNTRY_NAME ;
                    ecrm:minorder products.MINORDER
                        as virtrdf:Product-MINORDER ;
                    ecrm:maxorder products.MAXORDER
                        as virtrdf:Product-MAXORDER ;
                    ecrm:productVendor products.PRODUCT_VENDOR
                        as virtrdf:Product-PRODUCT_VENDOR ;
                    ecrm:has_vendor ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{products.}^.PRODUCT_VENDOR = ^{companies.}^.COMPANY_NAME and ^{products.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Product-PRODUCT_VENDOR2 ;
                    ecrm:description products.DESCRIPTION
                        as virtrdf:Product-DESCRIPTION .
                        
    	        ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:Product (products.ORG_ID, products.PRODUCT_ID)
    					where (^{products.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Product-is_ecrm_org_of .
    					
    			ecrm:Country (products.COUNTRY_NAME)
    				ecrm:is_country_of
    					ecrm:Product(products.ORG_ID, products.PRODUCT_ID)
    					as virtrdf:Product-is_country_of .
    					
    			ecrm:Category(products.ORG_ID, products.CATEGORY_ID)
    				ecrm:is_category_of
    					ecrm:Product(products.ORG_ID, products.PRODUCT_ID)
    					as virtrdf:Product-is_category_of .
    					
    			ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				ecrm:is_manufacturer_of
    					ecrm:Product(products.ORG_ID, products.PRODUCT_ID)
    					where (^{products.}^.MANUFACTURER = ^{companies.}^.COMPANY_NAME and ^{products.}^.ORG_ID = ^{companies.}^.ORG_ID)
    					as virtrdf:Product-is_manufacturer_of .
    					
    			ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				ecrm:is_vendor_of
    					ecrm:Product(products.ORG_ID, products.PRODUCT_ID)
    					where (^{products.}^.PRODUCT_VENDOR = ^{companies.}^.COMPANY_NAME and ^{products.}^.ORG_ID = ^{companies.}^.ORG_ID)
    					as virtrdf:Product-is_vendor_of .
    					
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Product(products.ORG_ID, products.PRODUCT_ID)
    					where (^{products.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{products.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Product-account_manager .
    
                ecrm:ProductAttribute (product_attributes.ORG_ID, product_attributes.PRODUCT_ID, product_attributes.ATTRIBUTE_ID)
                    a ecrm:ProductAttribute
                        as virtrdf:ProductAttribute-ProductAttributes ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{product_attributes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:ProductAttribute-ORG_ID ;
                    ecrm:has_product ecrm:Product(product_attributes.ORG_ID, product_attributes.PRODUCT_ID)
                        as virtrdf:ProductAttribute-PRODUCT_ID ;
                    ecrm:has_attribute ecrm:ProductAttributeDef(product_attributes.ORG_ID, product_attributes.ATTRIBUTE_ID)
                        as virtrdf:ProductAttribute-ATTRIBUTE_ID ;
                    ecrm:attributeValue product_attributes.ATTRIBUTE_VALUE
                        as virtrdf:ProductAttribute-ATTRIBUTE_VALUE .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:ProductAttribute (product_attributes.ORG_ID, product_attributes.PRODUCT_ID, product_attributes.ATTRIBUTE_ID)
    					where (^{product_attributes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:ProductAttribute-is_ecrm_org_of .
    					
    			ecrm:Product(product_attributes.ORG_ID, product_attributes.PRODUCT_ID)
    				ecrm:is_product_of
    					ecrm:ProductAttribute (product_attributes.ORG_ID, product_attributes.PRODUCT_ID, product_attributes.ATTRIBUTE_ID)
    					as virtrdf:ProductAttribute-is_product_of .
    
                ecrm:Catalog (catalogs.ORG_ID, catalogs.CATALOG_ID)
                    a ecrm:Catalog
                        as virtrdf:Catalog-Catalogs ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{catalogs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Catalog-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{catalogs.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{catalogs.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Catalog-OWNER_ID ;
                    ecrm:FREETEXT_ID catalogs.FREETEXT_ID
                        as virtrdf:Catalog-FREETEXT_ID ;
    				rdfs:label catalogs.CATALOG_NAME;
    				rdfs:comment catalogs.DESCRIPTION;
                    ecrm:catalogName catalogs.CATALOG_NAME
                        as virtrdf:Catalog-CATALOG_NAME ;
                    ecrm:has_provider ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{catalogs.}^.CATALOG_PROVIDER = ^{companies.}^.COMPANY_NAME and ^{catalogs.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Catalogs-CATALOG_PROVIDER2 ;
                    ecrm:catalogProvider catalogs.CATALOG_PROVIDER
                        as virtrdf:Catalog-CATALOG_PROVIDER ;
                    ecrm:catalogAudience catalogs.CATALOG_AUDIENCE
                        as virtrdf:Catalog-CATALOG_AUDIENCE ;
                    ecrm:validFrom catalogs.VALID_FROM
                        as virtrdf:Catalog-VALID_FROM ;
                    ecrm:validUntil catalogs.VALID_UNTIL
                        as virtrdf:Catalog-VALID_UNTIL ;
                    ecrm:description catalogs.DESCRIPTION
                        as virtrdf:Catalog-DESCRIPTION .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:Catalog (catalogs.ORG_ID, catalogs.CATALOG_ID)
    					where (^{catalogs.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Catalog-is_ecrm_org_of .
    					
    			ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
    				ecrm:is_provider_of
    					ecrm:Catalog (catalogs.ORG_ID, catalogs.CATALOG_ID)
    					where (^{catalogs.}^.CATALOG_PROVIDER = ^{companies.}^.COMPANY_NAME and ^{catalogs.}^.ORG_ID = ^{companies.}^.ORG_ID)
    					as virtrdf:Catalog-is_provider_of .
    					
       			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Catalog (catalogs.ORG_ID, catalogs.CATALOG_ID)
    					where (^{catalogs.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{catalogs.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Catalog-account_manager .
    
                ecrm:CatalogProduct (catalog_products.ORG_ID, catalog_products.CATALOG_ID, catalog_products.PRODUCT_ID)
                    a ecrm:CatalogProduct
                        as virtrdf:CatalogProduct-CatalogProducts ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{catalog_products.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:CatalogProduct-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{catalog_products.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{catalog_products.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:CatalogProduct-OWNER_ID ;
                    ecrm:has_catalog ecrm:Catalog(catalog_products.ORG_ID, catalog_products.CATALOG_ID)
                        as virtrdf:CatalogProduct-CATALOG_ID ;
                    ecrm:has_product ecrm:Product(catalog_products.ORG_ID, catalog_products.PRODUCT_ID)
                        as virtrdf:CatalogProduct-PRODUCT_ID ;
    				rdfs:comment catalog_products.DESCRIPTION;
                    ecrm:REL_ID catalog_products.REL_ID
                        as virtrdf:CatalogProduct-REL_ID ;
                    ecrm:price catalog_products.PRICE
                        as virtrdf:CatalogProduct-PRICE ;
                    ecrm:currency catalog_products.CURRENCY
                        as virtrdf:CatalogProduct-CURRENCY ;
                    ecrm:description catalog_products.DESCRIPTION
                        as virtrdf:CatalogProduct-DESCRIPTION .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:CatalogProduct (catalog_products.ORG_ID, catalog_products.CATALOG_ID, catalog_products.PRODUCT_ID)
    					where (^{catalog_products.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:CatalogProduct-is_ecrm_org_of .
    					
    			ecrm:Catalog(catalog_products.ORG_ID, catalog_products.CATALOG_ID)
    				ecrm:is_catalog_of
    					ecrm:CatalogProduct (catalog_products.ORG_ID, catalog_products.CATALOG_ID, catalog_products.PRODUCT_ID)
    					as virtrdf:CatalogProduct-is_catalog_of .
    					
    			ecrm:Product(catalog_products.ORG_ID, catalog_products.PRODUCT_ID)
    				ecrm:is_product_of
    					ecrm:CatalogProduct (catalog_products.ORG_ID, catalog_products.CATALOG_ID, catalog_products.PRODUCT_ID)
    					as virtrdf:CatalogProduct-is_product_of .
    					
    		   	ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:CatalogProduct (catalog_products.ORG_ID, catalog_products.CATALOG_ID, catalog_products.PRODUCT_ID)
    					where (^{catalog_products.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{catalog_products.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:CatalogProduct-account_manager .
    			
    			ecrm:tel_iri(companies.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(companies.PHONE_NUMBER) .
    
    			ecrm:tel_iri(companies.FAX_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(companies.FAX_NUMBER) .
    
    			ecrm:tel_iri(companies.MOBILE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(companies.MOBILE_NUMBER) .
    				
    			ecrm:tel_iri(employments.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(employments.PHONE_NUMBER) .
    				
    			ecrm:tel_iri(employments.FAX_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(employments.FAX_NUMBER).
    			
    			ecrm:tel_iri(employments.MOBILE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(employments.MOBILE_NUMBER).
    			
    			ecrm:tel_iri(contacts.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(contacts.PHONE_NUMBER).
    			
    			ecrm:tel_iri(contacts.PHONE2_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(contacts.PHONE2_NUMBER).
    			
    			ecrm:tel_iri(contacts.FAX_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(contacts.FAX_NUMBER).
    			
    			ecrm:tel_iri(contacts.MOBILE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(contacts.MOBILE_NUMBER).
    			
    			ecrm:tel_iri(leads.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(leads.PHONE_NUMBER).
    			
    			ecrm:tel_iri(leads.MOBILE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(leads.MOBILE_NUMBER).
    			
    			ecrm:tel_iri(leads.FAX_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(leads.FAX_NUMBER).
    			
    			ecrm:tel_iri(cases.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(cases.PHONE_NUMBER).
    			
    			ecrm:tel_iri(orders.PHONE_NUMBER)
    				owl:sameAs
    				ecrm:callto_iri(orders.PHONE_NUMBER).
            } .
    } .
    ;
    
    SPARQL
    prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    prefix ecrm: <http://www.openlinksw.com/ontology/ecrm#>
    prefix sioc: <http://rdfs.org/sioc/ns#>
    prefix foaf: <http://xmlns.com/foaf/0.1/>
    prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
    prefix cal: <http://www.w3.org/2002/12/cal/ical#>
    prefix product: <http://www.swop-project.eu/ontologies/pmo/product.owl#>
    prefix owl: <http://www.w3.org/2002/07/owl#>
    prefix relationship: <http://vocab.org/relationship/#>
    prefix gr: <http://purl.org/goodrelations/v1#>
    alter quad storage virtrdf:DefaultQuadStorage
    from eCRM.DBA.SFA_SALES_QUOTA as sales_quotas
    from eCRM.DBA.SFA_COMPANIES as companies text literal companies.DESCRIPTION
    from eCRM.DBA.SFA_CONTACTS as contacts text literal contacts.NAME_FIRST
    from eCRM.DBA.SFA_EMPLOYMENTS as employments
    from eCRM.DBA.SFA_LEADS as leads text literal leads.SUBJECT
    from eCRM.DBA.SFA_OPPORTUNITIES as opportunities text literal opportunities.OPPORTUNITY_NAME
    from eCRM.DBA.SFA_ACTIVITIES as activities
    from eCRM.DBA.SFA_MAIL_MESSAGES as messages
    from eCRM.DBA.SFA_DOCUMENTS as documents
    from eCRM.DBA.SFA_INFLUENCERS as influencers
    from eCRM.DBA.SFA_TEAMS as teams
    from eCRM.DBA.SFA_NOTES as notes text literal notes.DESCRIPTION
    from eCRM.DBA.SFA_COMPETITORS as competitors
    from eCRM.DBA.SFA_ISSUES as issues
    from eCRM.DBA.SFA_CUSTOM_FIELD_DEFS as custom_field_defs
    from eCRM.DBA.SFA_CUSTOM_FIELDS as custom_fields
    from eCRM.DBA.SFA_CASES as cases text literal cases.SUMMARY
    from eCRM.DBA.SFA_ORDERS as orders text literal orders.EMAIL
    from eCRM.DBA.SFA_ORDER_ITEMS as order_items
    from eCRM.DBA.PM_CATEGORIES as categories
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTE_DEFS as product_attribute_defs
    from eCRM.DBA.PM_PRODUCTS as products text literal products.DESCRIPTION
    from eCRM.DBA.PM_PRODUCT_ATTRIBUTES as product_attributes
    from eCRM.DBA.PM_CATALOGS as catalogs
    from eCRM.DBA.PM_CATALOG_PRODUCTS as catalog_products
    from eCRM.DBA.XSYS_MODULES as modules
    from eCRM.DBA.XSYS_REGISTRY as registries
    from eCRM.DBA.XSYS_ORGANIZATIONS_DATA as organizations_data
    from eCRM.DBA.XSYS_MESSAGES as xsysmessages
    from eCRM.DBA.XSYS_COUNTRIES as countries
    from eCRM.DBA.XSYS_PROVINCES as provinces
    from eCRM.DBA.XSYS_TIMEZONES as timezones
    from eCRM.DBA.XSYS_MIME_TYPES as mimetypes
    from eCRM.DBA.XSYS_MIME_EXTENSIONS as mimeexts
    from eCRM.DBA.XSYS_CNAMES as cnames
    from eCRM.DBA.XSYS_QUOTAS as quotas
    from eCRM.DBA.XSYS_ROLES as roles
    from eCRM.DBA.XSYS_ACCOUNTS as accounts
    from eCRM.DBA.XSYS_USERDATA as userdatas
    from eCRM.DBA.XSYS_GROUPDATA as groupdatas
    from eCRM.DBA.XSYS_MEMBERS as members
    from eCRM.DBA.XSYS_SESSIONS_DATA as sessionsdatas
    from eCRM.DBA.XSYS_SESSION_DATA as sessiondatas
    from eCRM.DBA.XSYS_LIST_MEMBERS_DEFS as list_members_defs
    from eCRM.DBA.XSYS_CLASSES as classes
    from eCRM.DBA.XSYS_ORG_CLASSES as org_classes
    from eCRM.DBA.XSYS_CLASS_METHODS as class_methods
    from eCRM.DBA.XSYS_CLASS_VIEWS as class_views
    from eCRM.DBA.XSYS_ROLE_PRIVILEGES as role_priveleges
    from eCRM.DBA.XSYS_USER_PRIVILEGES as user_priveleges
    from eCRM.DBA.XSYS_HISTORY as history
    from eCRM.DBA.XSYS_USERS as xsys_users
    from eCRM.DBA.AP_PROCESSES as ap_processes
    from eCRM.DBA.AP_RULES as ap_rules
    from eCRM.DBA.AP_QUEUE as ap_queues
    where (^{companies.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{contacts.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{leads.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{products.}^.COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    where (^{orders.}^.SHIP_COUNTRY_NAME = ^{countries.}^.COUNTRY_NAME)
    {
            create virtrdf:ecrmDemo3 as graph iri ("http://^{URIQADefaultHost}^/ecrm") option (exclusive, order 1503)
            {
                ecrm:Influencer (influencers.ORG_ID, influencers.INFLUENCER_ID)
                    a ecrm:Influencer
                        as virtrdf:Influencer-Influencers2 ;
                    a foaf:Person
                        as virtrdf:Influencer-Influencers ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label influencers.CONTACT_NAME;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{influencers.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Influencer-ORG_ID ;
                    ecrm:has_account_manager ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{influencers.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{influencers.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Influencer-OWNER_ID ;
                    ecrm:has_opportunity ecrm:Opportunity(influencers.ORG_ID, influencers.OPPORTUNITY_ID)
                        as virtrdf:Influencer-OPPORTUNITY_ID ;
                    ecrm:has_company ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{influencers.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{influencers.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Influencer-COMPANY_ID ;
                    ecrm:contactName influencers.CONTACT_NAME
                        as virtrdf:Influencer-CONTACT_NAME ;
                    foaf:title influencers.TITLE
                        as virtrdf:foafInfluencer-TITLE ;
                    ecrm:IROLE influencers.IROLE
                        as virtrdf:Influencer-IROLE ;
                    ecrm:responseMode influencers.RESPONSE_MODE
                        as virtrdf:Influencer-RESPONSE_MODE .
                        
    			ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                    ecrm:is_company_of
    					ecrm:Influencer (influencers.ORG_ID, influencers.INFLUENCER_ID)
                        where (^{influencers.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{influencers.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Influencer-is_company_of .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Influencer (influencers.ORG_ID, influencers.INFLUENCER_ID)
    					where (^{influencers.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Influencer-is_ecrm_org_of .
    					
    			ecrm:Opportunity (influencers.ORG_ID, influencers.OPPORTUNITY_ID)
                    ecrm:has_influencer
    					ecrm:Influencer (influencers.ORG_ID, influencers.INFLUENCER_ID)
                        as virtrdf:Influencer-is_opportunity_of .
                        
    			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Influencer (influencers.ORG_ID, influencers.INFLUENCER_ID)
    					where (^{influencers.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{influencers.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Influencer-account_manager .
    
                ecrm:Team (teams.ORG_ID, teams.OPPORTUNITY_ID, teams.CONTACT_ID)
                    a ecrm:Team
                        as virtrdf:Team-Teams ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{teams.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Team-ORG_ID ;
    				rdfs:label teams.TITLE;
                    ecrm:teamId teams.TEAM_ID
                        as virtrdf:Team-TEAM_ID ;
                    ecrm:has_opportunity ecrm:Opportunity(teams.ORG_ID, teams.OPPORTUNITY_ID)
                        as virtrdf:Team-OPPORTUNITY_ID ;
                    ecrm:owner ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{teams.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{teams.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Team-OWNER_ID ;
                    ecrm:has_contact ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
                        where (^{teams.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{teams.}^.ORG_ID = ^{contacts.}^.ORG_ID)
                        as virtrdf:Team-CONTACT_ID ;
                    ecrm:title teams.TITLE
                        as virtrdf:Team-TITLE ;
                    ecrm:department teams.DEPARTMENT
                        as virtrdf:Team-DEPARTMENT ;
                    ecrm:TROLE teams.TROLE
                        as virtrdf:Team-TROLE .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Team (teams.ORG_ID, teams.OPPORTUNITY_ID, teams.CONTACT_ID)
    					where (^{teams.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Team-is_ecrm_org_of .
    					
                ecrm:Contact(contacts.CONTACT_ID, contacts.ORG_ID)
                    ecrm:is_contact_of
    					ecrm:Team (teams.ORG_ID, teams.OPPORTUNITY_ID, teams.CONTACT_ID)
                        where (^{teams.}^.CONTACT_ID = ^{contacts.}^.CONTACT_ID and ^{teams.}^.ORG_ID = ^{contacts.}^.ORG_ID)
                        as virtrdf:Team-is_contact_of .
                        
    			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Team (teams.ORG_ID, teams.OPPORTUNITY_ID, teams.CONTACT_ID)
    					where (^{teams.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{teams.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Team-account_manager .
    
                ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
                    a ecrm:Competitor
                        as virtrdf:Competitor-Competitors2 ;
                    a foaf:Organization
                        as virtrdf:Competitor-Competitors ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{competitors.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Competitor-ORG_ID ;
                    ecrm:owner ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{competitors.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{competitors.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:Competitor-OWNER_ID ;
                    ecrm:has_opportunity ecrm:Opportunity(competitors.ORG_ID, competitors.OPPORTUNITY_ID)
                        as virtrdf:Competitor-OPPORTUNITY_ID ;
                    ecrm:has_company ecrm:Company(companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                        where (^{competitors.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{competitors.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Competitor-COMPANY_ID ;
                    ecrm:has_product ecrm:Product(competitors.ORG_ID, competitors.PRODUCT_ID)
                        as virtrdf:Competitor-PRODUCT_ID ;
                    foaf:name competitors.CONTACT_NAME
                        as virtrdf:foafCompetitor-CONTACT_NAME ;
                    ecrm:productName competitors.PRODUCT_NAME
                        as virtrdf:Competitor-PRODUCT_NAME ;
                    ecrm:Strengths competitors.STRENGTHS
                        as virtrdf:Competitor-STRENGTHS ;
                    ecrm:Weakness competitors.WEAKNESS
                        as virtrdf:Competitor-WEAKNESS ;
                    ecrm:Rating competitors.RATING
                        as virtrdf:Competitor-RATING ;
                    ecrm:Status competitors.STATUS
                        as virtrdf:Competitor-STATUS .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
    					where (^{competitors.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Competitor-is_ecrm_org_of .
    					
    			ecrm:Company (companies.COMPANY_NAME, companies.COMPANY_ID, companies.ORG_ID)
                    ecrm:is_company_of
    					ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
                        where (^{competitors.}^.COMPANY_ID = ^{companies.}^.COMPANY_ID and ^{competitors.}^.ORG_ID = ^{companies.}^.ORG_ID)
                        as virtrdf:Competitor-is_company_of .
                        
    			ecrm:Opportunity (competitors.ORG_ID, competitors.OPPORTUNITY_ID)
                    ecrm:is_opportunity_of
    					ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
                        as virtrdf:Competitor-is_opportunity_of .
                        
    			ecrm:Product(competitors.ORG_ID, competitors.PRODUCT_ID)
                    ecrm:is_product_of
    					ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
                        as virtrdf:Competitor-is_product_of .
                        
    			ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:Competitor (competitors.ORG_ID, competitors.COMPETITOR_ID)
    					where (^{competitors.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{competitors.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:Competitor-account_manager .
            
    			ecrm:Module (modules.MODULE_ID)
                    a ecrm:Module
                        as virtrdf:Module-Modules ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:prefix modules.PREFIX
                        as virtrdf:Module-PREFIX ;
    				rdfs:label modules.MODULE_NAME;
                    ecrm:moduleName modules.MODULE_NAME
                        as virtrdf:Module-MODULE_NAME ;
                    ecrm:description modules.DESCRIPTION
                        as virtrdf:Module-DESCRIPTION ;
                    ecrm:version modules.VERSION
                        as virtrdf:Module-VERSION ;
                    ecrm:buildDate modules.BUILD_DATE
                        as virtrdf:Module-BUILD_DATE ;
                    ecrm:installDate modules.INSTALL_DATE
                        as virtrdf:Module-INSTALL_DATE .
    
                ecrm:Registry (registries.KEY_NAME)
                    a ecrm:Registry
                        as virtrdf:Registry-Registrys ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:keyName registries.KEY_NAME
                        as virtrdf:Registry-KEY_NAME ;
                    ecrm:hasModule ecrm:Module(registries.MODULE_ID)
                        as virtrdf:Registry-MODULE_ID ;
                    ecrm:keyData registries.KEY_DATA
                        as virtrdf:Registry-KEY_DATA .
    			ecrm:Module(registries.MODULE_ID)
    				ecrm:is_module_of
    					ecrm:Registry (registries.KEY_NAME)
    					as virtrdf:Registry-is_module_of .
    
                ecrm:Message (xsysmessages.MODULE_ID, xsysmessages.MSG_ID)
                    a ecrm:Message
                        as virtrdf:Message-Messages ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label xsysmessages.MSG_TEXT;
                    ecrm:hasModule ecrm:Module(xsysmessages.MODULE_ID)
                        as virtrdf:Message-MODULE_ID ;
                    ecrm:messageText xsysmessages.MSG_TEXT
                        as virtrdf:Message-MSG_TEXT .
                        
    			ecrm:Module(registries.MODULE_ID)
    				ecrm:is_module_of
    					ecrm:Message (xsysmessages.MODULE_ID, xsysmessages.MSG_ID)
    					as virtrdf:Message-is_module_of .
    
                ecrm:Timezone (timezones.TZ_ID)
                    a ecrm:Timezone
                        as virtrdf:Timezone-Timezones ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label timezones.TZ_NAME;
                    ecrm:timezoneName timezones.TZ_NAME
                        as virtrdf:Timezone-TZ_NAME ;
                    ecrm:timezoneOffset timezones.TZ_OFFSET
                        as virtrdf:Timezone-TZ_OFFSET .
    
                ecrm:MimeType (mimetypes.ID)
                    a ecrm:MimeType
                        as virtrdf:MimeType-MimeTypes ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label mimetypes.MIME_TYPE;
    				rdfs:comment mimetypes.DESCRIPTION;
                    ecrm:mimeType mimetypes.MIME_TYPE
                        as virtrdf:MimeType-MIME_TYPE ;
                    ecrm:description mimetypes.DESCRIPTION
                        as virtrdf:MimeType-DESCRIPTION .
    
                ecrm:MimeExtension (mimeexts.MIME_TYPE_ID, mimeexts.EXTENSION)
                    a ecrm:MimeExtension
                        as virtrdf:MimeExtension-MimeExtensions ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:hasMimeType ecrm:MimeType (mimeexts.MIME_TYPE_ID)
                        as virtrdf:MimeExtension-MIME_TYPE_ID ;
                    ecrm:extension mimeexts.EXTENSION
                        as virtrdf:MimeExtension-EXTENSION .
                        
    			ecrm:MimeType (mimetypes.ID)
    				ecrm:is_MimeType_of
    					ecrm:MimeExtension (mimeexts.MIME_TYPE_ID, mimeexts.EXTENSION)
    					as virtrdf:MimeExtension-is_mimetype_of .
    
                ecrm:Cname (cnames.DNS_CNAME)
                    a ecrm:Cname
                        as virtrdf:Cname-Cnames ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label cnames.DNS_CNAME;
                    ecrm:dnsCname cnames.DNS_CNAME
                        as virtrdf:Cname-DNS_CNAME ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{cnames.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Cname-ORG_ID ;
                    ecrm:interface cnames.INTERFACE
                        as virtrdf:Cname-INTERFACE .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Cname (cnames.DNS_CNAME)
    					where (^{cnames.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Cname-is_ecrm_org_of .
    
                ecrm:Quota (quotas.ORG_ID, quotas.QUOTA_ID)
                    a ecrm:Quota
                        as virtrdf:Quota-Quotas ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label quotas.QUOTA_NAME;
                    ecrm:quotaName quotas.QUOTA_NAME
                        as virtrdf:Quota-QUOTA_NAME ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{quotas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Quota-ORG_ID ;
                    ecrm:spaceTotal quotas.SPACE_TOTAL
                        as virtrdf:Quota-SPACE_TOTAL .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Quota (quotas.ORG_ID, quotas.QUOTA_ID)
    					where (^{quotas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Quota-is_ecrm_org_of .
    
                ecrm:Role (roles.ORG_ID, roles.ROLE_ID)
                    a ecrm:Role
                        as virtrdf:Role-Roles ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label roles.ROLE_NAME;
                    ecrm:roleName roles.ROLE_NAME
                        as virtrdf:Role-ROLE_NAME ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{roles.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Role-ORG_ID ;
                    ecrm:parentID roles.PARENT_ID
                        as virtrdf:Role-PARENT_ID .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
                        ecrm:Role (roles.ORG_ID, roles.ROLE_ID)
                        where (^{roles.}^.ORG_ID = ^{organizations_data.}^.ORG_ID) as virtrdf:Role-is_ecrm_org_of .
    
                ecrm:Account (accounts.ORG_ID, accounts.ACCOUNT_ID)
                    a ecrm:Account
                        as virtrdf:Account-Accounts ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label accounts.ACCOUNT_NAME;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{accounts.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Account-ORG_ID ;
                    ecrm:accountType accounts.ACCOUNT_TYPE
                        as virtrdf:Account-ACCOUNT_TYPE ;
                    ecrm:accountName accounts.ACCOUNT_NAME
                        as virtrdf:Account-ACCOUNT_NAME ;
                    ecrm:data accounts.DATA
                        as virtrdf:Account-DATA .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:Account (accounts.ORG_ID, accounts.ACCOUNT_ID)
    					where (^{accounts.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Account-is_ecrm_org_of .
    
                ecrm:UserData (userdatas.ORG_ID, userdatas.ACCOUNT_ID)
                    a ecrm:UserData
                        as virtrdf:UserData-UserDatas ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{userdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:UserData-ORG_ID ;
                    ecrm:has_account ecrm:Account(userdatas.ORG_ID, userdatas.ACCOUNT_ID)
                        as virtrdf:UserData-ACCOUNT_ID ;
                    ecrm:status userdatas.STATUS
                        as virtrdf:UserData-STATUS ;
                    ecrm:loginPassword userdatas.LOGIN_PWD
                        as virtrdf:UserData-LOGIN_PWD ;
                    ecrm:has_role ecrm:Role(userdatas.ORG_ID, userdatas.ROLE_ID)
                        as virtrdf:UserData-ROLE_ID ;
                    ecrm:has_quota ecrm:Quota(userdatas.ORG_ID, userdatas.QUOTA_ID)
                        as virtrdf:UserData-QUOTA_ID ;
                    ecrm:spaceUsed userdatas.SPACE_USED
                        as virtrdf:UserData-SPACE_USED ;
                    ecrm:lastLogin userdatas.LAST_LOGIN
                        as virtrdf:UserData-LAST_LOGIN ;
                    ecrm:loginPolicy userdatas.LOGIN_POLICY
                        as virtrdf:UserData-LOGIN_POLICY ;
                    ecrm:preferences userdatas.PREFERENCES
                        as virtrdf:UserData-PREFERENCES .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:UserData (userdatas.ORG_ID, userdatas.ACCOUNT_ID)
    					where (^{userdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:UserData-is_ecrm_org_of .
    					
    			ecrm:Role(userdatas.ORG_ID, userdatas.ROLE_ID)
                    ecrm:is_role_of
    				    ecrm:UserData (userdatas.ORG_ID, userdatas.ACCOUNT_ID)
    					as virtrdf:UserData-is_role_of .
    					
    			ecrm:Quota(userdatas.ORG_ID, userdatas.QUOTA_ID)
                    ecrm:is_quota_of
    				    ecrm:UserData (userdatas.ORG_ID, userdatas.ACCOUNT_ID)
    					as virtrdf:UserData-is_quota_of .
    					
    			ecrm:Account(userdatas.ORG_ID, userdatas.ACCOUNT_ID)
                    ecrm:is_account_of
    				    ecrm:UserData (userdatas.ORG_ID, userdatas.ACCOUNT_ID)
    					as virtrdf:UserData-is_account_of .
    
                ecrm:GroupData (groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
                    a ecrm:GroupData
                        as virtrdf:GroupData-GroupDatas ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{groupdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:GroupData-ORG_ID ;
                    ecrm:has_account ecrm:Account(groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
                        as virtrdf:GroupData-ACCOUNT_ID ;
                    ecrm:owner ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{groupdatas.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{groupdatas.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:GroupData-OWNER_ID .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:GroupData (groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
    					where (^{groupdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:GroupData-is_ecrm_org_of .
    					
    			ecrm:Account(groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
                    ecrm:is_account_of
    				    ecrm:GroupData (groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
    					as virtrdf:GroupData-is_account_of .
    					
    		   	ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:GroupData (groupdatas.ORG_ID, groupdatas.ACCOUNT_ID)
    					where (^{groupdatas.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{groupdatas.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:GroupData-account_manager .
    
                ecrm:Member (members.ORG_ID, members.GROUP_ID, members.USER_ID)
                    a ecrm:Member
                        as virtrdf:Member-Members ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{members.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:Member-ORG_ID ;
                    ecrm:has_groupData ecrm:GroupData(members.ORG_ID, members.GROUP_ID)
                        as virtrdf:Member-GROUP_ID ;
                    ecrm:has_userData ecrm:UserData(members.ORG_ID, members.USER_ID)
                        as virtrdf:Member-USER_ID ;
                    ecrm:addedBy members.ADDED_BY
                        as virtrdf:Member-ADDED_BY ;
                    ecrm:addedOn members.ADDED_ON
                        as virtrdf:Member-ADDED_ON .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:Member (members.ORG_ID, members.GROUP_ID, members.USER_ID)
    					where (^{members.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:Member-is_ecrm_org_of .
    					
    			ecrm:GroupData(members.ORG_ID, members.GROUP_ID)
                    ecrm:is_groupdata_of
    				    ecrm:Member (members.ORG_ID, members.GROUP_ID, members.USER_ID)
    					as virtrdf:Member-is_groupdata_of .
    					
    			ecrm:UserData(members.ORG_ID, members.USER_ID)
                    ecrm:is_userdata_of
    				    ecrm:Member (members.ORG_ID, members.GROUP_ID, members.USER_ID)
    					as virtrdf:Member-is_userdata_of .
    
                ecrm:SessionsData (sessionsdatas.SID)
                    a ecrm:SessionsData
                        as virtrdf:SessionsData-SessionsDatas ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{sessionsdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:SessionsData-ORG_ID ;
                    ecrm:has_account ecrm:Account(sessionsdatas.ORG_ID, sessionsdatas.ACCOUNT_ID)
                        as virtrdf:SessionsData-ACCOUNT_ID ;
                    ecrm:createdOn sessionsdatas.CREATED_ON
                        as virtrdf:SessionsData-CREATED_ON ;
                    ecrm:expireOn sessionsdatas.EXPIRE_ON
                        as virtrdf:SessionsData-EXPIRE_ON ;
                    ecrm:forceExpire sessionsdatas.FORCE_EXPIRE
                        as virtrdf:SessionsData-FORCE_EXPIRE ;
                    ecrm:dirty sessionsdatas.DIRTY
                        as virtrdf:SessionsData-DIRTY ;
                    ecrm:ipAddr sessionsdatas.IP_ADDR
                        as virtrdf:SessionsData-IP_ADDR .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:SessionsData (sessionsdatas.SID)
    					where (^{sessionsdatas.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:SessionsData-is_ecrm_org_of .
    					
    			ecrm:Account(sessionsdatas.ORG_ID, sessionsdatas.ACCOUNT_ID)
                    ecrm:is_account_of
    				    ecrm:SessionsData (sessionsdatas.SID)
    					as virtrdf:SessionsData-is_account_of .
    
                ecrm:SessionData (sessiondatas.SID, sessiondatas.BUFFER_ID)
                    a ecrm:SessionData
                        as virtrdf:SessionData-SessionDatas ;
                    ecrm:has_sessionsData ecrm:SessionsData(sessiondatas.SID)
                        as virtrdf:SessionData-SID ;
                    ecrm:BUFFER_ID sessiondatas.BUFFER_ID
                        as virtrdf:SessionData-BUFFER_ID .
                        
    			ecrm:SessionsData(sessiondatas.SID)
                    ecrm:is_sessionsdata_of
    				    ecrm:SessionData (sessiondatas.SID, sessiondatas.BUFFER_ID)
    					as virtrdf:SessionData-is_sessionsdata_of .
    
                ecrm:Class (classes.CLASS_ID)
                    a ecrm:Class
                        as virtrdf:Class-Classes ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label classes.CLASS_NAME;
                    ecrm:className classes.CLASS_NAME
                        as virtrdf:Class-CLASS_NAME ;
                    ecrm:keyPrefix classes.KEY_PREFIX
                        as virtrdf:Class-KEY_PREFIX ;
                    ecrm:classTable classes.CLASS_TABLE
                        as virtrdf:Class-CLASS_TABLE ;
                    ecrm:data classes.DATA
                        as virtrdf:Class-DATA ;
                    ecrm:category classes.CATEGORY
                        as virtrdf:Class-CATEGORY ;
                    ecrm:weight classes.WEIGHT
                        as virtrdf:Class-WEIGHT ;
                    ecrm:xmlSchema classes.XML_SCHEMA
                        as virtrdf:Class-XML_SCHEMA .
    
                ecrm:OrgClass (org_classes.ORG_ID, org_classes.CLASS_ID)
                    a ecrm:OrgClass
                        as virtrdf:OrgClass-OrgClasses ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{org_classes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:OrgClass-ORG_ID ;
                    ecrm:has_class ecrm:Class(org_classes.CLASS_ID)
                        as virtrdf:OrgClass-CLASS_ID ;
                    ecrm:customFields org_classes.CUSTOM_FIELDS
                        as virtrdf:OrgClass-CUSTOM_FIELDS .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:OrgClass (org_classes.ORG_ID, org_classes.CLASS_ID)
    					where (^{org_classes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:OrgClass-is_ecrm_org_of .
    
                ecrm:ClassMethod (class_methods.CLASS_ID, class_methods.METHOD_ID)
                    a ecrm:ClassMethod
                        as virtrdf:ClassMethod-ClassMethods ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_class ecrm:Class(class_methods.CLASS_ID)
                        as virtrdf:ClassMethod-CLASS_ID ;
                    ecrm:methodId class_methods.METHOD_ID
                        as virtrdf:ClassMethod-METHOD_ID ;
                    ecrm:methodType class_methods.METHOD_TYPE
                        as virtrdf:ClassMethod-METHOD_TYPE .
                        
    			ecrm:Class(class_methods.CLASS_ID)
                    ecrm:is_class_of
    				    ecrm:ClassMethod (class_methods.CLASS_ID, class_methods.METHOD_ID)
    					as virtrdf:ClassMethod-is_class_of .
    
                ecrm:ClassView (class_views.ORG_ID, class_views.VIEW_ID)
                    a ecrm:ClassView
                        as virtrdf:ClassView-ClassViews ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
    				rdfs:label class_views.VIEW_NAME;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{class_views.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:ClassView-ORG_ID ;
                    ecrm:owner ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{class_views.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{class_views.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:ClassView-OWNER_ID ;
                    ecrm:has_class ecrm:Class(class_views.CLASS_ID)
                        as virtrdf:ClassView-CLASS_ID ;
                    ecrm:viewName class_views.VIEW_NAME
                        as virtrdf:ClassView-VIEW_NAME ;
                    ecrm:viewData class_views.VIEW_DATA
                        as virtrdf:ClassView-VIEW_DATA ;
                    ecrm:isPublic class_views.IS_PUBLIC
                        as virtrdf:ClassView-IS_PUBLIC .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:ClassView (class_views.ORG_ID, class_views.VIEW_ID)
    					where (^{class_views.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:ClassView-is_ecrm_org_of .
    					
    			ecrm:Class(class_views.CLASS_ID)
                    ecrm:is_class_of
    				    ecrm:ClassView (class_views.ORG_ID, class_views.VIEW_ID)
    					as virtrdf:ClassView-is_class_of .
    					
    		   	ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:ClassView (class_views.ORG_ID, class_views.VIEW_ID)
    					where (^{class_views.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{class_views.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:ClassView-account_manager .
    
                ecrm:RolePrivelege (role_priveleges.ORG_ID, role_priveleges.ROLE_ID, role_priveleges.CLASS_ID, role_priveleges.METHOD_ID)
                    a ecrm:RolePrivelege
                        as virtrdf:RolePrivelege-RolePriveleges ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{role_priveleges.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:RolePrivelege-ORG_ID ;
                    ecrm:has_role ecrm:Role(role_priveleges.ORG_ID, role_priveleges.ROLE_ID)
                        as virtrdf:RolePrivelege-ROLE_ID ;
                    ecrm:has_class ecrm:Class(role_priveleges.CLASS_ID)
                        as virtrdf:RolePrivelege-CLASS_ID ;
                    ecrm:has_method ecrm:ClassMethod(role_priveleges.CLASS_ID, role_priveleges.METHOD_ID)
                        as virtrdf:RolePrivelege-METHOD_ID .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:RolePrivelege (role_priveleges.ORG_ID, role_priveleges.ROLE_ID, role_priveleges.CLASS_ID, role_priveleges.METHOD_ID)
    					where (^{role_priveleges.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:RolePrivelege-is_ecrm_org_of .
    					
    			ecrm:Role(role_priveleges.ORG_ID, role_priveleges.ROLE_ID)
                    ecrm:is_role_of
    				    ecrm:RolePrivelege (role_priveleges.ORG_ID, role_priveleges.ROLE_ID, role_priveleges.CLASS_ID, role_priveleges.METHOD_ID)
    					as virtrdf:RolePrivelege-is_role_of .
    
                ecrm:UserPrivelege (user_priveleges.ORG_ID, user_priveleges.USER_ID, user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
                    a ecrm:UserPrivelege
                        as virtrdf:UserPrivelege-UserPriveleges ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{user_priveleges.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:UserPrivelege-ORG_ID ;
                    ecrm:has_userData ecrm:UserData(members.ORG_ID, user_priveleges.USER_ID)
                        as virtrdf:UserPrivelege-USER_ID ;
                    ecrm:has_class ecrm:Class(user_priveleges.CLASS_ID)
                        as virtrdf:UserPrivelege-CLASS_ID ;
                    ecrm:has_method ecrm:ClassMethod(user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
                        as virtrdf:UserPrivelege-METHOD_ID .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:UserPrivelege (user_priveleges.ORG_ID, user_priveleges.USER_ID, user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
    					where (^{user_priveleges.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:UserPrivelege-is_ecrm_org_of .
    					
    			ecrm:UserData(members.ORG_ID, user_priveleges.USER_ID)
                    ecrm:is_userdata_of
    				    ecrm:UserPrivelege (user_priveleges.ORG_ID, user_priveleges.USER_ID, user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
    					as virtrdf:UserPrivelege-is_userdata_of .
    					
    			ecrm:Class(user_priveleges.CLASS_ID)
                    ecrm:is_class_of
    				    ecrm:UserPrivelege (user_priveleges.ORG_ID, user_priveleges.USER_ID, user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
    					as virtrdf:UserPrivelege-is_class_of .
    					
    			ecrm:ClassMethod(user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
                    ecrm:is_classmethod_of
    				    ecrm:UserPrivelege (user_priveleges.ORG_ID, user_priveleges.USER_ID, user_priveleges.CLASS_ID, user_priveleges.METHOD_ID)
    					as virtrdf:UserPrivelege-is_classmethod_of .
    
                ecrm:History (history.ORG_ID, history.EVENT_ID)
                    a ecrm:History
                        as virtrdf:History-Historys ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{history.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:History-ORG_ID ;
                    ecrm:eventDate history.EVENT_DATE
                        as virtrdf:History-EVENT_DATE ;
                    ecrm:has_class ecrm:Class(history.CLASS_ID)
                        as virtrdf:History-CLASS_ID ;
                    ecrm:has_method ecrm:ClassMethod(history.CLASS_ID, history.METHOD_ID)
                        as virtrdf:History-METHOD_ID ;
                    ecrm:has_user ecrm:UserData(members.ORG_ID, history.USER_ID)
                        as virtrdf:History-USER_ID ;
                    ecrm:protocol history.PROTOCOL
                        as virtrdf:History-PROTOCOL ;
                    ecrm:location history.LOCATION
                        as virtrdf:History-LOCATION ;
                    ecrm:data history.DATA
                        as virtrdf:History-DATA .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:History (history.ORG_ID, history.EVENT_ID)
    					where (^{history.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:History-is_ecrm_org_of .
    					
    			ecrm:ClassMethod(history.CLASS_ID, history.METHOD_ID)
                    ecrm:is_classmethod_of
    				    ecrm:History (history.ORG_ID, history.EVENT_ID)
    					as virtrdf:History-is_classmethod_of .
    					
    			ecrm:UserData(members.ORG_ID, history.USER_ID)
                    ecrm:is_userdata_of
    				    ecrm:History (history.ORG_ID, history.EVENT_ID)
    					as virtrdf:History-is_userdata_of .
    
                ecrm:XSys_User (xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    a ecrm:XSys_User
                        as virtrdf:XSys_User-XSys_Users ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{xsys_users.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:XSys_User-ORG_ID ;
    				rdfs:label xsys_users.ACCOUNT_NAME;
                    ecrm:accountType xsys_users.ACCOUNT_TYPE
                        as virtrdf:XSys_User-ACCOUNT_TYPE ;
                    ecrm:accountName xsys_users.ACCOUNT_NAME
                        as virtrdf:XSys_User-ACCOUNT_NAME .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:XSys_User (xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
    					where (^{xsys_users.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:XSys_User-is_ecrm_org_of .
    
    			ecrm:AP_Process (ap_processes.ORG_ID, ap_processes.AP_ID)
                    a ecrm:AP_Process
                        as virtrdf:AP_Process-AP_Processes ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{ap_processes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:AP_Process-ORG_ID ;
                    ecrm:owner ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                        where (^{ap_processes.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{ap_processes.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
                        as virtrdf:AP_Process-OWNER_ID ;
                    ecrm:ProcessName ap_processes.NAME
                        as virtrdf:AP_Process-NAME ;
                    ecrm:ProcessDescription ap_processes.DESCRIPTION
                        as virtrdf:AP_Process-DESCRIPTION ;
                    ecrm:TargetClass ap_processes.TARGET_CLASS
                        as virtrdf:AP_Process-TARGET_CLASS ;
                    ecrm:Status ap_processes.STATUS
                        as virtrdf:AP_Process-STATUS ;
                    ecrm:AttachOnlyOne ap_processes.OPT_ATTACH_ONLY_ONE
                        as virtrdf:AP_Process-OPT_ATTACH_ONLY_ONE ;
                    ecrm:ExecImmediate ap_processes.OPT_EXEC_IMMEDIATE
                        as virtrdf:AP_Process-OPT_EXEC_IMMEDIATE ;
                    ecrm:ExecManualOnly ap_processes.OPT_EXEC_MANUAL_ONLY
                        as virtrdf:AP_Process-OPT_EXEC_MANUAL_ONLY ;
                    ecrm:AutoRestart ap_processes.OPT_AUTORESTART
                        as virtrdf:AP_Process-OPT_AUTORESTART ;
                    ecrm:AutoAttach ap_processes.OPT_AUTOATTACH
                        as virtrdf:AP_Process-OPT_AUTOATTACH .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:AP_Process (ap_processes.ORG_ID, ap_processes.AP_ID)
    					where (^{ap_processes.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:AP_Process-is_ecrm_org_of .
    					
    		   	ecrm:XSys_User(xsys_users.ORG_ID, xsys_users.ACCOUNT_NAME, xsys_users.ACCOUNT_ID)
                    ecrm:account_manager
    					ecrm:AP_Process (ap_processes.ORG_ID, ap_processes.AP_ID)
    					where (^{ap_processes.}^.OWNER_ID = ^{xsys_users.}^.ACCOUNT_ID and ^{ap_processes.}^.ORG_ID = ^{xsys_users.}^.ORG_ID)
    					as virtrdf:AP_Process-account_manager .
    
    			ecrm:AP_Rule (ap_rules.ORG_ID, ap_rules.AP_ID, ap_rules.RSEQ)
                    a ecrm:AP_Rule
                        as virtrdf:AP_Rule-AP_Rules ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{ap_rules.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:AP_Rules-ORG_ID ;
                    ecrm:process ecrm:AP_Process(ap_rules.ORG_ID, ap_rules.AP_ID)
                        as virtrdf:AP_Rules-APP_ID ;
                    ecrm:rType ap_rules.RTYPE
                        as virtrdf:AP_Rules-RTYPE ;
                    ecrm:RuleName ap_rules.NAME
                        as virtrdf:AP_Rules-NAME ;
                    ecrm:TargetData ap_rules.TRG_DATA
                        as virtrdf:AP_Rules-TRG_DATA ;
                    ecrm:actData ap_rules.ACT_DATA
                        as virtrdf:AP_Rules-ACT_DATA .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    				    ecrm:AP_Rule (ap_rules.ORG_ID, ap_rules.AP_ID, ap_rules.RSEQ)
    					where (^{ap_rules.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:AP_Rule-is_ecrm_org_of .
    					
    			ecrm:AP_Process(ap_rules.ORG_ID, ap_rules.AP_ID)
                    ecrm:is_process_of
    				    ecrm:AP_Rule (ap_rules.ORG_ID, ap_rules.AP_ID, ap_rules.RSEQ)
    					as virtrdf:AP_Rule-is_process_of .
    
    			ecrm:AP_Queue (ap_queues.ID)
                    a ecrm:AP_Queue
                        as virtrdf:AP_Queue-AP_Queues ;
                    rdfs:isDefinedBy ecrm:isDefinedBy () ;
                    ecrm:has_ecrm_organization ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
    					where (^{ap_queues.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
                        as virtrdf:AP_Queue-ORG_ID ;
                    ecrm:process ecrm:AP_Process(ap_queues.ORG_ID, ap_queues.AP_ID)
                        as virtrdf:AP_Queue-APP_ID ;
                    ecrm:OBJ_ID ap_queues.OBJ_ID
                        as virtrdf:AP_Queue-OBJ_ID ;
                    ecrm:isRunning ap_queues.IS_RUNNING
                        as virtrdf:AP_Queue-IS_RUNNING ;
                    ecrm:isDebug ap_queues.IS_DEBUG
                        as virtrdf:AP_Queue-IS_DEBUG ;
                    ecrm:currentRule ecrm:AP_Rule (ap_queues.ORG_ID, ap_queues.AP_ID, ap_queues.CURRENT_RULE)
                        as virtrdf:AP_Queue-CURRENT_RULE ;
                    ecrm:lastPass ap_queues.LAST_PASS
                        as virtrdf:AP_Queue-LAST_PASS ;
                    ecrm:lastExec ap_queues.LAST_EXEC
                        as virtrdf:AP_Queue-LAST_EXEC ;
                    ecrm:dateAttach ap_queues.DATE_ATTACH
                        as virtrdf:AP_Queue-DATE_ATTACH ;
                    ecrm:dateStart ap_queues.DATE_START
                        as virtrdf:AP_Queue-DATE_START .
                        
    			ecrm:OrganizationsData(organizations_data.ORG_ID, organizations_data.DNS_ZONE)
                    ecrm:ecrm_organization_of
    					ecrm:AP_Queue (ap_queues.ID)
    					where (^{ap_queues.}^.ORG_ID = ^{organizations_data.}^.ORG_ID)
    					as virtrdf:AP_Queue-is_ecrm_org_of .
    					
    			ecrm:AP_Rule (ap_queues.ORG_ID, ap_queues.AP_ID, ap_queues.CURRENT_RULE)
                    ecrm:is_CurrentRule_of
    					ecrm:AP_Queue (ap_queues.ID)
    					as virtrdf:AP_Queue-is_rule_of .
            } .
    } .
    ;
    	
    delete from db.dba.url_rewrite_rule_list where urrl_list like 'ecrm_%';
    delete from db.dba.url_rewrite_rule where urr_rule like 'ecrm_%';
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
        'ecrm_rule1',
        1,
        '(/[^#]*)',
        vector('path'),
        1,
        '/about/html/http/^{URIQADefaultHost}^%s%%01this',
        vector('path'),
        null,
        '(text/html)|(\\*/\\*)',
        0,
        303
        )
    ;
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
        'ecrm_rule2',
        1,
        '(/[^#]*)',
        vector('path'),
        1,
        '/sparql?query=CONSTRUCT+{+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%23this%%3E+%%3Fp+%%3Fo+}+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/ecrm%%3E+WHERE+{+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%23this%%3E+%%3Fp+%%3Fo+}&format=%U',
        vector('path', 'path', '*accept*'),
        null,
        '(text/rdf.n3)|(application/rdf.xml)',
        0,
        null
        )
    ;
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
        'ecrm_rule3',
        1,
        '(/[^#]*)/\x24',
        vector('path'),
        1,
        '%U',
        vector('path'),
        null,
        null,
        0,
        null
        )
    ;
    
    create procedure DB.DBA.ECRM_MAKE_RDF_DET()
    {
        declare uriqa_str varchar;
        uriqa_str := cfg_item_value(virtuoso_ini_path(), 'URIQA','DefaultHost');
        uriqa_str := 'http://' || uriqa_str || '/ecrm';
        DB.DBA."RDFData_MAKE_DET_COL" ('/DAV/VAD/eCRM/RDFData/', uriqa_str, NULL);
        VHOST_REMOVE (lpath=>'/ecrm/data/rdf');
        DB.DBA.VHOST_DEFINE (lpath=>'/ecrm/data/rdf', ppath=>'/DAV/VAD/eCRM/RDFData/All/', is_dav=>1, vsp_user=>'dba');
    }
    ;
    DB.DBA.ECRM_MAKE_RDF_DET()
    ;
    drop procedure DB.DBA.ECRM_MAKE_RDF_DET
    ;
    
    -- procedure to convert path to DET resource name
    create procedure DB.DBA.ECRM_DET_REF (in par varchar, in fmt varchar, in val varchar)
    {
      declare res, iri any;
      declare uriqa_str varchar;
      uriqa_str := cfg_item_value(virtuoso_ini_path(), 'URIQA','DefaultHost');
      uriqa_str := 'http://' || uriqa_str || '/ecrm';
      iri := uriqa_str || val;
      res := sprintf ('iid (%d).rdf', iri_id_num (iri_to_id (iri)));
      return sprintf (fmt, res);
    }
    ;
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('ecrm_rdf', 1,
        '/ecrm/(.*)', vector('path'), 1,
        '/ecrm/data/rdf/%U', vector('path'),
        'DB.DBA.ECRM_DET_REF',
        'application/rdf.xml',
        2,
        303)
    ;
    
    create procedure DB.DBA.ECRM_DET_REF2 (in par varchar, in fmt varchar, in val varchar)
    {
    	declare tmp, stream any;
    	declare oid, inst, class, sid, url varchar;
    	declare pos, org_id_ integer;
    	val := replace(val, '%27', '\'');
    	val := replace(val, '%20', ' ');
    	if (val like '%/%/view.vsp?sid=%&oid=%')
    	{
    		tmp := sprintf_inverse (val, '%s/%s/view.vsp?sid=%s&oid=%s', 0);
    		inst := tmp[0];
    		class := tmp[1];
    		sid := tmp[2];
    		oid := tmp[3];
    		pos := strchr(oid, '&');
    		if (pos is not NULL)
    		{
    			oid := left(oid, pos);
    		}
    		org_id_ := (select WAI_ID from DB.DBA.WA_INSTANCE where WAI_NAME = inst);
    		if (class = 'company')
    		{
    			for (select COMPANY_NAME, COMPANY_ID from eCRM.DBA.SFA_COMPANIES where cast(COMPANY_ID as varchar) = oid and ORG_ID = org_id_) do
    			{
    				url := sprintf('Company/%U/%U/%d#this', COMPANY_NAME, COMPANY_ID, org_id_);
    			}
    		}
    		if (class = 'lead')
    		{
    			for (select SUBJECT, LEAD_ID from eCRM.DBA.SFA_LEADS where cast(LEAD_ID as varchar) = oid and ORG_ID = org_id_) do
    			{
    				url := sprintf('Lead/%U/%d/%U#this', SUBJECT, org_id_, LEAD_ID);
    			}
    		}
    		if (class = 'opportunity')
    		{
    			url := sprintf('Lead/%d/%/U#this', org_id_, oid);
    		}
    		if (class = 'contact')
    		{
    			for (select NAME_FIRST, NAME_MIDDLE, NAME_LAST, CONTACT_ID from eCRM.DBA.SFA_CONTACTS where cast(CONTACT_ID as varchar) = oid and ORG_ID = org_id_) do
    			{
    				url := sprintf('Contact/%U/%U/%U/%U/%d#this', NAME_FIRST, NAME_MIDDLE, NAME_LAST, CONTACT_ID, org_id_);
    			}
    		}
    		if (class = 'order')
    		{
    			url := sprintf('Order/%d/%U#this', org_id_, oid);
    		}
    
    	}
    	else if (val like '%/%/view.vsp?sid=%')
    	{
    		tmp := sprintf_inverse (val, '%s/%s/view.vsp?sid=%s', 0);
    		inst := tmp[0];
    		class := tmp[1];
    		sid := tmp[2];
    		org_id_ := (select WAI_ID from DB.DBA.WA_INSTANCE where WAI_NAME = inst);
    		if (class = 'organization')
    		{
    			for (select DNS_ZONE from eCRM.DBA.XSYS_ORGANIZATIONS_DATA where ORG_ID = org_id_) do
    			{
    				url := sprintf('OrganizationsData/%d/%U#this', org_id_, DNS_ZONE);
    			}
    		}
    	}
    	return url;
    }
    ;
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('ods_ecrm_rdf',
    	1,
        '/dataspace/([^/]*)/eCRM/(.*)',
        vector('uname', 'path'),
        1,
        '/ecrm/%U',
        vector('path'),
        'DB.DBA.ECRM_DET_REF2',
        'application/rdf.xml',
        2,
        303)
    ;
    
    DB.DBA.URLREWRITE_CREATE_RULELIST (
    	'ecrm_rule_list1',
    	1,
    	vector (
    	'ecrm_rule1',
    	'ecrm_rule2',
    	'ecrm_rule3',
    	'ecrm_rdf'
    	))
    ;
    
    VHOST_REMOVE (lpath=>'/ecrm');
    DB.DBA.VHOST_DEFINE (lpath=>'/ecrm', ppath=>'/DAV/VAD/eCRM/', vsp_user=>'dba', is_dav=>1, def_page=>'sfront.vspx', is_brws=>0, opts=>vector ('url_rewrite', 'ecrm_rule_list1'));
    
    create procedure DB.DBA.LOAD_ECRM_ONTOLOGY_FROM_DAV()
    {
    
      declare ses, stat, msg, metas, rset, query, _source any;
    
      metas := NULL;  rset  := NULL;
      stat := '00000'; msg := '';
    
      _source := 'http://www.openlinksw.com/data/turtle/ecrm.ttl' ; 
       query  := sprintf('SPARQL define get:soft "no-sponge" load <%s> into <http://www.openlinksw.com/schemas/eCRMOntology/1.0/>',_source);
    
      exec (query, stat, msg, vector (), 0, metas, rset);
      if (stat <> '00000') {
        log_message(sprintf ('Load eCRM Ontology: An error occurred %s %s', stat, msg));
      };
      commit work;
    
    	--declare content, urihost varchar;
    	--select cast (RES_CONTENT as varchar) into content from WS.WS.SYS_DAV_RES where RES_FULL_PATH = '/DAV/VAD/eCRM/ecrm.owl';
    	--DB.DBA.RDF_LOAD_RDFXML (content, 'http://www.openlinksw.com/ontology/ecrm#', '');
    	--urihost := cfg_item_value(virtuoso_ini_path(), 'URIQA','DefaultHost');
    	--if (urihost = 'www.openlinksw.com')
    	--{
    	--	DB.DBA.VHOST_REMOVE (lpath=>'/ontology/ecrm');
    	--	DB.DBA.VHOST_DEFINE (lpath=>'/ontology/ecrm', ppath=>'/DAV/VAD/eCRM/ecrm.owl', vsp_user=>'dba', is_dav=>1, is_brws=>0);
    	--}
    }
    ;
    DB.DBA.LOAD_ECRM_ONTOLOGY_FROM_DAV()
    ;
    drop procedure DB.DBA.LOAD_ECRM_ONTOLOGY_FROM_DAV
    ;
    
    XML_SET_NS_DECL ('virt-ecrm', 'http://www.openlinksw.com/ontology/ecrm#', 2)
    ;
    
    -- Reload the persistent eCRM RDF Views i.e. with persistent RDF Views option  -- the inclusion of triggers for updating the Quad Store
    
    create procedure DB.DBA.RELOAD_PERSISTENT_ECRM_RDF_VIEWS()
    {
    
      declare ses, stat, msg, metas, rset, query, _host any;
      declare _baseGraph, _targetGraph any;
    
      metas := NULL;  
      rset  := NULL; 
      stat  := '00000'; 
      msg   := '';
    
      _host        := registry_get ('URIQADefaultHost');
      _baseGraph   := sprintf('http://%s/ecrm',_host);
      _targetGraph := sprintf('urn:%s:ecrm',_host);
      query        := sprintf('SPARQL clear graph <%s>',_targetGraph);
    
      log_enable(3,1);
      exec (query, stat, msg, vector (), 0, metas, rset);
      if (stat <> '00000') {
        log_message(sprintf ('Reload persistent eCRM RDF Views: An error occurred %s %s', stat, msg));
      };
      commit work;
      
      log_enable(1) ;
      
      RDF_VIEW_SYNC_TO_PHYSICAL (_baseGraph, 0, _targetGraph, 1, 1);
    
    }
    ;
    DB.DBA.RELOAD_PERSISTENT_ECRM_RDF_VIEWS()
    ;
    drop procedure DB.DBA.RELOAD_PERSISTENT_ECRM_RDF_VIEWS
    ;
    
    

    Example for Reloading the persistent eCRM RDF Views:


    Connected to OpenLink Virtuoso
    Driver: 06.04.3132 OpenLink Virtuoso ODBC Driver
    OpenLink Interactive SQL (Virtuoso), version 0.9849b.
    Type HELP; for help and EXIT; to exit.
    SQL> RDF_VIEW_SYNC_TO_PHYSICAL ('http://localhost:8890/ecrm', 1, 'urn:myecrm:data');
    STATE    MESSAGE
    VARCHAR  VARCHAR
    _______________________________________________________________________________
    
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    22023    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo1> is not used in storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads>
    
    in
    signal:(BIF),
            __01 => '22023',
            __02 => 'Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo1> is not used in storage <http://www.op' (truncated),
    DB.DBA.RDF_QM_DROP_MAPPING([executable]/sparql.sql:10755),
         storage => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
         mapname => (ARRAY_OF_POINTER value, tag 193),
    <Top Level>,
              :0 => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
              :1 => (ARRAY_OF_POINTER value, tag 193)
    00000    Reloading built-in metadata, this might fix some errors without accurate reporting that they did exist
    00000    Built-in metadata were reloaded
    00000    Metadata from system graph are cached in memory-resident JSOs (JavaScript Objects)
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo1> is added to the storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads
    >
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is unflagged and can be edited by other transactions
    00000    Transaction committed, SPARQL compiler re-configured
    00000    4 RDF metadata manipulation operations done
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    22023    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo2> is not used in storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads>
    
    in
    signal:(BIF),
            __01 => '22023',
            __02 => 'Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo2> is not used in storage <http://www.op' (truncated),
    DB.DBA.RDF_QM_DROP_MAPPING([executable]/sparql.sql:10755),
         storage => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
         mapname => (ARRAY_OF_POINTER value, tag 193),
    <Top Level>,
              :0 => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
              :1 => (ARRAY_OF_POINTER value, tag 193)
    00000    Reloading built-in metadata, this might fix some errors without accurate reporting that they did exist
    00000    Built-in metadata were reloaded
    00000    Metadata from system graph are cached in memory-resident JSOs (JavaScript Objects)
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo2> is added to the storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads
    >
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is unflagged and can be edited by other transactions
    00000    Transaction committed, SPARQL compiler re-configured
    00000    4 RDF metadata manipulation operations done
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    22023    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo3> is not used in storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads>
    
    in
    signal:(BIF),
            __01 => '22023',
            __02 => 'Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo3> is not used in storage <http://www.op' (truncated),
    DB.DBA.RDF_QM_DROP_MAPPING([executable]/sparql.sql:10755),
         storage => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
         mapname => (ARRAY_OF_POINTER value, tag 193),
    <Top Level>,
              :0 => UNAME'http://www.openlinksw.com/schemas/virtrdf#SyncToQuads',
              :1 => (ARRAY_OF_POINTER value, tag 193)
    00000    Reloading built-in metadata, this might fix some errors without accurate reporting that they did exist
    00000    Built-in metadata were reloaded
    00000    Metadata from system graph are cached in memory-resident JSOs (JavaScript Objects)
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is flagged as being edited
    00000    Quad map <http://www.openlinksw.com/schemas/virtrdf#ecrmDemo3> is added to the storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads
    >
    00000    Quad storage <http://www.openlinksw.com/schemas/virtrdf#SyncToQuads> is unflagged and can be edited by other transactions
    00000    Transaction committed, SPARQL compiler re-configured
    00000    4 RDF metadata manipulation operations done
    
    33 Rows. -- 19031 msec.
    

    Related