Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Pages: 1
Bonjour,
Voici un code permettant de faire exécuter une série de fichiers .sql depuis une application web :
#IF DEFINED PBWEBFORM THEN UploadFiles("c:\", 15780518, 1, true,"Chargez dans l'ordre les fichiers SQL à exécuter", ".sql", "wf_callback", w_execut_sql) #END IF
Et la fonction wf_callback associée :
Integer wf_callback(string as_array[])
// BW128 Integer li_return integer li_fnum long ll_bytes string ls_filename string ls_docpath int li_position int li_stringlength int li_rightchar string ls_sql mle_sql.Text = "" for li_return = 1 to upperbound(as_array) ls_docpath = as_array[li_return] ls_filename = ls_docpath // take just the ls_filename portion of the this string by search right to left for the '\' symbol li_position = LastPos (ls_filename , '\') li_stringlength = len(ls_filename ) li_rightchar = li_stringlength - li_position ls_filename = right( ls_filename , li_rightchar ) li_fnum = FileOpen(ls_docpath, StreamMode!) ll_bytes = FileRead(li_fnum, ls_sql) FileClose(li_fnum) if ll_bytes > 0 then Execute immediate :ls_sql; if sqlca.sqlcode > -1 then commit; mle_sql.Text = mle_sql.Text + ls_docpath + "~t~tOK~r~n" else rollback; mle_sql.Text = mle_sql.Text + ls_docpath + "~t~tKO" MessageBox("ERREUR SQL","SQLCA.SQLCODE = " + string(sqlca.sqlcode) + "~r~n" + sqlca.sqlerrtext) li_return = upperbound(as_array) + 1 // sortie de boucle end if else mle_sql.Text = mle_sql.Text + ls_docpath + "~t~tKO" MessageBox("ERREUR","Erreur de lecture du fichier " + ls_docpath) li_return = upperbound(as_array) + 1 // sortie de boucle end if Next Return li_return
Hors ligne
Hors ligne
000 pépites
Hors ligne
000 pépites
Hors ligne
Pages: 1