Dynamic Query

Posted by Admin on 03-Apr-2009 03:46

hello, i am beginer of progress, when i tried to make a dynamic query i got error in my query due to the use of can-find keyword inside the  so how i ensure that

the existance of related field isin other table or not ? if there is one to many relationship is there. the code is like that.

  def var xtest   as handle   no-undo.
  def var v-query-test as char no-undo.

  create query xtest. 
  xtest:set-buffers(buffer xsrequest:handle,buffer xsrcomment:handle).
 
v-query-test = "for each xsrequest no-lock where xsrequest.xpren = 1 
    AND ( xsrequest.xpmon = 1)
    and ( xsrequest.xprvn = 2 or xsrequest.xprvn = 4)
    and ( xsrequest.xsrtn = 1 or xsrequest.xsrtn = 2)
    and ( xsrequest.xstac = '1000' or xsrequest.xstac = '2000' or xsrequest.xstac = '8000')
    and ( xsrequest.xsrpn = 1 or xsrequest.xsrpn = 4)
    and ( xsrequest.xsrecassign = 'kacharya' or xsrequest.xsrecassign = 'PSTAdmin')
    and ( xsrequest.xsreccreator = 'PSTAdmin')
    AND ( xsrequest.xsrettitle CONTAINS 'svn'
     OR   xsrequest.xsrem CONTAINS 'svn'
     OR  CAN-FIND(FIRST  xsrcomment where xsrequest.xsretid = xsrcomment.xsretid  AND xsrcomment.xsrctcomment MATCHES 'svn')
        )" .


   message v-query-test VIEW-AS ALERT-BOX.
  xtest:query-prepare(v-query-test). 
                                          
                                                                                         
  xtest:query-open().
 
  repeat while not xtest:query-off-end:
    xtest:get-next().

   
    DISP xsrequest.xsretid  .

  end.
xtest:query-close().
delete object xtest.

All Replies

This thread is closed