Home Page for the TeradataForum
 
 

 

UDF Library: 'stat_dt'

Component: 'stat_dt.c'


 
<< readme.txt  

Modify the BTEQ script below for your environment. This script sends
the source code to the server to be compiled, but you may prefer to
compile it separately on the TPA node and then create the function
from the object code.


=== stat_dt.c ===

/*--------------------------------------------------------------------
** s t a t _ d t
** User-Defined Function to convert the first 4 timestamp bytes in
** DBC.TVFields.FieldStatistics to a date.
**
** 2005-05-02  G. Rommel -- initial release
**
**------------------------------------------------------------------*/

#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include <string.h>

void stat_dt (
  VARBYTE   *field_stats,
  DATE      *result,
  char  sqlstate[6] )
{
 *result =
   ((((field_stats->bytes[1] * 256) + field_stats->bytes[0]) - 1900)
     * 10000)
     + (field_stats->bytes[2] * 100) + field_stats->bytes[3];

 strcpy(sqlstate, "00000");
 return;
}

=== stat_dt.bteq ===

drop function sysdba.stat_dt;

create function sysdba.stat_dt
 ( varbyte(16400) )
returns date
language C
no sql
parameter style td_general
deterministic
returns null on null input
external name
 'CS!stat_dt!/your/pathname/src/stat_dt.c!F!stat_dt';

.quit


<< readme.txt  





 
 

Recent Threads

Attachments

Library

Library

White Papers

UDFs

·is_integer

·nthValue

·stat_dt

·xparts

 

Teradata PDFs

IBM PDFs

 

Quick Reference

Rules of Conduct

FAQs

Join the Forum

 

Archives

Sample Index

2009  2003
2008  2002
2007  2001
2006  2000
2005  1999 
2004    


 
 
 

 
 
 
 
 
 
 
 
 
  
 
  Top Home Join Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky 
Last Modified: 05 January 2009