Book a Demo

Author Topic: Executing Query with current data possible Repository.SQLQuery API call ?  (Read 4015 times)

conan

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Hi Guys

I would like to run a query in Repository.SQLQuery function similar to "Recently Modified Element" query.

Code: [Select]
SELECT * from t_object WHERE t_object.ModifiedDate >= #Now - <Search Term># ORDER BY ModifiedDate ASC

The above query is getting executed in the EA SQL Editor  , but not getting executed in the Repository.SQLQuery method.
i understood that #Now - <Search Term>#  keyword is specific to EA , but is there any way i can run the above query with current date ? similar to ( Datetime.now() or Now() ) to access the current day modified elements ?

( i dont want to define a search , i need to run the query in a script using Repository.SQLQuery function )


TIA
Conan
 




qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Calculate the date and replace the #...#  part with in the valid SQL formatted date (depends on the database). Since you want to run it from a script that should be not issue. EA's search has a couple of these functions like #Branch# which replaces the text with a(n internally scripted) list of package ids before passing the query to the DB.

q.

conan

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Hi qwerty

Thanks for the reply . In that case is there any way available in the EA script to get the current date ? Similar to Datetime.now()  in c# or now() in sql ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Depends on the language. In VBScript you can use now()

Geert