您的位置:首页 > 其它

Some useful DQL tips

2010-11-12 17:31 399 查看
1.[b]DQLtocreateuser[/b]

create“dm_user”object
setclient_capability=2,
setdefault_folder=’<foldername>’,
sethome_docbase=’<docbasename>’,
setmailto:user_address='a@abc.com',
setuser_os_domain=’<domain>’,
setuser_name=’<username>’,
setuser_os_name=’<username>’,
setuser_privileges=0;

2.[b]DQLtoexecutestoredprocedure(worksforallsupportedDBMSes)[/b]

executeexec_sqlwithquery=’executemy_sp_test”123”,”prasad”‘;

3.Running[b]DQLinbatchmode[/b]

a.Createadqlfile

b.Runthefollowingfromcommandprompt

$idqldocbasename-Uusername-Ppassword-Rtest.dql

Examplecommand

C:/Documentum/product/5.3/bin>idql32docbasename-Uusername-Ppassword-RC:
/test.dql

test.dqlwouldcontainsomethinglikethis

<dqlstatement1;>
go
<dqlstatement2;>
go

4.[b]DQLtoGetallFilesunderaParticularCabinet[/b]

selectr_object_id,object_namefromdm_document(all)wherefolder(’/Cabinetname’,descend);

TheaboveDQLgivesallversions.Togetonlycurrentversions

select*fromdm_documentwherefolder(’/Cabinetname’,descend)

5.[b]DQLtogettotalnumberofdocumentsandfoldersunderacabinet[/b]


SELECTcount(*)ascnt,‘Docs’ascategoryFROMdm_document(all)
WHEREFOLDER(’/CabinetName’,DESCEND)
UNION
SELECTcount(*)ascnt,‘Folders’ascategoryFROMdm_folder
WHEREFOLDER(’/CabinetName’,DESCEND)

6.[b]DQLtofindwhetheradocumentisapartofvirtualdocument[/b]

SELECTobject_name,r_object_idFROMdm_sysobject
WHEREr_object_idIN
(SELECTparent_idFROMdmr_containment
WHEREcomponent_id=(SELECTi_chronicle_idFROMdm_sysobjectWHEREr_object_id=‘<child-object-id>’))

7.Repeatingattributes

Repeatedattributequeriesarealwaysafun.Iamgoingtopresentheremorerepeatedattributequeries.Butforstarters,recognizetheimportanceofANYkeyword

selectr_folder_pathfromdm_folderwhereobject_name
=’myFolder’andanyr_folder_path=’/CabinetName/test’;

8.[b]DQLtofindobjecttypeofadocument[/b]

selectr_object_typefromdm_documentwhereobject_name=’ObjectName’;

9.[b]DQLforindex[/b]

Followingquerycreatesindex
EXECUTEmake_indexWITHtype_name=’dmi_workitem’,attribute=’r_workflow_id’

Usingthequerybelow,onecanfindoutwhetherindexhasbeensuccesfullycreatedoralternativelywhethertheindexexistsornot

Selectr_object_id,index_type,attribute,attr_count,data_spacefromdmi_indexwhereindex_typein(selectr_object_idfromdm_typewherename=’dmi_workitem’);

10.[b]DQLtoseesessions[/b]

executeshow_sessions

11.EnableFTDQL

SELECT
r_object_id,
score,
text,
object_name,
r_object_type,
r_lock_owner,
owner_name,
r_link_cnt,
r_is_virtual_doc,
r_content_size,
a_content_type,
i_is_reference,
r_assembled_from_id,
r_has_frzn_assembly,
a_compound_architecture,
i_is_replica,
r_policy_id,acl_name,
r_creation_date,
r_modify_date,
subject
FROM
custom_document
WHERE
(custom_attr1=’search1′AND
(custom_attr2=’search2′AND
))AND
(a_is_hidden=FALSE)
ENABLE
(FTDQL)


12.[b]DQLtogetcurrentdate,time[/b]
selectDATE(now)assystimefromdm_server_config;

13.[b]DQLtolistallavailabletemplatesinWebpublisher[/b]

select*frommy_documentwherefolder(’/WebPublisherConfiguration/ContentTemplates/myTemplates’,descend)andanyr_version_label=’Approved’;

14.[b]DQLtolistobjectshavingduplicatenames[/b]

SELECTobject_name,count(*)FROMdm_document
GROUPBYobject_name
HAVINGcount(*)>1
ORDERBYobject_name

