`
Templates: Template snippets to derrive FileManger to add NULL values where needed 2004-04-01 -- Bjarne Havnen Newsgroups: sv.clarion.drivers > Any chance we can see a snippet of your derived FM that handles this? No problem. It doesn't look very pretty now, been some adjustements and more to come. I will kill the Select Max() type of autoinc. What I do to get this work is to let AutoInc be checked on the key to generate the call The first field in the recordstructure must be the Seed field I never call PrimeAutoInc directly, since I depend on some fields to be NULL, I call primerecord. I add the below template on the files that need it, that is the files where I need to immedialtely know the ID. I will also have to handle the cancelautoinc and set some flags for autoinc done #Extension(AdiEnableSeed,'Enable SEED'),Application,Multi,Description('Seed for '& %AdiFile) #Display('This template requires the AdiSQLFM class') #Prompt('File',File),%AdiFile #Prompt('Max value',Check),%MaxIt #At(%FileManagerCodeSection,%AdiFile,'Init','(File File,ErrorClass EC)') !Self.SqlAutoInc = True #If(Not %MaxIt) Self.SqlAutoInc =1 #Else Self.SqlAutoInc=2 #End #EndAT This is the template I use to set null on some fields. All fields that should be primed with a default value from other file is checked and I can also add some other fields if I like. Note that I change the SuppressClear parameter to avoid NULL being set to 0. #Extension(AdiSetNULL,'SETNULL() on all empty fields before insert'),Application,Multi,Description('SETNULL '& %ADiFile) #Prompt('Select File',File),%AdiFile #Display('Field that have initial value will always be checked') #Button('Select fields to null'),Multi(%AdiFields,%Adifield),Inline #Prompt('Select Field',Field(%Adifile)),%AdiField #EndButton #At(%FileManagerCodeSection,%AdiFile,'PrimeRecord','(Byte SuppressClear = 0),BYTE'),Priority(2500) #Declare(%MyF) #Fix(%File,%AdiFile) If Not SuppressClear # Printed November 21, 2024, 7:00 am This article has been viewed/printed 35200 times. Google search has resulted in 28 hits on this article since January 25, 2004. |