how to check if the ResultSet is null?
Hi, I stuck on a problem: I am creating a registration form. I need to check if the person info has already in database. I created a Z SQL method which I used "select usr_email from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" I want to call this method from my dtml method and see if it returns "null". But I'm not sure how to implement this. In Java, it has ResultSet which I can check if it returns null. I'm not sure how to accomplish this in Zope. I could not find relevant document. If you know this, could you give me a hand? Thanks! Sa
You could always do something like this first: "select Count(usr_email) from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" Then check the result will be either 1 or 0. Cheers Peter -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Sa Sent: Thursday, 13 July 2000 6:04 AM To: zope@zope.org Subject: [Zope] how to check if the ResultSet is null? Hi, I stuck on a problem: I am creating a registration form. I need to check if the person info has already in database. I created a Z SQL method which I used "select usr_email from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" I want to call this method from my dtml method and see if it returns "null". But I'm not sure how to implement this. In Java, it has ResultSet which I can check if it returns null. I'm not sure how to accomplish this in Zope. I could not find relevant document. If you know this, could you give me a hand? Thanks! Sa
You could always do something like this first: "select Count(usr_email) from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" Then check the result will be either 1 or 0. That's asking for trouble 'cos Zope ain't gonna like an id such as 'Count(usr_email)', it's a great idea though :-) Here's how you might need to rephrase it to make Zope happy: "select Count(usr_email) as usremail from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" HTH, Chris
Sa wrote:
Hi, I stuck on a problem: I am creating a registration form. I need to check if the person info has already in database. I created a Z SQL method which I used "select usr_email from info(table name) where usr_email = <dtml-sqlvar usr_email type=string>" I want to call this method from my dtml method and see if it returns "null". But I'm not sure how to implement this. In Java, it has ResultSet which I can check if it returns null. I'm not sure how to accomplish this in Zope. I could not find relevant document. If you know this, could you give me a hand? Thanks!
If your ZSQL Method is named MyMethod: <dtml-in MyMethod> You've got some data <dtml-else> Nothing returned from the SQL </dtml-in> Hope that helps . . . -CJ
participants (4)
-
Chris Withers -
Christopher J. Kucera -
Peter Marriott -
Sa