15.ClearINBOX

deletedmi_queue_itemobjectswheredelete_flag=0

16.[b]DQLtoretrieveallrequiredattributesofaparticulartype[/b]
SELECTattr_nameFROMdmi_dd_attr_infoWHEREtype_name=’dm_document’ANDis_required<>0

17.[b]DQLtolistworkflowattachments[/b]

selectr_component_id,r_component_namefromdmi_wf_attachmentwherer_workflow_id=‘<workflowID>’

18.Ifyourstatisticsarenotuptodate,databasemaychooseaveryinefficientexecutionplan.Besuretoupdatestatisticsoften.Itisrecommendedthatyouusethedm_UpdateStatisticsjobasitwillcalculateextendedstatisticsonparticulartablesandcolumnswhichprovideadditionalperformancebenefits.IftheDBAusestheirownscriptstocalculatethestatistics,thentheseenhancementswillnotbeavailable.

19.Usethescript“dctm_indexes_by_table.sql”togeneratealistofallindexesonDocumentumtables,orderedbytablename.(Availablefromhttp://developer.documentum.com.)
Usethescript“dctm_indexes_by_index.sql”togeneratealistofallindexesonDocumentumtables,
orderedbyindexname.(Availablefromhttp://developer.documentum.com.)

20.ItisstronglyrecommendedthatallindexesonDocumentumbasetablesbecreatedfromwithinDocumentumandnotatthedatabaselevel.
Therearetworeasonsforthis:
TheinternalconversionprocessfromDQLtoSQLwillcheckforthepresenceofadmi_indexobjectforrepeatingvaluedattributesandwillgeneratedifferentSQLaccordingtowhatitfinds.
IfindexesarecreateddirectlythroughSQL*Plus,thenDocumentumwillnotknowanythingaboutthemandwillassumeitisunindexed.ThismayresultinalessefficientSQLquery.
Secondly,iftheindexesarecreatedfromwithinDocumentum,andtheyareinadvertentlydropped,thedm_DBWarningjobwillautomaticallyrecreatethematnextexecution.
Thesyntaxforcreatingnewindexesisasfollows:

InDQL:
EXECUTEmake_indexWITHtype_name=object_type,
attribute=attribute_name{,attribute=attribute_name,…)
or
UsingAPIs:
dmAPIGet(”apply,session,NULL,MAKE_INDEX,TYPE_NAME,S,object_type,ATTRIBUTE,S
,attribute_name(,ATTRIBUTE,S,attribute_name,…}
Theseindexeswillbecreatedinthetablespaceidentifiedbytheindex_storeserver.iniparameter.
Besuretocreatetheindexontheappropriatetypetable.
Forexample,although‘keywords’isanattributeofthedm_documenttype,itisactuallyinheritedfrom‘keywords’fromthedm_sysobjecttype.

DroptheIndexifNecessary
Ifthereisnoperformanceimprovement,ORtheoptimizerisnotusingthenewindex,dropitusing:
EXECUTEdrop_index[[FOR]dmi_index_id][WITHname=index_name]
or
dmAPIGet(”apply,session,dmi_index_id,DROP_INDEX[,NAME,S,index_name]“)

21.UsingtheiapiutilityandthetraceAPIyoucangenerateloginformationthatcontainstheSQLresultingfromaDQLquery.
ThisisusefulwhenitisaDQLquerythatisperformingpoorlyandyouwishtotestusinganonsuperuseraccount.Non-querytypeAPIsarenottraced.
HereisanexampleoftracingasimpleDQLquery.
trace,c,10,,DM_QUERY.

MoreonTKPROFhere

http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm

22.[b]DQLHints[/b]

SELECTobject_nameFROMdm_documentENABLE(RETURN_TOP10)

ForDB2,performancecanbeimprovedusing
SELECTobject_nameFROMdm_documentENABLE(RETURN_TOP10,OPTIMIZE_TOP10)

TheFETCH_ALL_RESULTSNhintfetchesalltheresultsfromthedatabase
immediatelyandclosesthecursor.Thehintdoesnotaffecttheexecutionplan,
butmayfreeupdatabaseresourcesmorequickly.
Tofetchalltheresults,setNto0.
OnSQLServer,itisrecommendedthatyouuseSQL_DEF_RESULT_SETS
insteadoftheFETCH_ALL_RESULTShint.SQL_DEF_RESULTS_SETS
providesthesamebenefitsandistherecommendedwaytoaccessSQLServer
databases.

PassthroughhintsarehintsthatarepassedtotheRDBMSserver.Theyarenot
handledbyContentServer.

Toincludeapassthroughhint,youmustidentifythedatabaseforwhichthe
hintisvalid.Toidentifythetargetdatabase,keywordsprecedethehints.The
validkeywordsare:ORACLE,SQL_SERVER,SYBASE,andDB2.For
example,thefollowingstatementincludespassthroughhintsforSQLServer:
SELECT“r_object_id”FROM“dm_document”
WHERE“object_name”=’test’
ENABLESQL_SERVER(’ROBUSTPLAN’,'FAST4’,’ROBUSTPLAN’)
Forportability,youcanincludepassthroughhintsformultipledatabasesin
onestatement.Theentirelistofhintsmustbeenclosedinparentheses.The
syntaxis:
(database_hint_list{,database_hint_list})
wheredatabase_hint_listis:
db_keyword(’hint’{,’hint})
db_keywordisoneofthevalidkeywordsidentifyingadatabase.hintisanyhint
validonthespecifieddatabase.
Forexample:
SELECTobject_nameFROMdm_documentdocdm_useru
WHEREdoc.r_creator_name=u.user_nameENABLE
(ORACLE(’RULE’,’PARALLEL’),SYBASE(’ATISOLATIONREAD
UNCOMMITTED’),SQL_SERVER(’LOOPJOIN’,’FAST1’)

UseFETCH_ALL_RESULTSifyouwanttoreducetheresourcesusedbythe
databaseserverbyquicklyclosingcursors.OnSQLServer,try
FETCH_ALL_RESULTSifusingSQL_DEF_RESULT_SETSdidnotimprove
queryperformance.

23.Ifthetableisregistered,checkwiththeowneroftheregisteredtable,oraDocumentumsuperuser,aboutgivingyouaccesstothetable.

YouwillneedatleastaBROWSEpermitontheregisteredtableobjectinordertoaccessit.Ifthetablehasnotyetbeenregistered,checkwiththetable’sowneraboutregisteringit.NotethatyoumusthaveREADaccesstothedm_registeredobjectforthistableinordertoaccessitinanyway(SELECT,INSERT,UPDATE,DELETE).

Notethatifyouspecifiedthespecialdm_dbodocumentbaseowner,thefirstparameterwillholdtheactualnameofthedocumentbaseowner.

24.DQLtolistdocbrokers

executelist_targets

25.[b]DQLtolistworrkflowinformation[/b]

selecttask_name,task_state,actual_start_date,dequeued_datefromdmi_queue_itemwhererouter_id=‘workflowId’

26.Querytofindactiveworkflows,supervisorsoftheworkflows

selectr_object_id,object_name,title,owner_name,r_object_type,r_creation_date,r_modify_date,a_content_typefromdm_documentwherer_object_idin(selectr_component_idfromdmi_packagewherer_workflow_idin(selectr_object_idfromdm_workflowwherer_runtime_state=1))

26.ThoughthisisnotDQL,IthoughtofmentioninghereasitmostwidelyusedDFCoperation

sysObject.queue(”dm_autorender_win31″,_
“rendition”,_
0,_
False,_
dueDate,_
“rendition_req_ps_pdf”)

27.TofindACLsrelatedtodm_sysobject:
selectr_object_idasobj_id,object_namefrom

dm_sysobject(all)

whereacl_name=”and

acl_domain=”
TofindACLsasthedefaultACLofauser:
selectuser_namefromdm_userwhereacl_name=”
TofindACLsassociatedwithatype:
selectr_object_id,r_type_namefromdmi_type_infowhereacl_domain=”andacl_name=”
WhenthesequeriesdonotreturnanyrelatedobjectsandyoustillcannotdeletetheACL,usetracing:
IntheMessageTesterorIAPI,executethecommand:apply,c,NULL,SQL_TRACE,LEVEL,I,1
Then,trytodeletetheACLthatiscausingproblem.
Turnofftracingbyexecuting:
apply,c,NULL,SQL_TRACE,LEVEL,I,0
Examinethesessionlogforthetraceoutput,locatedin$DOCUMENTUM/dba/log//
Excerptofthesessionlog:
[DM_ACL_E_DESTROY_IN_USE]error:“FailedtodestroytheACL‘DocumentumUsers’indomain‘dbabep’becauseitisinuse.”

[DM_SESSION_I_SESSION_QUIT]info:“Session01000dcb80010ccfquit.”
RunthefollowingqueryfromOracleSQL:
selectr_object_idfromdm_sysobject_swhereacl_domain=’dbabep’andacl_name=’DocumentumUsers’unionselectr_object_idfromdm_user_swhereacl_domain=‘dbabep’andacl_name=’DocumentumUsers’unionselectr_object_idfromdmi_type_info_swhereacl_domain=’dbabep’andacl_name=’DocumentumUsers’
Itwillreturnther_object_idvalue=09000dcb800362c4.
RunthefollowingqueryfromIDQL:
selectobject_name

fromdm_sysobject

wherer_object_id=’09000dcb800362c4′
Iftheabovequeryreturnednothing,thenthisobjectcannotbeaccessedbyanyDocumentumWorkSpacemethod,onlyviaSQLintheunderlyingOracledatabase.ThefollowingentriesmustbedeletedattheRDBMSlevel:dm_sysobject_sanddm_sysobject_rtables;therearenoentriesinthedmi_objecttable

28.Listofobjecttypesandcorrespondingidentifiers.Helpfulwhenreadingthecode.

00dmi_audittrail_attrs
03dm_type
05dmr_containment
06dmr_content
08dm_application
08dm_job
08dm_procedure
08dm_query
08dm_script
08dm_smart_list
09dm_document
0bdm_folder
0cdm_cabinet
0ddm_assembly
10dm_method
11dm_user
12dm_group
19dm_registered
1fdmi_index
26dmi_registry
27dm_format
28dm_filestore
28dm_store
2cdm_distributedstore
2edmi_type_info
2fdm_dump_record
30dmi_dump_object_record
31dm_load_record
32dmi_load_object_record
37dm_relation
3adm_location
3bdm_fulltext_index
3cdm_docbase_config
3ddm_server_config
40dm_blobstore
41dm_note
45dm_acl
46dm_policy
49dmi_package
4admi_workitem
4cdm_activity
4ddm_workflow
53dm_literal_expr
5edm_federation
5fdm_audittrail_acl
5fdm_audittrail_group
5fdm_audittrail
66dm_alias_set
6admi_dd_attr_info
0bdm_taxonomy
0bdm_xml_application
6bdm_display_config
20dmi_sequence

29.JobschedulerQuery

SELECTALLr_object_id,a_next_invocation
FROMdm_job
WHERE(
(run_now=1)
OR((is_inactive=0)
AND((a_next_invocation<=DATE(’now’)
ANDa_next_invocationISNOTNULLDATE)
OR(a_next_continuation<=DATE(’now’)
ANDa_next_continuationISNOTNULLDATE)
)
AND((expiration_date>DATE(’now’))
OR(expiration_dateISNULLDATE))
AND((max_iterations=0)
OR(a_iterations<max_iterations))
)
)
AND(i_is_reference=0ORi_is_referenceisNULL)
AND(i_is_replica=0ORi_is_replicaisNULL)
ORDERBYa_next_invocation,r_object_id

29.DCTM5.3SP1dmcleanhasanewargument-clean_aborted_wf.Ifspecified,themethodremovesallabortedworkflowsintherepository.YoucansetthisusingDA

30.TodealwithapostrophesinDQL,escapewithapsotrophe.ForexampletofindalluserswithnamelikeO’Hare,usefollowingDQL

selectgroup_namefromdm_groupwhereanyusers_nameslike‘%O”Hare%’

31.Inordertoviewcompletedworkflows,youneedtoenableworkflowauditing.WorkflowManagerhasanoptiontoturnauditingONwithinaworkflowtemplatetoviewcompletedworkflows.

FromWorkflowManager:

1)Uninstalltemplate
2)File>TemplateProperties
3)UnderTemplateAuditTrailSetting,selectoption‘AlwaysOn’-Audittraildataforeachinstancewillbeavailableandsavedatworkflowcompletions.

32.Inaworkflow,aperformercanentercommentswhilehe/sheisperformingthetask.Andthosecommentsarecarriedtothenextperformerinthisworkflow.WhenusingWebPublisherworkflowreporttoreviewtheworkflowinstances,andinworkflowhistory,youareonlyabletogetthetruncatedcommentsbackfromWP’sinterface.Especiallyforthosealreadyabortedworkflowinstances,thereisnowaythatyoucangetthecompletecommentsbackfromWP’sGUI.Insomecases,thosecommentsareveryimportanttoourcustomersandtheyneedtofindawaytogetthosecommentsback.

Hereisthestepstogetthosecommentsback:

==

1)Identifytheworkflowfromthedm_workflowtable,getther_object_idoftheworkflow:

selectr_object_id,object_namefromdm_workflowwhereobject_name=‘yourworkflowname’
2)Identifythenotesthatarecarriedbythisworkflow:

