Hi Ganesh, 

Please don’t do it this way, as you’re opening yourself to sql-injection. When 
doing parameterized queries in sql, please reach for prepared statements. 

As others have mentioned, next.jdbc with a sprinkle of honeysql on top should 
be exact what you’re looking for. 

Erik. 
-- 
i farta

> 20. des. 2020 kl. 16:26 skrev Ganesh Neelekani <ganeshneelek...@gmail.com>:
> 
> 
> Hello Team,
> 
> I am new to clojure and I wanted to write a function where input from map 
> keys are passed as parameter as input to the sql query.
> 
> (def query-body1 "
> select first_name, last_name
> from ${table_name}
> where 
>   person_id=${person_id}
> order by ${id}
> ")
> 
> 
> (def query-body2 "
> select first_name, last_name
> from ${table_name}
> where 
>   person_id=${person_id},
>   and first_name=${first_name},
>   and last_name=${last_name},
> order by ${id}
> ")
> 
> (functiona-name query-body1  (:table_name "Employee", :person_id 123, id: 
> "ABC"))
> 
> (functiona-name query-body2 (:table_name "Employee", :person_id 123, 
> :first_name "John", :last_name "David", id: "ABC"))
> 
> output should be 
> select first_name, last_name
> from Employee
> where 
>   person_id=123,
>   and first_name=John,
>   and last_name=David,
> order by ${id}
> 
> How can I achieve this?
> 
> Thanks,
> Ganesh N
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/clojure/3695bf0e-95df-4bce-b4a1-575c110c7994n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/62035614-F32E-45EE-875F-99ACD8EA6CD1%40assum.net.

Reply via email to