[Qt-interest] Variants and Binds

Bill King bill.king at nokia.com
Thu Sep 24 05:06:04 CEST 2009


Actually, I think qRegisterMetaTypeStreamOperators<> () may be more
along the lines of what you're looking for.

On 09/24/2009 11:15 AM, ext Jason H wrote:
> Right, but something somewhere Qt is serializing my date to be to_char('2001-01-01', 'YYYY-MM-DD'). I'd like to do the same for my data type, except my serialization  is just not quoting the string value. I would have hoped that the registering with QVariant would have allowed me to do that... Where QDate is  to_char '%1', 'YYYY-MM-DD'), I'd just have it output %1 (no quotes) and my problem would be solved.
>
> But thanks for your help.
>
>
>
>
>
> ----- Original Message ----
> From: Tony Rietwyk <tony.rietwyk at rightsoft.com.au>
> To: qt-interest at trolltech.com
> Sent: Wednesday, September 23, 2009 9:04:24 PM
> Subject: Re: [Qt-interest] Variants and Binds
>
> I have no idea what the Qt Oracle driver does.  It should be able to
> transfer date/time values into the database without converting them to or
> from string.  
>
> to_char is an Oracle function, and has nothing to do with Qt. 
>
> Tony.
>
>
>   
>> -----Original Message-----
>> From: Jason H [mailto:scorp1us at yahoo.com] 
>> Sent: Thursday, 24 September 2009 10:54
>> To: Tony Rietwyk; qt-interest at trolltech.com
>> Subject: Re: [Qt-interest] Variants and Binds
>>
>>
>> It does help, but where does the "to_char('2001-01-01', 
>> 'YYYY-MM-DD')" come from? I learned that was being done from 
>> from boundValues()
>>
>>
>>
>> ----- Original Message ----
>> From: Tony Rietwyk <tony.rietwyk at rightsoft.com.au>
>> To: qt-interest at trolltech.com
>> Sent: Wednesday, September 23, 2009 8:45:54 PM
>> Subject: Re: [Qt-interest] Variants and Binds
>>
>> Jason wrote:
>>
>>     
>>> I wish to add a new kind of class to QVariant, so that I can 
>>> use it in a SQL bind.
>>>
>>> Specifically, I need to provide access to database 
>>> expressions. For  instance a QDate object is serialized to 
>>> to_char('2001-01-01', 'YYYY-MM-DD') when used in Oracle. I 
>>> need to provide a very similar thing in that I need 
>>> SEQUENCE.nextval (an expression, not a string) so that my 
>>> call is bindValue(":rowid", 
>>> Expression("TABLE_ID_SEQUENCE.nextval")); If I use a 
>>> QByteArray, I get "TABLE_ID_SEQUENCE.nextval", the string, 
>>> and that isn't a valid numeric record ID. 
>>>
>>> So I need to know how I can create  a datatype that won't 
>>>       
>> be quoted. 
>>     
>>> Thanks!
>>>       
>> Hi Jason, 
>>
>> Even if you did add the extra type to QVariant, it would not 
>> work.  A SQL
>> expression can only be evaluated on the server, and you can 
>> only bind values
>> on the client.  
>>
>> I think you can either: 
>>
>> - Put the expression into the actual SQL statement, for 
>> example, insert into
>> tableName(fieldName1, fieldName2...) values 
>> (TABLE_ID_SEQUENCE.nextval,
>> :fieldName2...)
>>
>>     Then just bind the other fields. 
>>
>> - Or you need to explicitly select the value from the sequence first: 
>>
>>     myQuery.exec("select TABLE_ID_SEQUENCE.nextval from dual");
>>     myQuery.next();
>>     int sequence = myQuery.value(0).toInt;
>>
>> then bind that value just like the fields.  
>>
>> Hope that helps, 
>>
>> Tony.
>>     
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>       
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
Bill King, Software Engineer
Qt Development Frameworks, Nokia Pty Ltd
Brisbane Office




More information about the Qt-interest-old mailing list