selectr_note_idfromdmi_packagewherer_workflow_id=‘theobjectidoftheworkflow’
3)Getthecontentidofeachofthosenoteidsreturned:

selectr_object_idfromdmr_contentwhereanyparent_id=‘thenoteid’
4)GotoDA,Administration->JobManagement->Administration,usethe“GET_PATH”methodtofindoutthepathofthefileswhichstoresthecomments.

33.Querytogetalldocumentsexpiredinprevious1month

SELECTs.r_object_id,s.object_name,DATETOSTRING(”r.a_expiration_date”,’mm/dd/yyyy’)ascreation_date
FROMdm_sysobject_ss,dm_sysobject_rr
WHEREs.r_object_id=r.r_object_id
ANDs.r_object_type=‘dm_document’
ANDDATEDIFF(month,”r.a_expiration_date”,DATE(NOW))>=0
ANDDATEDIFF(month,”r.a_expiration_date”,DATE(NOW))<=1
ANDr.r_version_label=‘Expired’
ORDERBY3

34.DQLtofindallthefoldersinaCabinet,wherethefoldersarecontentless
SELECTf1.object_name,f1.r_object_id,f1.r_folder_path
FROMdm_folderf1
WHEREFOLDER(’/Cabinetname’,descend)
ANDNOTEXISTS(SELECTf2.object_nameFROMdm_sysobjectf2WHEREANYf2.i_folder_id=f1.r_object_id)
ORDERBYobject_name

