SunQuest
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 15th, 2003, 01:13 AM
sehiser sehiser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toledo, OH
Posts: 14 sehiser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How do I write back by line item?

Hello,

I'm writting a program in VB to connect to an AS/400 via ODBC.

The customer I am working with has a table of sales orders.

A sales order may contain 50-100 line items. Each line would be for a different item associated with the same order.

As of right now, I would be using the item name to identify where to write back an update to the line item.

What I am wondering is, can I write back by line item instead?

They don't seem to have a key index, but I am going with what they are telling me.

So would this be possible? I have numerous books on different versions of SQL but I thought I would post the question just incase I can get a response here before I page through my books.

Thanks,

Reply With Quote
  #2  
Old August 15th, 2003, 06:12 AM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
You would need to know what the unique key(s) is(are) in order to do updates per record. I presume your AS/400 database will accept ANSI SQL statements, so just do an update where your 'where' clause contains enough elements to ensure uniqueness.
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
  #3  
Old August 15th, 2003, 05:47 PM
sehiser sehiser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toledo, OH
Posts: 14 sehiser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, but that is how I am doing it now.

I need to write back by line item, not a key index. I thought there was a way you could specify which line item to write too.

For instance, suppose I am writting back to a MDB through ODBC.

ORDER, ITEM, QTY, OPTION
12345, WIDGET, 5, null
12345, WIDGET, 3, RED
12345, WIDGET, 3, BLUE
12345, WIDGET, 5, RED
12345, WIDGET, 5, BLUE
12345, GADGET, 3, RED
etc...

Based on the above, I would have to write a select like this...

SELECT * FROM SALES WHERE ORDER = '12345' AND ITEM = 'WIDGET' AND QTY = '3'AND OPTION = 'RED'

That can get cumbersome. Wouldn't it be easier if I could index and sort then writeback to a specific line using the same sort?

See, I also have to work with a database that stores customer orders, but adds lines using the same order for each option they add to their order.

I may have to just do a lot of coding, but I thought I saw somebody do it by line item before.

Reply With Quote
  #4  
Old August 15th, 2003, 05:54 PM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
If I am understanding what you are doing, you want to do an update without all the where clauses. That only works if your database has unique keys in the table. Some databases do that automagically, others don't. If your DBAs say there is no primary key, I think you are probably SOL.

You should be writing this in code, so once written all should be done in a loop, so whats the big deal?

Reply With Quote
  #5  
Old August 15th, 2003, 06:12 PM
sehiser sehiser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toledo, OH
Posts: 14 sehiser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The big deal was finding out if I could write by line item instead of coding everything and get the same result. You don't know if you don't ask or come across it reading. So I asked.

Just like if somebody is writting in PHP.

print $strReturn = ( $value = 12) ? "Yes it is!":"No it's not";

is an easy way of writting all this...

If $value = 12 then {
$strReturn = "Yes it is!"
}
else {
$strReturn = "Not it's not"
}
print $strReturn;

If somebody didn't ask they wouldn't know and that's much easier.

So there is no big deal when it comes to a question because no question is stupid. In fact, writting back by a line item is a great idea that should be incorporated as a standard function in a future release of a SQL extention.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > How do I write back by line item?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway