[:main] ; this section specifies the global settings server=servername ; leave blank for local ; This option is used to connect to the database to fetch the data about stored procedures username=something password=... ; username and password to connect to the database to fetch the data about stored procedures ; if you define the "connectionstring" option this username/password will NOT appear in the generated ; file. database=JOBVIPER ; in which database are the stored procedures DSN=jobodbc ; the data service name, ignored if you specify the connectionstring, by default the same as [:main]database connectionstring=DSN=...;UID=...;PWD=...; ; the connection string for the generated VB class ; if you do not specify this if will be created from [:main]DSN, [:main]username and [:main]password classname=SP ; the name of the generated VB class. Should be the same as the name of the outputfile projectname=ViperDB ; name of the VB project. Projectname.Classname will become the object ID (Server.CreateObject("Projectname.Classname")) outputfile=w:\Viper\VBSourceCode\ViperDB\SP.cls ; the output file should be full path. It will be relative to current directory. functionfile=w:\Viper\VBSourceCode\ViperDB\Functions.bas ; or functionfile=$Bin\Functions.bas ; this option specifies the file that implements ExecuteCommand__, ; OpenRecordset__ , ErrorHandler__ and GetSessionVar__ functions. ; See the documentation and attached files FunctionsXXX.bas ; for examples. Your functions have to accept the same parameters ; as the ones in those examples and must return Empty on success ; and something else on failure. ; You may define other functions in that file as well, but be careful ; not to use the same name as a stored procedure. ; I end the functions with two underscores since that is unlikely to ; appear in stored procedures. ; ; The $Bin will be replaced by the path to SP_COM_generator.exe helpfile=w:\viper\web\ViperDB.html ; where to write the class documentation - list of methods with parameters, SQL definition of procedures, etc. ; if you do not specify this parameter no docs will be generated ; the following parameter is a little (well not so little) tricky ; It's actually Perl code that will be evaluated for the procedure definition ; and will extract the embedded documentation (if any). ; You will find the text of the stored procedure in $_ and I expect to get the generated docs again in $_. ; I will test the return value of the last command and if you return a false value ; I will include the definition of the stored procedure ; ; Since I'm sure most of you are not that great when it comes to regular expressions I provide a few examples. ; If you use a different syntax, let me know, send me an example and I'll write the regexp(s) for you. useforhelp=<<*END* s/^.*?--\*{5,}(.*?)--\*{5,}.*/$1/s and s/^--\s*//mg and s{^(.*?)\s*:\s*(.*)$}{$1$2}mg and $_="$_
" *END* ; this one extracts documentation in format : ; --**************************************************************************** ; -- Procedure Name : DeleteCountryMasterDetails ; -- Purpose : To delete a record from the [country] table. ; -- Input Params : CountryID ; -- Modified History : By : ; --**************************************************************************** ; ; If the stored procedure did not have docs in this format you will get the definition: ; ; CREATE PROCEDURE DeleteCountryMasterDetails(@CountryId int) ; AS ; begin ; DELETE FROM Country WHERE CountryID = @CountryId ; end useforhelp=<<*END* if (s{^.*?/\*\s*docs\b(.*?)\*/.*$}{$1}s) { s/^\s*//s; s/\s*$//s; s/\n/
\n/sg; 1; # this returns the true value. just in case there is only one line } *END* ; this one takes documentation in form : ; /* docs ; Blah blah blaaah. Bla Blahhh bla bla. ; Bla bla bla bla blaaaaa. ; */ useforhelp=<<*END* if (s{^.*?/\*\s*docs\b(.*?)\*/.*$}{$1}s) { s/^\s*//s; s/\s*$//s; s/\n/
\n/sg; 1; # this returns the true value. just in case there is only one line } elsif (s/^.*?--\*{5,}(.*?)--\*{5,}.*/$1/s) { s/^--\s*//mg; s{^(.*?)\s*:\s*(.*)$}{$1$2}mg; $_="$_
"; } *END* ; And this one takes either of the formats above. useforhelp=<<*END* if (s{^.*?/\*\s*docs\b(.*?)\*/.*$}{$1}s) { s/^\s*//s; s/\s*$//s; s/\n/
\n/sg; 1; # this returns the true value. just in case there is only one line } else { s{/\*.*?\*/}{}gs; s/^(.*?)--\*{5,}.*?--\*{5,}/$1/s; s/^\s*$//gm; s/go\s*$//is; s/[\s\n]*$//s; $_ = "
$_
"; } *END* ; This one is what I use actually. ; It takes documentation in form /* docs ... */ ; and if it's not there it returns the code of the stored procedure ; stripping out documentation in form ; --********** ; -- Bla : foo ; --********** ; if there is any. ; (The reason is that I've inherited the database and it's full of totally misleading docs.) [:default] ; this section sets the default options for all stored procedures. ; it may contain any options defined for a stored procedure [:sp_groups] ; this section specifies the groups of stored procedures with the same options ; say if all procedures whose name start with Fetch or Get should return a recordset ; you specify withrecordset=^(Fetch|Get) ; the value is an ordinary Perl regexp and it's case insensitive! ; The regular expressions should be mutually exclusive. ; The order in which they will be tested is undetermined !!! sourcesafe=^dt_ update=^Update insert=^Insert ; Of course you may overwrite the options specified for a group ; by options you specify for a single procedure. [:withrecordset] recordset=1 [:sourcesafe] skip=1 [:update] return_value=RowCount:last [:insert] return_value=ID [spName] ; this defines options for a stored procedure ; this takes precedence over the SP groups and [:default]. ; If a [:section] or [:default] specifies : ; recordset=1 ; and you do NOT want to return a recordset from this procedure ; you have to include : ; recordset=0 ; Same with other options. optional=paramname,paramname,... ; the parameters that are optional (have a default value in the SP's definition) ; The optional setting has a meaning ONLY IF recordset is not set ; and you don't use return_value=Something:last recordset=1 ; Do you want to get the recordset back? ; It will be the last parameter. ; (unless you use return_value=Something:last in which case it will come before the return value). skip=1 ; Skip this procedure return_value=VariableName ; Are you interested in the procedure return value? ; the ByRef varVariableName will be the first parameter to the method ; or return_value=VariableName:last ; the ByRef varVariableName will be the last parameter to the method ; takes precedence even over the recordset=1 ; If you return both recordset and :last return_value then you'll have ; first the SP parameters, then the recordset and last the return_value test_varname=Type:Error message ; or test_varname=Type:Error number:Error message ; This adds type checking before filling in the ADODB.Command ; types : Numeric, Int, Natural, ID, Nonempty, Date ; type names are case insensitive ; If the parameter doesn't exist within a procedure then this setting is ignored ; so you may safely set this in an sp_group or [:default] ; ; You may create your own tests. See below. trimchars=1 ; turns on char() and varchar() trimming. This means that all input and output char and varchar ; parameters will be trim()ed. This of course DOES NOT trim() recordset fields! ;trimchars=0 ; turns off char() and varchar() trimming ;trimchars=varname,varname,... ; turns on char() and varchar() trimming ONLY FOR these variables from_session=userid:userid,usertype:usertype ; comma separated list of "@parameterName:sessionVarName" ; if the stored procedure requires @parameterName the parameterName will be the last ; parameter of the method and will be optional. If you do not specify it, the value of ; Session("sessionVarName") will be used instead. [:checks] Tinyint=<<*END* Private Sub Check__Tinyint(ByVal value As Variant, ByVal num As Long, ByVal msg As String) If Not IsNumeric(value) Then Err.Raise num, , msg If value < 0 Or value > 255 Then Err.Raise num, , msg End Sub *END* ; Here you define custom parameter checking procedures ; The procedure name MUST start with Check__ !!! ; And the name of the ; The procedure should have three parameters, first will be the value to check ; second is the error number to report and third the error message ; The error number and message come from the INI file : ; test_blanklines=Tinyint:50001:"Blank lines after field" must be a positive number smaller than 255. ; ; the type names are case insensitive [:custom] begin=<<*END* ' here comes custom code to add on top *END* end=<<*END* ' here comes custom code to add on bottom *END* ; here you may have any VB code you want to include in the class ; private functions and subs may be used only within the object ; public ones will become methods of the COM object.