Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. @select(
  2. " select
  3. product_id,
  4. product_name,
  5. product_price,
  6. product_image,
  7. product_url
  8. from
  9. product
  10. where
  11. valid_flag = '1' "
  12. @condition(
  13. (not (null product_name))
  14. " and
  15. product_name like :product_name")
  16. @condition(
  17. (and (not (null price_low))
  18. (not (null price_high)))
  19. " and
  20. product_price between :price_low and :price_high")
  21. " order by
  22. product_id
  23. limit :limit ")
  24. (defsql fetch-product (product_name price_low price_high limit))
  25.  
  26. ;; ->
  27.  
  28. (defun fetch-product (&key product_name price_low price_high limit)
  29. (let* ((sql (format NIL "~A~A~A~A"
  30. "select product_id...."
  31. (if (not (null product_name))
  32. " and product_name like :product_name "
  33. "")
  34. (if (and (not (null price_low))
  35. (not (null price_high)))
  36. " and product_price between :price_low and :price_high"
  37. "")
  38. " order by product_id limit :limit "))
  39. (query (prepare *db* sql))
  40. (result (execute query (list :product_name product_name :price_low price_low :price_high price_high :limit limit))))
  41. (fetch-all result)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement