Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oracle varchar in remote view
Message
De
24/09/2004 16:56:26
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00945603
Message ID:
00945894
Vues:
15
I am testing a very basic oracle table with cursoradapters. The table is as follows:

Table: Generated_id
fields: FIELDID varchar(8)
LASTUSED varchar(20)
primary key: FIELDID

I created a class called test. Into test I added a class called caGenerated_id which is based on a cursoradapter.

I went through the cursor adapter builder and set the following:
Properties tab:
ODBC data source
use dsn - filled in with appropriate information and tested
Data Access tab:
Select command: select GENERATED_ID.* from GENERATED_ID
schema: FIELDID C(8), LASTUSED C(20)
buffer mode: optimistic table buffering
Auto update tab:
send updates - checked
auto update - checked
both fields checked for update
primary key field checked

I went through the data environment builder on the form. I did not fill in the data source type in the first tab. The the cursors tab I located my class and added the cursor adapter from the class. I left everything as displayed except what was in the autoupdate tab. For some reason the update fields were not longer checked nor was the primary key field checked. So I rechecked them as before. Any idea why this was like what I saw?

I then added a command button on the form to test the operation of the cursoradapter. The following is the code from the buttons click event:

SELECT genkey
BROWSE NORMAL
SELECT genkey
INSERT INTO genkey (fieldid, lastused) VALUES ('test','0123')
SELECT genkey
BROWSE NORMAL
SELECT genkey
llupdate = TABLEUPDATE(.T.,.T.,'genkey')
IF llupdate
=MESSAGEBOX('success')
ELSE
AERROR(cErrorArray)
=MESSAGEBOX("Error: " + STR(cErrorArray(1)) + CHR(13) + cErrorArray(2))
ENDIF

Basically I wanted to show the original contents, then add a record and finally update the table.

BUT, the form tells me success and oracle shows no new record. What am I doing wrong?

Jason


>>Hi Mark, I tried the CABuilder class and it is pretty slick. One problem though, when I try inserting a record (ie insert into genkey (fieldid, lastused) values ('test','1234')) I get an error saying that It is trying to insert null into fieldid. I looked into the CA built by your builder and the fieldid which is the pk is not in the insert or update command. Did I miss something or is there a reason for this?
>
>By default, my builder does NOT include PK fields for inserts and updates. I handle the population of PK fields either with a BeforeInsertUpdate trigger [in Oracle] or in the case of a VFP table, throught the use of the Default value for that PK field. The Default is actually a function call to a stored procedure in the DBC that checks a Kounters table to get the next (integer) ID for that table. I will probably make this a builder option in my next version.
>
>>If I am building a cursor adapter myself do I have to specify the insert, delete and update commands?
>
>No, you can let VFP do this for you as long as properties like Tables, UpdatableFieldList, UpdateNameList and KeyFieldList are properly filled in. The ConversionFunc property is also useful for RTRIMming character fields when the source DB column is a varchar data type. Fortunately, in VFP9 we now have native varchar data types and varchar mapping to remote DB columns. The SendUpdates, AllowInsert, AllowUpdate and AllowDelete properties also need to be .T.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform