Dear all, I am developing a web application for a biological research institute down here in india. I have some problem in using JOINS. The below is the queries i used, *SQL query **File name : drug* select drug_name,dtype from bio_info_schema.drug order by dtype *File name:drug_gene_details* Note : i used both the sql queries seperately, but neither one worked. SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug_gene.gene_name FROM drug,drug_gene WHERE drug.drug_name = drug_gene.drug_name and drug.drug_name=<dtml-sqlvar drug_name type=string> SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug.dtype,drug_gene.gene_name FROM drug INNER JOIN drug_gene ON drug.drug_name = drug_gene.drug_name AND drug.drug_name=<dtml-sqlvar drug_name type=string> Below is the DTML code i have used, *File name : view_drug_detail* <table width = 30% border = 1 > <tr> <!-- Table header --> <th>Drug Name</th> </tr> <!-- Iterate through drug details using dtml-in tag --> <dtml-in drug> <!-- for each drug , print out the drug name and type of drug --> <tr> <td align = center> <a href="http://localhost:8080/ddrd/ddrtb/drugs/display_drugs/* drug_gene_details*/drug_name/<dtml-var drug_name>/*view_drug_info*"><dtml-var drug_name></a></td> </tr> </dtml-in> </table> *File name : view_drug_info* <h3><font color= #008000><center>Drug Information Summary</center></font></h3> <table width = 100% border = 1 align=center> <tr> <th>Drug name</th><td><dtml-var drug_name></td> </tr> <tr> <th>Route of Administration</th><td><dtml-var route_of_admin></td> </tr> <tr> <th>Dosage (Adult)</th><td><dtml-var dose_adult></td> </tr> <tr> <th>Dosage (Child)</th><td><dtml-var dose_child></td> </tr> <tr> <th>Adverse Effects</th><td><dtml-var adverse_effects></td> </tr> <tr> <th>Drug Type</th><td><dtml-var dtype></td> </tr> <tr> <th>Drug Targets</th><td><dtml-var gene_name></td> </tr> </table> This is the error which i got. Site Error An error was encountered while publishing this resource. exceptions.KeyError Sorry, a site error occurred. Traceback (innermost last): * Module ZPublisher.Publish, line 150, in publish_module * Module ZPublisher.Publish, line 114, in publish * Module Zope, line 134, in zpublisher_exception_hook * Module Shared.DC.ZRDB.DA, line 547, in __getattr__ KeyError: _r Troubleshooting Suggestions * The URL may be incorrect. * The parameters passed to this resource may be incorrect. * A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. Any kind of suggestion and help will be very useful. Thanks in advance. -- Best Regards \madhan Things must be learned only to be unlearned again or, more likely, to be corrected. -- Richard Feynman
Did you try the Test tab at ZSQL method management page? If it does not work, you will get error from SQL server. If it works and you does not get any data, then your query is not fit to any data. ----- Original Message ----- From: member madhangc To: zope@zope.org Sent: Tuesday, April 15, 2008 1:08 PM Subject: [Zope] Problem with DTML and JOINS(ZSQL) Dear all, I am developing a web application for a biological research institute down here in india. I have some problem in using JOINS. The below is the queries i used, SQL query File name : drug select drug_name,dtype from bio_info_schema.drug order by dtype File name:drug_gene_details Note : i used both the sql queries seperately, but neither one worked. SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug_gene.gene_name FROM drug,drug_gene WHERE drug.drug_name = drug_gene.drug_name and drug.drug_name=<dtml-sqlvar drug_name type=string> SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug.dtype,drug_gene.gene_name FROM drug INNER JOIN drug_gene ON drug.drug_name = drug_gene.drug_name AND drug.drug_name=<dtml-sqlvar drug_name type=string>
Zope is agnostic of whatever SQL you enter. In other words, they compile differently and their errors are completely different. I suggest you do this: 1. Fake the ZSQL to make sure your DTML is correct by changing the SQL to something like this: SELECT 'drug_name_test', 'route_of_admin_test', etc. 2. Then write the ZSQL properly with the correct SQL syntax that you want to use and as you're developing this, test it using the ZSQL Method's Test tab rather than testing it via your custom DTML application. 3. Run together. PS. Tip: I always name my ZSQL methods something like select_all_drug_zsql or UpdateOneDrug.sql just to avoid confusion when I'm later working on the application. 'drug' isn't a suitable name of a function/method. On 15/04/2008, member madhangc <madhangc@opensuse.us> wrote:
Dear all, I am developing a web application for a biological research institute down here in india. I have some problem in using JOINS. The below is the queries i used,
SQL query
File name : drug select drug_name,dtype from bio_info_schema.drug order by dtype
File name:drug_gene_details Note : i used both the sql queries seperately, but neither one worked.
SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug_gene.gene_name FROM drug,drug_gene WHERE drug.drug_name = drug_gene.drug_name and drug.drug_name=<dtml-sqlvar drug_name type=string>
SELECT drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug.dtype,drug_gene.gene_name FROM drug INNER JOIN drug_gene ON drug.drug_name = drug_gene.drug_name AND drug.drug_name=<dtml-sqlvar drug_name type=string>
Below is the DTML code i have used,
File name : view_drug_detail <table width = 30% border = 1 > <tr> <!-- Table header --> <th>Drug Name</th> </tr> <!-- Iterate through drug details using dtml-in tag --> <dtml-in drug> <!-- for each drug , print out the drug name and type of drug --> <tr> <td align = center> <a href="http://localhost:8080/ddrd/ddrtb/drugs/display_drugs/drug_gene_details/drug_name/<dtml-var drug_name>/view_drug_info"><dtml-var drug_name></a></td> </tr> </dtml-in> </table>
File name : view_drug_info <h3><font color= #008000><center>Drug Information Summary</center></font></h3> <table width = 100% border = 1 align=center> <tr> <th>Drug name</th><td><dtml-var drug_name></td> </tr> <tr> <th>Route of Administration</th><td><dtml-var route_of_admin></td> </tr> <tr> <th>Dosage (Adult)</th><td><dtml-var dose_adult></td> </tr> <tr> <th>Dosage (Child)</th><td><dtml-var dose_child></td> </tr> <tr> <th>Adverse Effects</th><td><dtml-var adverse_effects></td> </tr> <tr> <th>Drug Type</th><td><dtml-var dtype></td> </tr> <tr> <th>Drug Targets</th><td><dtml-var gene_name></td> </tr> </table>
This is the error which i got.
Site Error
An error was encountered while publishing this resource. exceptions.KeyError Sorry, a site error occurred. Traceback (innermost last): * Module ZPublisher.Publish, line 150, in publish_module * Module ZPublisher.Publish, line 114, in publish * Module Zope, line 134, in zpublisher_exception_hook * Module Shared.DC.ZRDB.DA, line 547, in __getattr__ KeyError: _r Troubleshooting Suggestions * The URL may be incorrect. * The parameters passed to this resource may be incorrect. * A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience.
Any kind of suggestion and help will be very useful. Thanks in advance.
-- Best Regards \madhan
Things must be learned only to be unlearned again or, more likely, to be corrected. -- Richard Feynman _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (3)
-
Jaroslav Lukesh -
member madhangc -
Peter Bengtsson