From: dave.snyder@snide.com (Dave Snyder)
Newsgroups: comp.databases.informix
Subject: Re: User defined functions in ACE
Date: 29 Sep 92 00:03:18 GMT
Reply-To: dave.snyder@snide.com (Dave Snyder)
X-Informix-List-ID: <list.1490>

Quoting Stuart Hemming...
} 
} Now what I would like to do is call this function from inside ACE.
} I've had a look through the SQL manuals and can find nothing on this
} subject. However, one of the include files
} ${INFORMIXDIR}/incl/ctools.h implies that this can be done.
} 
} I guess that I somehow have to re-compile sacego like I have to
} re-compile fglgo for 4gl programs.
} 
} Can anyone tell me how this is done?
} 
Although I haven't done this with ACE, I have done this with perform.  The
procedure is the same for ACE execpt that you use:
  cace -O source.ec -o newsacego
instead of:
  cperf -O source.ec -o newsperform

Below is some code that I wrote about 3 years ago.  The first function actually
reads fields from a perform screen, the second function uses passed values.
Although this is for compiling a new sperform, the second function could be
used in an new sacego.  I hope this answers your questions.

PS:  I know that I should be checking the return values of the UPDATES and
INSERTS, but like I said... this was written 3 years ago and I didn't know
any better back then.

Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip
/* ident = "@(#)dperform.ec	1.1" */


#include "ctools.h"

valueptr	upd_pmprop();
valueptr	upd_pmtran();

struct ufunc userfuncs[] = 
{
	"upd_pmprop", upd_pmprop,
	"upd_pmtran", upd_pmtran,
	0, 0
};


/*******************************************************************************
* AFTER ADD OF pm_tran CALL upd_pmprop()                                       *
*******************************************************************************/
valueptr upd_pmprop()
{
	$long	pmtran_propnum;
	$long	pmtran_date;
	char	pmtran_code[2];

	pf_getval("f000", &pmtran_propnum, CLONGTYPE, 4);
	pf_getval("b", pmtran_code, CCHARTYPE, 2);
	pf_getval("f022", &pmtran_date, CLONGTYPE, 4);

	switch (pmtran_code[0]) {
	case 'B':
		$update pm_prop set billed = $pmtran_date
		   where propnum = $pmtran_propnum;
		break;
	case 'C':
		$update pm_prop set cleaned = $pmtran_date
		   where propnum = $pmtran_propnum;
		break;
	case 'I':
		$update pm_prop set inspected = $pmtran_date
		   where propnum = $pmtran_propnum;
		break;
	case 'W':
		$update pm_prop set wintered = $pmtran_date
		   where propnum = $pmtran_propnum;
		break;
	case 'X':
		$update pm_prop set boarded = $pmtran_date
		   where propnum = $pmtran_propnum;
		break;
	}
}


/*******************************************************************************
* AFTER ADD OF pm_prop CALL upd_pmtran()                                       *
*******************************************************************************/
valueptr upd_pmtran(arg1, arg2, arg3)
valueptr arg1, arg2, arg3;
{
	$char	pmprop_inspector[4];
	$long	pmprop_propnum;
	$long	pmprop_date;

	pmprop_propnum = arg1->v_long;
	pmprop_date = arg2->v_long;
	strcpy(pmprop_inspector, arg3->v_charp);

	$insert into pm_tran values
	   ($pmprop_propnum, 0, $pmprop_inspector, "A", $pmprop_date, "", "");
}


Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip

DAS
-- 
David Snyder @ Snide Computer Services - Folcroft, PA          Current Release
                                                               is db4glgen-3.7
UUCP:  ..!uunet!das13!dave   INTERNET:  dave.snyder@snide.com
Newsgroups: comp.databases.informix