If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > Update across different databases

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-06, 08:45
woodsdarren woodsdarren is offline
Registered User
 
Join Date: Jun 2005
Posts: 10
Update across different databases

I am using Pervasive.SQL 2000i. I have 2 databases, say db1 abd db2. In db1 I have a table tbl1 and in db2 i have a table with the same structure but different data. (db2 is a copy of db1). The structure is as follows:

db1
customer totalytd totallyr


db2
customer totalytd totallyr

The customer fields have the same data. I need to update 'totallyr' in db1 with the values in 'totalytd' in db2 for each customer. Can someone help me with the update statement for this? Thanks in advance!
Reply With Quote
  #2 (permalink)  
Old 01-11-06, 09:52
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
I don't know if it'll work with PSQL 2000i but in V8 (and later) you can add the database name (not DSN name) before the table name. For example:
select db1.table1.field1 from db1.table1
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 01-12-06, 09:50
woodsdarren woodsdarren is offline
Registered User
 
Join Date: Jun 2005
Posts: 10
Thanks for the reply. unfortunatley, PSQL 2000i does not like this syntax.
Reply With Quote
  #4 (permalink)  
Old 01-12-06, 09:57
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
What error does it give?
Also, what's the exact SQL statement you are using?
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #5 (permalink)  
Old 01-12-06, 10:37
woodsdarren woodsdarren is offline
Registered User
 
Join Date: Jun 2005
Posts: 10
This is the error:

ODBC Error: SQLSTATE = 37000, Native error code = 0
Syntax Error: UPDATE HPFYE.RM00103
SET HPFYE.RM00103.<< ??? >>TTLSLLYR = HPFSAMPLE.RM00103.TTLSLYTD
WHERE HPFYE.RM00103.CUSTNMBR = HPFSAMPLE.RM00103.CUSTNMBR

This is the statement:

UPDATE HPFYE.RM00103
SET HPFYE.RM00103.TTLSLLYR = HPFSAMPLE.RM00103.TTLSLYTD
WHERE HPFYE.RM00103.CUSTNMBR = HPFSAMPLE.RM00103.CUSTNMBR
Reply With Quote
  #6 (permalink)  
Old 01-12-06, 10:43
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Just to confirm:
TTLSLLYR is a field.
RM00103 is the table name
and
HPFYE is the database name (not ODBC DSN but Pervasive Database name).

Is that correct?
Does the following statement work:
select HPFYE.RM00103.TTLSLLYR from HPFSAMPLE.RM00103
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #7 (permalink)  
Old 01-12-06, 10:48
woodsdarren woodsdarren is offline
Registered User
 
Join Date: Jun 2005
Posts: 10
Yes, this is correct.

The statement does not work: It gives an error:
ODBC Error: SQLSTATE = 37000, Native error code = 0
Syntax Error: select HPFYE.RM00103.<< ??? >>TTLSLLYR from HPFSAMPLE.RM00103

This works though:
SELECT RM00103.TTLSLLYR FROM HPFSAMPLE.RM00103
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On