Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Fonksiyona boş değer atama Hatası
#1
Arkadaşlar Sa...

Kullanıcı tarafından yazılan kelimeye göre Veri tabanında silme işlemi yapıyorumm..
 STOK_ISMI alanında  Silinmesi istenilen"kelimeyi"  bulup; ilgili kayıtları silebiliyorumm..

aktif Listbox ta Bulunan  STOK GRUP larına göre (Listede gezinirken stok grubu aktif oluyor) bulunan kayıtlarda geçen kelimeyi silmek istedıgımde (Checkbox işaretlenmiş oluyor)
KelimeyeGoreSil fonksiyonu problemsiz çalışıyor.
parametreler dolmuş oluyor...

Checkbox ı işaretlemeyip devam edince GRUP_KODU boş değer aldiğı için hata alıyorum...

BU Hatayı nasıl çözebilirim..Firebird Stored procedure de hata alıyorum


Function TDm1.KelimeyeGoreSil(GrKod:String;Kelime:String):Integer;
   var
    KaySay:Integer;
     Begin
        SpKelimeSil.ParamByName('GR_KOD').AsString := GrKod;
        SpKelimeSil.ParamByName('KELIME').AsString := Kelime;
        SpKelimeSil.ExecProc ;
        KaySay:= SpKelimeSil.ParamByName('KAY_SAY').AsInteger ;
        Result :=KaySay;
     End;




procedure TFUrunBilgileri.Button3Click(Sender: TObject);
var
i:Integer ;
Pval:Word;
Kelime1,Kelime2:String;
GrKod1: String;
begin

   Kelime1 :=  UPPERcase(EditKopya.text) ;
   Kelime2 :=  ' Kelimesi içeren tüm kayıtları Silmek İstediğinizden Eminmisiniz?';

      pVal:= MessageDlg(Kelime1+Kelime2,mtconfirmation,[mbyes,mbno,mbCancel],0) ;

     if CbAktGrGoreSil.Checked then  
       Begin
        GrKod1 := QStokGr.FieldByName('GRUP_KODU').AsString ;

         Case  Pval of
                mrYes:
                       Begin
                          i:= Dm1.KelimeyeGoreSil (GrKod1,Kelime1) ;
                          ShowMessage(Inttostr(i)+ ' Kayıt silindi');
                          QStokBilgi.Close ;
                          QStokBilgi.Open ;

                       end;
                MrNo:
                      Begin
                       QStokBilgi.Cancel ;
                      end;

           end ;

      
       end Else

             Case  Pval of
                mrYes:
                       Begin
                         // Burda grup kodu nu almıyorum çünkü Tüm tablodaki verileri siliyor
                          i:= Dm1.KelimeyeGoreSil (GrKod1,Kelime1) ;
                          ShowMessage(Inttostr(i)+ ' Kayıt silindi');

                               QStokBilgi.Close ;
                               QStokBilgi.Open ;

                       end;
                MrNo:
                      Begin
                       QStokBilgi.Cancel ;
                      end;

            end;

end;

*************************************************************

Firebird deki stored procedure de aşağıdakı gibi :

SET TERM ^^ ;
CREATE  PROCEDURE KELIMEYE_GORE_KAYITSIL (
  GR_KOD VarChar(2), 
  KELIME VarChar(10))
 returns (
  KAY_SAY Integer)
AS
BEGIN
 
 
   SELECT COUNT(*) AS KAY_SAY1 FROM STOK_BILGILERI
      WHERE  
           GRUP_KODU = :GR_KOD
           AND
           STOK_ADI CONTAINING :KELIME 
           
       INTO:KAY_SAY;  

    
    DELETE FROM STOK_BILGILERI
      WHERE  
       GRUP_KODU = :GR_KOD
           AND
       STOK_ADI CONTAINING :KELIME;        
    
       
END ^^
SET TERM ; ^^


Ek Dosyalar Resimler
   
Cevapla
#2
Hobi olarak öğrenmek istiyorsanız aldığınız hatayı yazmanız forum üyeleri için yardımcı olur. yok işim görülsün diyorsanız aynı şekilde bunu mesela claude a sorun. yardımcı olur.
Cevapla
#3
Thumbs Up 
For more code and videos: Coding in Delphi ( VCL/FMX/Android/Firebird/Ubuntu ) subscribe my channel:
http://www.youtube.com/emailx45    Angel   click likes and subscribe me!

CONTAINING:
a) no case-sensitive
b) no use B-Three common indexes
c) BLOB field is accepted
d) if big-table, we have a problem here = low performance! Else, it's good!
e) alternative: use third component "Full-Text Search", or UDF/External Engines extentions
--------------------------------------------
SELECT <<YOUR FIELDS HERE  ex. ID, FieldXX, FieldYY, etc... >>
FROM MyTABLENameXXXX
WHERE MyTextStringsFIELD CONTAINING :MyParamText;   // <---- always use "PARAMS" not text plain
//... other directives here if want!  like "ORDER BY" etc...
//... if necessary, use "UNION", "JOIN", etc.. etc.. etc..
// ... using "COUNT(*)" = low performance if table is big or if UNION or JOIN is used
// ... if necessary, use "CET" = Common Expression Table 


SQL_RUN := 'SELECT xxxxxxFIELDSxxxxxxx  FROM xxxxxTABLExxxxx WHERE xxxxxxCLAUSExxxxxxx';
QueryFIREBIRD.SQL.Text := SQL_RUN;
QueryFIREBIRD.EXECProc;
//
// Now catch the result and test if "null" or not and use it!

--------------------------------------------

Alternative way to full performance: FULL SPEED!
1) create a new column with text indexes
2) find your text using this new column 
3) you can create a new VIEW-table read-only for this task! No concorrences, Full Speed!

---------------------------------------------
Summary:
1) depend of your table in use, exists many options to do "this"!
2) you can use "stored procedures" as before
3) you can use "select" in this new-VIEW as any other table
4) if fact, you can create your table on-demand if you tasks is not used all time! you can deactivate it when not necessary!
5) etc.. etc... etc.. exists many options for this!

----------------------------------------------
if you want avoid use "IF" or "Case" you can use Table-Driven Pattern ( Dispatch Table Pattern )



... 
// this can be defined in you a "public" place, like a unit specific for this like   uMyDispatchTables.pas
type
  TMyTableDispatchEnum = ( mtdNo, mtdYes ); // just 2 values: 0 = false;  1=true
   //
   // to "procedure of objects" use this:  "array [ TMyTableDispatchEnum ] of procedure of object;" 
  TMyTableDispatch     = array [ TMyTableDispatchEnum ] of procedure; // of procedure(... with params );

var
  LMyTableDispatch: TMyTableDispatch;

procedure procNO; // procNo( with params ... )
begin
  // to do when answer is "NO"
end;

procedure procYES; // procYES( with params ... )
begin
  // to do when answer is "YES"
end;

// procedure OnCreate or any other place in code...
procedure InitializeMyTableDispatch;
begin
  LMyTableDispatch[ mtdNo ]  := procNO;  // you can use any "procedure" defined in any other unit - just warning about scope!!!
  LMyTableDispatch[ mtdYes ] := procYES;
end;

// procedure OnDestroy or any other place in code...
procedure FinalizeMyTableDispatch;
begin
  LMyTableDispatch[ mtdNo ]  := nil;
  LMyTableDispatch[ mtdYes ] := nil;
end;

procedure TFormPrincipal.Button3Click( Sender: TObject );
var
  LMessageDLGAnswer: TMyTableDispatchEnum;
begin
  // your MessageDLG result should be "ONLY":  0 or 1 !!! if any other you need create more "ENUMS" in TMyTableDispatchEnum( .... .... .... )
  LMessageDLGAnswer := TMyTableDispatchEnum( ( CheckBox1.Checked ) ); // True = 1 and False = 0
  //
  LMyTableDispatch[ LMessageDLGAnswer ]; // LMyTableDispatch[ LMessageDLGAnswer ]( your params...);
  //
  // your code continue here...
end;

initialization // or "form.ONCREATE" etc... or any other place public if using in many places!

InitializeMyTableDispatch;

finalization  // or "form.ONDESTROY" etc... or any other place public if using in many places!

FinalizeMyTableDispatch;

end.
  
MSWindows, Android, RAD Studio 13 Florence ve kafamda bir fikir  Tongue  
WWW
Cevapla
#4
Çözümünü buldum. Kolay Gelsin...


SET TERM ^^ ;
CREATE /* OR ALTER */ PROCEDURE KELIMEYE_GORE_KAYITSIL_3 (
GR_KOD VarChar(2),
KELIME VarChar(10))
returns (
KAY_SAY Integer)
AS
BEGIN

IF (:GR_KOD <> '') THEN

BEGIN
SELECT COUNT(*) AS KAY_SAY1 FROM STOK_BILGILERI
WHERE
GRUP_KODU = :GR_KOD
AND
STOK_ADI CONTAINING :KELIME

INTO:KAY_SAY;


DELETE FROM STOK_BILGILERI
WHERE
GRUP_KODU = :GR_KOD
AND
STOK_ADI CONTAINING :KELIME;

END ELSE


BEGIN
SELECT COUNT(*) AS KAY_SAY1 FROM STOK_BILGILERI
WHERE

STOK_ADI CONTAINING :KELIME

INTO:KAY_SAY;


DELETE FROM STOK_BILGILERI
WHERE

STOK_ADI CONTAINING :KELIME;

END

END ^^
SET TERM ; ^^
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Runtime error 236 hatası yhackup 6 1.307 29-07-2026, Saat: 00:10
Son Yorum: emailx45
  matematiksel karşılaştırma hatası nevzatc 7 1.530 14-04-2026, Saat: 06:36
Son Yorum: emailx45
  Delphi ile SQL server bağlantı hatası yakalama Under 20 4.379 21-11-2025, Saat: 15:24
Son Yorum: mrmarman
  OpenSSL Hatası mcuyan 1 922 29-04-2025, Saat: 02:28
Son Yorum: mcuyan
Photo Delphi 12.2ilginç bir ide hatası tuna 13 5.023 25-03-2025, Saat: 09:47
Son Yorum: tuna



Konuyu Okuyanlar: 1 Ziyaretçi