Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
salut tout le monde, j'ai une DW avec sqlselect= "select T1.X, T2.Y from T1, T2 where T1.Code_T2=T2.code" . j'ai activé l'option UPDATE et tout se passe a merveille( la saisie, la sauvgarde ...), MAIS le probleme ce que lorsque je modife cette SQLSELECT avec setSqlselect a l'aide d'un script en ajoutant une clause WHERE et ORDER BY ,la DW ne sauvegarde pas les donnees. et retourne le fameux message d'erreur "DW does not have UPDATE capability !!!!) . Aidez moi SVP
Dernière modification par blali (16-06-2008 15:00:34)
Hors ligne
F1 a écrit:
Use SetSQLSelect to dynamically change the SQL SELECT statement for a DataWindow object in a script.
If the DataWindow is updatable, PowerBuilder validates the SELECT statement against the database and DataWindow column specifications when you call the SetSQLSelect function. Each column in the SQL SELECT statement must match the column type in the DataWindow object. The statement is validated only if the DataWindow object is updatable.
You must use the SetTrans or SetTransObject function to set the transaction object before the SetSQLSelect function will execute.
If the new SELECT statement has a different table name in the FROM clause and the DataWindow object is updatable, then PowerBuilder must change the update information for the DataWindow object. PowerBuilder assumes the key columns are in the same positions as in the original definition. The following conditions will make the DataWindow not updatable:
¨ There is more than one table in the FROM clause.
¨ A DataWindow update column is a computed column in the SELECT statement.
If changing the SELECT statement makes the DataWindow object not updatable, the DataWindow control cannot execute an Update function call for the DataWindow object in the future.
Limitations to using SetSQLSelect Use SetSQLSelect only if the data source for the DataWindow object is a SQL SELECT statement without retrieval arguments and you want PowerBuilder to modify the update information for the DataWindow object:
dw_1.Modify("DataWindow.Table.Select='select...'")
Modify will not verify the SELECT statement or change the update information, making it faster but more susceptible to user error. Although you can use Modify when arguments are involved, it is not recommended because of the lack of checking.
Donc, il faut que tu vérifies que ton nouveau SELECT n'entre pas en violation avec les limitations listées ci-dessus.
En l'occurence, ton problème semble venir de la présence de plusieurs tables dans la clause "FROM"
Hors ligne
apres un setsqlselect, il te faut remettre en dur les update properties de ta DW ;)
Hors ligne
Repondant a :
*** F1 : Je touche en rien le contenu de la clause SELECT et FROM simplement j'ajoute la clause WHERE et ORDER BY !!!
*** SEBOU: Comment remettre en dur les update properties de ma DW ??
Merci les amis
Hors ligne
Bonjour,
Avant l'appel de l'update(), essaye de remettre en place (dans le code) les update properties:
dw.modify("nom_colonne.Update = Yes") // pour toutes les colonnes qui doivent être actualisées (No, au contraire dw.modify("nom_colonne.Key = Yes") // pour specifier si la colonne fait partie de la clé (No, au contraire) dw.modify("DataWindow.Table.UpdateTable = ~"T1~"") // le nom de la table à mettre à jour dw.modify("DataWindow.Table.UpdateWhere = 0") dw.modify("DataWindow.Table.UpdateKeyInPlace = No")
Les valeurs initiales de ces propriétés, avant la modification avec SQLSelect, sont visibles en faisant un export de la datawindow (ouvrir le fichier résultat avec un éditeur quelconque)
Hors ligne
blali a écrit:
Repondant a :
*** F1 : Je touche en rien le contenu de la clause SELECT et FROM simplement j'ajoute la clause WHERE et ORDER BY !!!
Merci les amis
Exact, mais le setSQLSelect a annulé les UPDATE properties de ta datawindow. Dès lors, PB essaye de les "ré-activer" dynamiquement
à partir du nouveau SELECT. Or, dans les UPDATE properties, il faut toujours que tu précises quelle table tu souhaites mettre à jour.
Comme il y a deux tables dans ton SELECT, PB est incapable de choisir. Il faut donc que tu le lui précises comme te l'a indiqué SEBOU.
Pour info, regarde ce que te dit l'aide PB (F1 ) sur:
<DW Control Name>.Modify("DataWindow.Table.UpdateKeyinPlace=<Yes or No>") <DW Control Name>.Modify("DataWindow.Table.UpdateTable='<string containing updateable table name>'") <DW Control Name>.Modify("DataWindow.Table.UpdateWhere='<0 - Key Columns, 1 - Key and Updateable Columns, 2 - Key and Modified Columns>' ")
[EDIT] Grillé par anfr2005
Hors ligne
Merci mille fois mes amis de votre soutient, ma DW tourne bien maintenant,
Alors A+
Hors ligne
Wahouuuuuuu, pour une fois j'ai su répondre à une question
J'deviens un bon hein !! lol
(bon j'avoue faut dire que j'ai eu le probleme vendredi après midi lol)
Hors ligne