Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @select(
- " select
- product_id,
- product_name,
- product_price,
- product_image,
- product_url
- from
- product
- where
- valid_flag = '1' "
- @condition(
- (not (null product_name))
- " and
- product_name like :product_name")
- @condition(
- (and (not (null price_low))
- (not (null price_high)))
- " and
- product_price between :price_low and :price_high")
- " order by
- product_id
- limit :limit ")
- (defsql fetch-product (product_name price_low price_high limit))
- ;; ->
- (defun fetch-product (&key product_name price_low price_high limit)
- (let* ((sql (format NIL "~A~A~A~A"
- "select product_id...."
- (if (not (null product_name))
- " and product_name like :product_name "
- "")
- (if (and (not (null price_low))
- (not (null price_high)))
- " and product_price between :price_low and :price_high"
- "")
- " order by product_id limit :limit "))
- (query (prepare *db* sql))
- (result (execute query (list :product_name product_name :price_low price_low :price_high price_high :limit limit))))
- (fetch-all result)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement