| |
|
|
rquindt | Hello
i want in a SQL data base with whom übergebenen Datensätzen automatically a customers-Nr give away let. the functions so far too by Generator:
Db("fbSQLExec", hdb&, "CREATE TABLE ADRESSEN \ ( KDNR Integer generated by Default as identity (start With 0) primary key hardship NULL,\ NAME CHAR(30),\ FIRST NAME CHAR(30))",1)
If I now a Datensatz einfüge, would like I gladly these customers-Nr back transfer having, so I tappt im dunkeln in a further step benefit can. the should loudly internet by "RETURNING" functions
db("fbSQLExec",hdb&,"INSERT INTO ADRESSEN (NAME,FIRST NAME) \ VALUES ('Mustermann','Max')" + " RETURNING KDNR",1)
only I get the Result not a variable. to the whole have I a DELPHI-code found, get whom but not XPROFAN adjusted:
with DBank.IBC_Anschrift do begin Close; SQL.Clear; SQL.Add('INSERT INTO address (AUFTRAG, Name_1, Name_2)'); SQL.Add('VALUES (''87777'', ''Schulze'', ''Nummer 2'')'); SQL.Add('RETURNING ID');
ExecSQL; NewID:= DBank.IBC_Anschrift.ParamByName('RET_ID').Value;
ShowMessage(IntToStr(NewID); end;
can me there someone help? Vielen Thanks in the advance. |
|
|
| |
|
|
|
H.Brill | i think time, you mußt too a variable indicate, on The the SQL-commands whom generierten Content the first slot KDNR there triggert.
Declariere time a variable worth% and try it so :
db("fbSQLExec",hdb&,"INSERT INTO ADRESSEN (NAME,FIRST NAME) \
VALUES ('Mustermann','Max')" + " RETURNING KDNR INTO :worth%",1)
Stichpunkt : eingebettete variables with colon.
In worth% should then the Content stand. too Perhaps time a String (worth$) try.
so have I the time Internet red. wants me but now not because of this a thing a extra DB building.
try it hold simply time |
|
|
| Benutze XPROFAN X3 + FREEPROFAN Wir sind die XProfaner. Sie werden von uns assimiliert. Widerstand ist zwecklos! Wir werden alle ihre Funktionen und Algorithmen den unseren hinzufügen.
Was die Borg können, können wir schon lange. | 04/03/18 ▲ |
|
|
|
|
Michael W. | of my Wissens give The db(SQLEXEC/fbSQLExec/slSQLExec only The Number of processed Datensätze back.
on the FireBird-Page missing with RETURNING The ESQL-Kennung. means there in the eingebetteten Version "fbembedded" the RETURNING neither. see: [...] and: [...]
means a function building, The The address aufnimmt and the Kundennummer back gives.
Proc neue_Adresse
Parameters pName$, pVorname$
Declare hGrid&
hGrid& = Create("Grid",3,0)
db("fbSQLExec", hdb&, "INSERT INTO ADRESSEN ( name,First name ) VALUES ( :pName$, :pVorname$ )", 1)
db("fbSQLExec", hdb&, "SELECT KdNr,name,First name FROM ADRESSEN WHERE (name = ':pName$') AND (First name = ':pVorname$')", hGrid&)
' The values can then any controlled werden; needed becomes only the first
' in the Grid disembark no Überschriften, The Base is means row 0 and column 0
Return Val( GetText$(hGrid&, 0,0) )
ENDPROC
KdNr& = neue_Adresse( "Mustermann", "Max" )
the means of course two SQL-command on The data base loszulassen, but therefore can The values too same to check on.
One Another benefit the function: usually need one for Kundennummern defined Nummernkreise and reaches, The for nötige edit can there with take in.
the can itself then for product-, Rechnungs- and others numbers abschauen and so kapseln. |
|
|
| System: Windows 8/10, XProfan X4 Programmieren, das spannendste Detektivspiel der Welt. | 04/04/18 ▲ |
|
|
|
|
rquindt | thanks for hints. there it often time same names and Vornamen or other Kombinationen gives, have the whole time with nem Generator rebuilt.
Db("fbSQLExec",hdb&,"CREATE GENERATOR KDNR",1) '----- Generator for data-set Nr becomes created ------- Db("fbSQLExec",hdb&,"SET GENERATOR KDNR TO 0",1) '----- KDNR = data-set-Nr, worth launch with 0 ------
KdNr& = Datei_SatzNr( hdb& ) ' next SatzNr detect
db("fbSQLExec",hdb&,"INSERT INTO ADRESSEN (KDNR,NAME,FIRST NAME) \ VALUES (:KdNr&,'Mustermann','Max')",1)
End
'-------------------------------------------------------------------------------- Proc Datei_SatzNr
Parameters hdb1& Declare hGrid&
hGrid& = Create("Grid",3,0)
Db("fbSQLExec",hdb1&,"select gen_id(KDNR,1) from RDB$DATABASE",hGrid&)
Return Val( GetText$(hGrid&, 0,0) )
' in the Grid disembark no Überschriften, The Base is means row 0 and column 0
ENDPROC |
|
|
| |
|
|
|
Michael W. | Yes, not integrally.
hGrid& = Create("Grid",3,0)' <-- created one Grid with 3 Split
' here becomes of SELECT but only 1 worth generiert... (in the example were it KdNr,name,First name)
Db("fbSQLExec",hdb1&,"select gen_id(KDNR,1) from RDB$DATABASE",hGrid&)
Return Val( GetText$(hGrid&, 0,0) )
Also becomes into most SELECT The entire data base go through, unless one border The Search with of/ one WHERE-Klausel one. the gen_id() could but such a Begrenzung on a row imply. |
|
|
| |
|
|