Re: [Zope] Fw: [Zope] Parameter in ZSQL

2000-08-13 Thread jan

Indra Gunawan wrote:
> 
>  Thanks man that really works..!!...
>  I want to ask another question
>  can I retrieve a random row from a table?

Yes, you can - but how is a bit dependent on your database, if
you want it to be efficient. The problem here is that SQL does
not by itseld define a rownum or similar.

If, on the other hand, you have a unique, sequential "id" column
in your table, you can use that in a SELECT statement.
Read up on SELECT in your SQL manual.

Probably, I'd do it as follows (untested, but should give you the
general idea):

in your DTML method, use an expression to get a random value
between 1 and the number of rows in your table. An SQL method
like

 SELECT count(*) AS rowcount FROM table;

gives you the total number of rows.

An expression like int(rnd()*rowcount) will give you a random
value to use in a SELECT (you'll need to define it as a parameter
or pass it in via REQUEST). You could use your current
ShowProduct for that. For the details of the random call, see
your Python manual (mine is in the office).

HTH,
Jan

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] Fw: [Zope] Parameter in ZSQL

2000-08-13 Thread Indra Gunawan


 Thanks man that really works..!!...
 I want to ask another question
 can I retrieve a random row from a table?
 if can, could anyone tell me 
 (using the same table and scheme from the previous question)
 
 Thanks again Mr Philipp Auersperg 
 
 -IGUN-
 ICQ:1474584
> 
> 
> > call :
> > 
> > 
> > with  you just define a variable in the current namespace
> > 
> > Philipp Auersperg (zwork)
> > 
> 
>  
> 


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Parameter in ZSQL

2000-08-13 Thread Philipp Auersperg

call :


with  you just define a variable in the current namespace

Philipp Auersperg (zwork)

*** REPLY SEPARATOR  ***

On 13.08.2000 at 17:27 Indra Gunawan wrote:

>Hello All
>here's the problem
>my Zope 2.2.0 is running on win98
>my Database is a MySQL
>
>I created a ZSQL method named ShowProduct with parameter product_id
>
>the template as follows : select * from products where type=string>
>
>why can't I call the ZSQL method directly (without using the GET/POST
>variables)?
>I try to call it like this
>
>
>
>...(i would like to insert some of programs here if this is working)
>
>
>
>
>it always returns error like this
>Error Type: Bad Request
>Error Value: ['product_id']
>
>can anyone help please? is there any workaround for this?
>TIA
>
>-IGUN-
>ICQ:1474584
>
>
>
>
>___
>Zope maillist  -  [EMAIL PROTECTED]
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )




___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] Parameter in ZSQL

2000-08-13 Thread Indra Gunawan

Hello All
here's the problem
my Zope 2.2.0 is running on win98
my Database is a MySQL

I created a ZSQL method named ShowProduct with parameter product_id

the template as follows : select * from products where 

why can't I call the ZSQL method directly (without using the GET/POST
variables)?
I try to call it like this



...(i would like to insert some of programs here if this is working)




it always returns error like this
Error Type: Bad Request
Error Value: ['product_id']

can anyone help please? is there any workaround for this?
TIA

-IGUN-
ICQ:1474584




___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )