[Zope-DB] Problem selecting Oracle LOB's
Jorge O. Martinez
jmartinez@emediamillworks.com
Tue, 19 Mar 2002 10:48:19 -0500
Matt:
You are absolutely right. I looked at the source, and this is coming
back as well:
<tr>
<td>44</td> <--- THIS IS WHAT I SAW
<td><Products.DCOracle2.db.LobLocator instance at 996494></td>
(DIDN'T SEE THIS)
</tr>
I'll try what you suggest. One question though. How do I call the
'select' method? Does this look correct to you:
<dtml-in select>
<dtml-var Products.DCOracle2.db.LobLocator>
</dtml-in>
Thanks for your quick and accurate response,
Jorge M.
Matthew T. Kromer wrote:
> Jorge O. Martinez wrote:
>
>> (I am resubmitting this question because I had initially sent it with
>> the wrong subject, and figured people would think it's the same
>> subject. Sorry about that).
>>
>> Hi:
>>
>> I have been able to install Zope, DCOracle2, and was able to make a
>> connection to the DB, and execute simple queries displaying results
>> just fine.
>>
>> However, I have not been able to get LOB's to work. I am following the
>> examples from Peterb in:
>>
>> http://www.zope.org/Members/peterb/oracle_lobs
>>
>> I am trying to do a select blob, and I get the template to display the
>> id (which is the argument I pass), but don't get anything for the
>> knowledge_text (the LOB, which is only text), this is what I am getting:
>>
>> KNOWLEDGE ID KNOWLEDGE TEXT
>> 44
>
>
>
> I bet if you view source, you'll see the tag <LobLocator ...> as the 2nd
> argument, which the browser is hiding because it thinks its a tag.
>
>>
>> SQL used:
>> SELECT
>> knowledge_id, knowledge_text
>> FROM
>> knowledge
>> where
>> knowledge_id = 44
>>
>>
>> I know it must be my error because I think I am not calling the
>> "select" Python script correctly; I've tried several different ways,
>> and get all kinds of errors. Anybody outthere knows what is the
>> correct way to call it from the Z SQL Method? This is what I have in
>> my Z SQL Method:
>>
>> ------------
>>
>> SELECT
>> knowledge_id, knowledge_text
>> FROM
>> knowledge
>> <dtml-sqlgroup where>
>> <dtml-sqltest knowledge_id op=eq type=int optional>
>> </dtml-sqlgroup>
>
>
>
> Because you test something named knowledge_id, you have to pass it in as
> a parameter... see below
>
>>
>> <dtml-in select>
>> <dtml-var sequence-item>
>> </dtml-in>
>>
>> ** I am including 1 of the ways how I tried to call the 'select'
>> script but it does not work**
>>
>> ------------
>>
>> And this is the code in the select Python script (same from the sample
>> code). I've tried many different ways, this is just the latest:
>>
>> # Manually iterate over whole result set, copy into list of dicts just
>> # like dictionaries()
>> # except we also read all BLOBs in their entirety and put in the
>> value, # not the LobLocator
>>
>> result = []
>> for row in container.sql_select_blob(id=id):
>> lob = row['blob']
>> result.append({'id': row['id'], 'blob': lob.read()})
>> return result
>
>
>
> You want
>
> for row in container.sql_select_block(knowledge_id=id)
>
> ... presuming ID is the value you want to search for. It has to match
> the definition of the SQL method.
>
> Otherwise what you're doing is correct.
>
> Note that the latest DCOracle2 is "most correct" in CVS; I can't
> remember if there was a broken-ness to the LOB support in PR1.
>
>>
>> ** Note, I've tried this way, and also replacing the 'id=id' for
>> 'id=knowledge_id', but it did not work, also I replaced the 'blob' for
>> 'knowledge_text' (my blob), but it doesn't like it **
>>
>> I am new to Python and Zope, hence this basic question. I am sure it
>> must be something simple, so thanks for your patience,
>>
>> Regards,
>>
>> Jorge M.
>>
>>
>
>
--
Jorge O. Martinez
MIS Senior Associate
eMediaMillWorks
1100 Mercantile Lane, Suite 119
Largo, MD 20774
E-mail => jmartinez@eMediaMillWorks.com
Phone => (301)883-2482 ext. 105
Fax => (301)883-9754