35.DQLforfindingallcheckedoutdocumentsinadocbase
select*fromdm_documentwhere(r_lock_ownerisnotnullstringorr_lock_owner<>”orr_lock_owner<>‘‘)

36.DQLtolisttheuserswhohasaccesstoparticularfolderpath
SELECTi_all_users_namesFROMdm_group
WHEREgroup_nameIN(SELECTr_accessor_nameFROMdm_acl
WHEREobject_nameIN(SELECTacl_nameFROMdm_folder
WHEREANYr_folder_path=‘/folderpath’))
ORDERBYi_all_users_names

37.Querytofindoutwhatusersignedoffonwhatdocument

SELECT“audited_obj_id”FROM“dm_audittrail”WHERE
“event_name”=‘dm_signoff’AND
“user_name”=‘tom’AND
substr(”audited_obj_id”,1,2)=‘09′AND
“time_stamp”>=DATE(’01/01/1998′,‘dd/mm/yy’)AND
“time_stamp”<=DATE(TODAY)

38.Isthereanywayormethodbywhichwecancangettoknowabouttheperiod,wheneverametadata(attribute)isaddedtoobjectoranyofitssubobjecttypes.

Youwouldneedtoregisterthesaveeventtobeauditedonyourobjecttype.Wheneverapropertyischangeditwillhaveasaveeventtowriteittothecontentserver.

39.listingallcontentsthatareinWIPstateonly.IfacontentisalsoinStagingorActiveorExpiredstate,itwillnotshowupintheresult:

DQL>SELECTobject_name,r_version_labelFROMdm_sysobjectwhereanyr_version_labelin(’WIP’)andr_object_idnotin(selectr_object_idfromdm_sysobjectwhereanyr_version_labelin(’Staging’,‘Approved’,‘Expired’))

39.Querytogetallexpireddocumentsinpreviousmonth
SELECTs.r_object_id,s.object_name,DATETOSTRING(”r.a_expiration_date”,’mm/dd/yyyy’)ascreation_date
FROMdm_sysobject_ss,dm_sysobject_rr
WHEREs.r_object_id=r.r_object_id
ANDs.r_object_type=‘dm_document’
ANDDATEDIFF(month,”r.a_expiration_date”,DATE(NOW))>=0
ANDDATEDIFF(month,”r.a_expiration_date”,DATE(NOW))<=1
ANDr.r_version_label=‘Expired’
ORDERBY3

0.Querytofindthefilesystempathlocationofadocument

selectdoc.r_object_id,doc.object_name,MFILE_URL(”,-1,”)asmypath,doc.i_folder_idfromdm_documentdoc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: