I am a newcomer to KIX ~6 months. I have been viewing this BBS for about four months and have found your examples to be very helpful. I would appreciate any suggestions you have to improve the following.
Thanks
Stanley

CODE

;FUNCTION WRITEDB
;
;ACTION This function will use a stored procedure to write to a database
;
;AUTHOR Stanley
;
;CONTRIBUTORS Philbert, TKO
;
;VERSION 1
;
;DATE CREATED 20040603 YYYYMMDD
;
;DATE MODIFIED 20040608
;
;KIXTART 4.22
;
;SYNTAX WRITEDB( <job_name> , <status> , <descrip> )
;
;PARAMETERS job_name
; Name of parent script
;
; status
; Job started = GREEN, completed successfully = GRAY, errored = RED
;
; PARAMETER3
; Text field used to send @SERROR or Completed
;
;RETURNS nothing
;
;REMARKS Additional remarks about the UDF

;

FUNCTION WRITEDB($job_name,$status,$descrip)

; Path to UDL
$ConnDSN = "file name=<PATH TO UDL>"

; Create an object of type: ADODB class: Connection
$objConn = CreateObject("ADODB.Connection")

; Pass UDL path to connectionstring method of Object
; created in previous step
$objConn.connectionstring = $ConnDSN

; Open database ADODB object
$objConn.Open()

; Create an object of type: ADODB class: Command
$oCmd = CreateObject("ADODB.Command")

; Assign DB connection to Command
$oCmd.ActiveConnection = $objConn

; Set Command text
$oCmd.CommandText = "<SCHEMA.PROCEDURE_NAME>"

; Set Command Type
$oCmd.CommandType = 4

; Create parameter and set properties to be passed to Stored Procedure
$oParam1 = $oCmd.CreateParameter("job_name_val")
$oParam1.type = 200
$oParam1.direction = 1
$oParam1.size = 255
$oParam1.value = $job_name
$oCmd.Parameters.Append($oParam1);Append parameter list

; Create parameter and set properties to be passed to Stored Procedure
$oParam2 = $oCmd.CreateParameter("description_val")
$oParam2.type = 200
$oParam2.direction = 1
$oParam2.size = 4000
$oParam2.value = $descrip
$oCmd.Parameters.Append($oParam2);Append parameter list

; Create parameter and set properties to be passed to Stored Procedure
$oParam3 = $oCmd.CreateParameter("status_val")
$oParam3.type = 200
$oParam3.direction = 1
$oParam3.size = 50
$oParam3.value = $status
$oCmd.Parameters.Append($oParam3);Append parameter list

; Execute Command
$cmdx = $oCmd.Execute

; Set parameters = to NULL
$oParam1 = ""

$oParam2 = ""

$oParam3 = ""

; Set Command = to NULL
$oCmd = ""

; Close DB object
$objConn.close()

ENDFUNCTION

CODE

_________________________
Taxation WITH representation isn't so hot, either!