Jim Steil a écrit :
>
> I have a legacy table that I’m trying to update.  It has an integer
> primary key that works fine for most of what I’m doing.  But, in some
> situations I need to update a record based on values in 2 other
> fields.  Below is a snippet of the def:
>
>  
>
> class *OrderItem*(SQLObject):
>
>     class *sqlmeta*:
>
>         style = Style(longID=True)
>
>         idName = /'orderItemId'/
>
>        
>
>     orderItemId = IntCol()
>
>     orderNumber = IntCol()
>
>     lineNumber = IntCol()
>
>  
>
> What I need to do is find out if the orderNumber/lineNumber
> combination exists and if so, do an update of the attributes instead
> of adding a new record.
>
>  
>
> I suppose I could do a select and return an object and then do a get
> based on the orderItemId, but that seems cumbersome.  Is there
> something I can do so that I can perform a get against 2 columns,
> orderNumber and lineNumber in this case, something similar to:
>
>  
>
> X = OderItem.get(orderNumber=1234, lineNumber=1)
>
>  
>
>             -Jim
>
Why not a select?
X=OrderItem.selectBy(orderNumber=1234, lineNumber=1)
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to