## Message Posted: Tue, 25 Feb 2014 @ 22:20:29 GMT

 < Last>>

 Subj: UDF using DECIMAL8 OR DECIMAL16 VALUES to pass decimal(18, 2) values From: Satti, Faheem

Hi Folks,

need the help to create a UDF in C using DECIMAL8 OR DECIMAL16 VALUES to pass input values defined as decimal(18,2) values

This code works and gives result:

```     input/output size <= (9,2)

REPLACE FUNCTION plusudfdec(
a   DECIMAL(9,2),
b   DECIMAL(9,2)
)RETURNS DECIMAL(9,2)
LANGUAGE C
NO SQL
EXTERNAL NAME 'CS!plusudfdec!C:\Users\Documents\UDFs\dec\plusudfdec.c'
PARAMETER STYLE TD_GENERAL;

#define SQL_TEXT Latin_Text
#include
#include
#include
#include
#include

void plusudfdec(DECIMAL4 *a, DECIMAL4 *b, DECIMAL4 *result, char
sqlstate[5])
{  *result = *a + *b;}
;

select plusudfdec(5.1,10.3);

*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.

plusudfdec(5.1,10.3)
--------------------
15.40
```

Increase the input/output size from (9,2) to (10,2) and in c program from

```     DECIMAL4 to DECIMAL8
This does not compile
REPLACE FUNCTION plusudfdec(
a   DECIMAL(10,2),
b   DECIMAL(10,2)
)RETURNS DECIMAL(10,2)
LANGUAGE C
NO SQL
EXTERNAL NAME 'CS!plusudfdec!C:\Users\UDFs\dec\plusudfdec.c'
PARAMETER STYLE TD_GENERAL;

#define SQL_TEXT Latin_Text
#include
#include
#include
#include
#include

void plusudfdec(DECIMAL8 *a, DECIMAL8 *b, DECIMAL8 *result, char
sqlstate[5])
{  *result = *a + *b;}
;

Errors/Warnings reported during compilation
```

 < Last>>

Attachments

Library

Quick Reference

Archives

Sample Index

 2016 2007 2015 2006 2014 2005 2013 2004 2012 2003 2011 2002 2010 2001 2009 2000 2008 1999

2014 Indexes

 Jan Jul Feb Aug Mar Sep Apr Oct May Nov Jun Dec

 Top Home Privacy Feedback