Hi Shantanu,

I finally got it working as follows:

(defmulti parse-int type)
(defmethod parse-int java.lang.Integer [n] n)
(defmethod parse-int java.lang.String [s] (Integer/parseInt s))

(defn get-a-member [id]
  (layout/render "member/profile2.html"
    {:member (db/get-member-url (parse-int id))}
    (session/put! :member-id (parse-int id))))

So parse-int ensures id is specified as an integer for postgres.

I have another question. I'd like to get the username from this result set and 
put it in session. How would I add that to the above code. If I add :username 
username to the session PUT statement, it doesn't recognize it.

(defn get-a-member [id]
  (layout/render "member/profile2.html"
    {:member (db/get-member-url (parse-int id))}
    (session/put! :member-id (parse-int id) :username username)))

So I look up the record, and from that record I want to extract id and username 
and put them in session as member-id and username.

Btw, would you recommend using an ORM or straight java.jdbc and if an ORM, any 
particular one you'd recommend?

Best,
Pardeep.


On Feb 11, 2014, at 1:16 AM, Shantanu Kumar wrote:

> Can you post the SQL template (with ? symbols) you are trying to execute? 
> Usually, with PostgreSQL you can specify ?::integer in place of ? to imply 
> that the passed parameter is an integer.
> 
> Shantanu
> 
> On Tuesday, 11 February 2014 13:52:54 UTC+5:30, The Dude (Abides) wrote:
> Hi, I'm getting an error calling a record from an id passed via a url using 
> Korma Sql. The error says:
> 
> org.postgresql.util.PSQLException
> 
> ERROR: operator does not exist: smallint = character varying Hint: No 
> operator matches the given name and argument type(s). You might need to add 
> explicit type casts. Position: 57
> 
> I have a list of members, with a url /member/:id to call profile for that 
> member in the view showing the member list. Here's my 3 moving parts:
> 
> ROUTE
> 
> (GET "/member/:id" [id] (get-the-member id))
> 
> FUNCTION
> 
> (defn get-the-member [id]
>     (layout/render 
>       "member/profile.html"
>       {:member (db/get-member-url id)}))
> 
> MODEL
> 
> (defn get-member-url [id]
>   (first (select members
>                  (where {:id id})
>                  (limit 1))))
> 
> Now if I hard code the id number in the model, it works, but its not 
> accepting the id var as an integer. How would I give it an explicit typecast 
> in this instance. Or would it perhaps be better to use java.jdbc or another 
> ORM like Sql Lingov, HoneySQL, Clojureql or clojure-sql? Rest of crud working 
> fine, but id var not being accepted by the model. The model itself works if 
> an id number is hardcoded. Perhaps I'm missing some simple syntax point here?
> 
> -- 
> 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 a topic in the Google 
> Groups "Clojure" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/clojure/F9S5W9xEhWs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to