RE: Re: [Zope] dynamically generating sql queries?
Hi, Thank you very much for your answer. As you suggested, i concatenate the string with an integer to create a fieldname and then pass it to zsql object along with language argument. I do everything inside a Script (Python) object that accepts 3 arguments (field,index,language)now. - result=field+str(index) res=context.select_sql(field=result, language=language) print res[0].result return printed - I test this python script inside ZMI and run into problems. It works only if I explicitly specify the columname like print res[0].author_1. another question- how can one specify row index here?(res[row index]). Each language has one row. thanks _ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ 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 )
[Zope] dynamically generating sql queries?
Hi, I have five fields in the database author1,author2..author5. Trying to generate a parameter for the select_sql method called result, I run into an error -cannot add type int to string. Could you please say how to concatenate a string and a number? please look at the code.. -- dtml-in _.range(1,6) dtml-call REQUEST.set('field','author') dtml-let field=field index=sequence-index result=field+index dtml-in select_sql(field=result , language=language) dtml-var sequence-key /dtml-in /dtml-let /dtml-in -- or is there a better way to generate 5 different sql quesries and display the result? thank you. _ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ 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 )