initial
This commit is contained in:
@@ -0,0 +1,477 @@
|
||||
<!--- примитивный конструктор селектов, чтобы не набирать руками колонки --->
|
||||
<!--- v0.1 2018.02.27 --->
|
||||
<!--- v0.3 13.11.2020 --->
|
||||
<!--- v0.4 16.11.2020 for rest api--->
|
||||
<!--- v0.5 27.07.2025 fields, export--->
|
||||
<!--- v0.6 01.09.2025 fixes--->
|
||||
<cfsetting enablecfoutputonly="false"/>
|
||||
<!---<cfimport prefix="m" taglib="../../../lib"/>--->
|
||||
<!---<cfimport prefix="d" taglib="lib/data"/>--->
|
||||
|
||||
<cfparam name="obj" default=""/>
|
||||
<cfparam name="schema" default=""/>
|
||||
<!---<cfparam name="ds" default="metadata"/>--->
|
||||
<cfparam name="out" default="field_set,bean"/>
|
||||
<cfparam name="alias" default=""/>
|
||||
<cfparam name="dt_format_iso" default="0"/>
|
||||
<cfparam name="form.column_list" default=""/>
|
||||
<cfset tag_prefix="m:"/>
|
||||
<!---<cfswitch expression=#ds#>
|
||||
<cfcase value="metadata"><cfset request.ds="mms"/></cfcase>
|
||||
<cfcase value="data"><cfset request.ds="ditcloud"/></cfcase>
|
||||
<cfdefaultcase><cfset request.ds=""/></cfdefaultcase>
|
||||
</cfswitch>--->
|
||||
<cfquery name="qSchema" datasource="#request.DS#">
|
||||
select schema_name
|
||||
from information_schema.schemata
|
||||
order by schema_name
|
||||
</cfquery>
|
||||
|
||||
<cfquery name="qObj" datasource="#request.DS#">
|
||||
select o.table_type as type, o.table_name as name
|
||||
from information_schema.tables o
|
||||
where o.table_type in ('BASE TABLE','VIEW')
|
||||
<cfif len(schema)>AND table_schema=<cfqueryparam cfsqltype="cf_sql_varchar" value="#schema#"/></cfif>
|
||||
order by o.table_type, o.table_name
|
||||
</cfquery>
|
||||
<!---<cfdump var=#qObj#/>--->
|
||||
<!--- *** надо ключевые поля выводить первыми --->
|
||||
<cfquery name="qCol" datasource="#request.DS#">
|
||||
select c.column_name as name, c.data_type, c.character_maximum_length as max_length, c.is_nullable, c.is_identity
|
||||
from information_schema.columns c
|
||||
join information_schema.tables o on (c.table_name=o.table_name AND c.table_schema=o.table_schema)
|
||||
where o.table_name=<cfqueryparam cfsqltype="cf_sql_varchar" value="#obj#"/>
|
||||
</cfquery>
|
||||
<!---
|
||||
|
||||
<cfdump var=#qCol#/><cfabort/>--->
|
||||
|
||||
|
||||
|
||||
<html><head></head><body>
|
||||
<h1>Генератор всякой всячины из таблицы PostgreSQL</h1>
|
||||
<form action="" method="post">
|
||||
<!--- <select name="ds" onchange="submit();">
|
||||
<option <cfif #ds# EQ "data"> selected</cfif>>data</option>
|
||||
<option <cfif #ds# EQ "metadata"> selected</cfif>>metadata</option>
|
||||
</select>--->
|
||||
<label for="schema">Схема</label>
|
||||
<select name="schema" id="schema" onchange="submit();">
|
||||
<cfoutput query="qSchema">
|
||||
<option <cfif #qSchema.schema_name# EQ #schema#> selected</cfif>>#qSchema.schema_name#</option>
|
||||
</cfoutput>
|
||||
</select>
|
||||
<label for="obj">Таблица</label>
|
||||
<select name="obj" id="obj">
|
||||
<cfoutput query="qObj">
|
||||
<option <cfif #obj# EQ #name#> selected</cfif> value="#name#">
|
||||
<cfif #trim(qObj.type)# EQ 'U'>(table)<cfelseif #trim(qObj.type)# EQ 'V'>(view)<cfelse></cfif> #name#
|
||||
</option>
|
||||
</cfoutput>
|
||||
</select>
|
||||
<br/>
|
||||
|
||||
<b>Поля:</b>
|
||||
<input type="checkbox" name="fields_all" id="fields_all" value="1" onchange="; for (var i=0, fld_checkboxes=document.getElementsByName('column_list'), n=fld_checkboxes.length; i < n ; i++) {fld_checkboxes[i].checked = this.checked;}" style="margin-right:0;"/>
|
||||
<label for="fields_all">(все)</label>
|
||||
<cfoutput query="qCol">
|
||||
<input type="checkbox" name="column_list" id="column_list_#qCol.currentRow#" value="#name#"<cfif structKeyExists(form, "column_list")><cfif listFind(form.column_list,name)> checked</cfif></cfif> style="margin-right:0;"/><label for="column_list_#qCol.currentRow#">#name#</label>
|
||||
</cfoutput> <i>для некоторых вариантов предполагается, что таблица имеет целочисленный ключ "tablename_id"</i>
|
||||
<br/>
|
||||
|
||||
<b>Генерировать:</b>
|
||||
<input type="checkbox" name="out_all" id="out_all" value="1" onchange="; for (var i=0, checkboxes=document.getElementsByName('out'), n=checkboxes.length; i < n ; i++) {checkboxes[i].checked = this.checked;}" style="margin-right:0;"/>
|
||||
<label for="out_all">(все)</label>
|
||||
|
||||
<cfloop list="select,update,insert,export,bean,grid,simple_grid,detail,fields_spec,field_set" item="outformat">
|
||||
<cfoutput>
|
||||
<input type="checkbox" name="out" id="#outformat#" value
|
||||
="#outformat#"<cfif structKeyExists(form, "out")><cfif listFind(form.out,outformat)> checked</cfif></cfif> style="margin-right:0;"/>
|
||||
<label for="#outformat#">#outformat#</label>
|
||||
</cfoutput>
|
||||
</cfloop>
|
||||
|
||||
<br/>
|
||||
<cfoutput>
|
||||
<label for="alias">Alias:</label> <input type="text" name="alias" id="alias" value="#alias#" size="2"/>
|
||||
</cfoutput>
|
||||
<input type="checkbox" name="dt_format_iso" id="dt_format_iso" value="1"<cfif dt_format_iso> checked</cfif>/><label for="dt_format_iso">Datetime format ISO</label>
|
||||
|
||||
<input type="submit" name="do" value="Сформировать"/>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif structKeyExists(form, "do")>
|
||||
<cfif structKeyExists(form, "out")>
|
||||
|
||||
|
||||
|
||||
<cfif listFind(form.out,"select")>
|
||||
<cfset comma="No"/>
|
||||
<pre>
|
||||
select <cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<cfif comma>,<cfelse> <cfset comma="Yes"/></cfif><cfif len(alias)>#alias#.</cfif>#name#</cfif></cfoutput>
|
||||
from <cfoutput>#schema#.#obj#<cfif len(alias)> #alias#</cfif></cfoutput>;
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"insert")>
|
||||
<pre>
|
||||
insert into <cfoutput>#schema#.#obj#</cfoutput> (<cfset comma="No"/> <cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)><cfif !is_identity OR listLen(column_list)><cfif comma>
|
||||
,<cfelse>
|
||||
<cfset comma="Yes"/></cfif>#name#</cfif></cfif></cfoutput>
|
||||
) values (<cfset comma="No"/><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)><cfif !is_identity OR listLen(column_list)><cfif comma>
|
||||
,<cfelse>
|
||||
<cfset comma="Yes"/></cfif><cfqueryparam cfsqltype="#cfSqlType(data_type)#" value="###name###"/></cfif></cfif></cfoutput>
|
||||
);
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"export")>
|
||||
<cfquery name="qExport">
|
||||
select <cfif listLen(column_list)>#column_list#<cfelse>*</cfif>
|
||||
from #schema#.#obj#
|
||||
</cfquery>
|
||||
<pre>
|
||||
insert into <cfoutput>#schema#.#obj#</cfoutput> (<cfset comma="No"/> <cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)><cfif comma>
|
||||
,<cfelse>
|
||||
<cfset comma="Yes"/></cfif>#name#</cfif></cfoutput>
|
||||
)
|
||||
values
|
||||
<cfoutput query="qExport">(<cfset comma="No"/><cfloop query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)><cfif comma>, <cfelse><cfset comma="Yes"/></cfif><!---
|
||||
--->'#qExport[qCol.name]#'</cfif></cfloop>)<!---
|
||||
---><cfif qExport.currentRow LT qExport.recordCount>,</cfif>
|
||||
</cfoutput>;
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"update")>
|
||||
<cfset comma="No"/>
|
||||
<pre>
|
||||
update <cfoutput>#obj#</cfoutput> set <cfoutput query="qCol"><cfif !is_identity OR listLen(column_list)><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<cfif comma>,<cfelse> <cfset comma="Yes"/></cfif>#name#=<cfqueryparam cfsqltype="#cfSqlType(data_type)#" value="###name###"/></cfif></cfif></cfoutput>
|
||||
<cfoutput>where #obj#_id=<cfqueryparam cfsqltype="cf_sql_integer" value="###obj#_id##" null=##!isNumeric(#obj#_id)##/></cfoutput>;
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"bean")>
|
||||
<pre>
|
||||
<d:bean readonly=#!pageInfo.writePermitted()# table="<cfoutput>#obj#</cfoutput>" datasource="#request.DS#" output="d" status="status"><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<cfswitch expression=#name#>
|
||||
<cfcase value="creator_id"><d:param field="creator_id" type="integer" value="##request.usr_id##" skipUpdate/></cfcase>
|
||||
<cfcase value="updater_id"><d:param field="updater_id" type="integer" value="##request.usr_id##"/></cfcase>
|
||||
<cfcase value="dt_created"><d:param field="dt_created" type="timestamp" value="##Now()##" skipUpdate/></cfcase>
|
||||
<cfcase value="dt_updated"><d:param field="dt_updated" type="timestamp" value="##Now()##"/></cfcase>
|
||||
<cfdefaultcase><d:param field="#name#" type="#translateDataType(data_type)#"<cfif isStringType(data_type) AND (max_length GT 0)> size="#max_length#" preprocessor=##cleanInput##</cfif><cfif isStringType(data_type) AND (max_length LE 0)> preprocessor=##plain2HtmClean##</cfif><cfif "#name#" EQ "#obj#_id"> key autoincrement<cfelseif is_nullable AND true> forNull=""</cfif><cfif isIntegerType(data_type)> default="0" init="0"</cfif>/></cfdefaultcase>
|
||||
</cfswitch></cfif></cfoutput>
|
||||
</d:bean>
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"grid")>
|
||||
<pre>
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<layout:grid_head titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray#><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<th><layout:column_head name="#name#"/></th></cfif></cfoutput>
|
||||
</layout:grid_head>
|
||||
</thead>
|
||||
|
||||
<cfoutput query="qRead" maxrows="#pageInfo.recordsPerPage#" startrow="#pageInfo.nStart#">
|
||||
<tr><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<td class="c">##<cfif isDateType(data_type)>dateFormat(#name#,'YYYY-MM-DD')<cfelse>#name#</cfif>##</td></cfif></cfoutput>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
</table>
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<cfif listFind(form.out,"simple_grid")>
|
||||
<pre>
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<th>#name#</th></cfif></cfoutput>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<cfoutput query="qRead">
|
||||
<tr><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<td class="c">##<cfif isDateType(data_type)>dateFormat(#name#,'YYYY-MM-DD')<cfelse>#name#</cfif>##</td></cfif></cfoutput>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
</table>
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"detail")>
|
||||
<pre>
|
||||
|
||||
<div class="detail">
|
||||
<cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<div class="tr">
|
||||
<div class="th">#name#</div>
|
||||
<div class="td"><cfif NOT max_length GT 0><input type="text" name="#name#" id="#name#" value="<cfelseif (isStringType(data_type) AND (max_length LE 0))><textarea rows="5" cols="70" name="#name#" id="#name#"><cfelseif isIntegerType(data_type)><input type="checkbox" name="#name#" id="name" value="1"<cfif (</cfif><!---
|
||||
--->##<cfif isDateType(data_type)>dateFormat(d.#name#,'YYYY-MM-DD')<cfelse>d.#name#</cfif>##<cfif (isStringType(data_type) AND max_length GT 0) OR /*listFind("127,106,62,59,36,56,108,52,41,58,61,189,48",system_type_id)*/true>"/><cfelseif (isStringType(data_type) AND (max_length LE 0))></textarea><cfelseif isIntegerType(data_type)> GT 0)> checked</cfif>/></cfif><!---
|
||||
---></div>
|
||||
</div>
|
||||
</cfif></cfoutput>
|
||||
</div>
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"fields_spec")><!--- webkit bug? it changes order of pre with left curved bracket inside,
|
||||
minimum sample: 1<pre>{</pre>3 Пытается парсить Error: Parse error on line 1:
|
||||
{ contragent_id={prefi
|
||||
--^
|
||||
Expecting 'STRING', '}', got 'undefined'--->
|
||||
<div style="white-space:pre; font-family:monospace;">
|
||||
{
|
||||
<cfset comma="No"/><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)><cfif comma>
|
||||
,<cfelse> <cfset comma="Yes"/></cfif>#name#={prefix="#alias#", type="#cfSqlType(data_type)#"}</cfif></cfoutput>
|
||||
}
|
||||
</div>
|
||||
</cfif>
|
||||
<hr/>
|
||||
|
||||
<cfif listFind(form.out,"field_set")>
|
||||
<pre>
|
||||
select
|
||||
<cfoutput><#tag_prefix#field_set titleMapOut="local.titleMap" lengthOut="fieldCount"></cfoutput><cfoutput query="qCol"><cfif listLen(column_list) EQ 0 OR listFind(#column_list#,#name#)>
|
||||
<cfif isDateType(data_type)><#tag_prefix#field title="#name#"><!---
|
||||
---><cfif dt_format_iso><!---
|
||||
--->to_char(<!---
|
||||
---><cfif len(alias)>#alias#.<!---
|
||||
---></cfif>#name#, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as #name#<!---
|
||||
---><cfelse><!---
|
||||
---><cfif len(alias)>#alias#.<!---
|
||||
---></cfif>#name#<!---
|
||||
---></cfif></#tag_prefix#field><!---
|
||||
---><cfelseif isUuidType(data_type)><#tag_prefix#field title="#name#"><!---
|
||||
---><cfif len(alias)>#alias#.<!---
|
||||
---></cfif>#name#::text as #name#</#tag_prefix#field><!---
|
||||
---><cfelse><#tag_prefix#field title="#name#"><!---
|
||||
---><cfif len(alias)>#alias#.<!---
|
||||
---></cfif>#name#</#tag_prefix#field><!---
|
||||
---></cfif></cfif></cfoutput>
|
||||
<cfoutput></#tag_prefix#field_set></cfoutput>
|
||||
from <cfoutput>#obj#<cfif len(alias)> #alias#</cfif></cfoutput>;
|
||||
</pre>
|
||||
</cfif>
|
||||
|
||||
<hr/>
|
||||
|
||||
</cfif>
|
||||
</cfif>
|
||||
|
||||
</body></html>
|
||||
|
||||
<!--- <cffunction name="isDateType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="40,41,58,61,189"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction> --->
|
||||
|
||||
<cffunction name="isDateType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="date,time,datetime,timestamp,timestamptz,timestamp with time zone"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="isNumericType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="bigint,integer,decimal,double,float,numeric,smallint,tinyint"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="isIntegerType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="bigint,integer,smallint,tinyint"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="isStringType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="varchar,character varying,text"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="isUuidType" output="No"><!--- UUID и GUID имеют разный формат --->
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="uuid"><cfreturn true/></cfcase>
|
||||
<cfdefaultcase><cfreturn false/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="cfSqlType" output="No">
|
||||
<cfargument name="type"/>
|
||||
<cfswitch expression=#type#>
|
||||
<cfcase value="uuid"><cfreturn "cf_sql_other"/></cfcase><!--- idstamp for postgresql does not work correctly --->
|
||||
<cfcase value="bit,bool,boolean"><cfreturn "cf_sql_bit"/></cfcase>
|
||||
<cfcase value="bigint"><cfreturn "cf_sql_bigint"/></cfcase>
|
||||
<cfcase value="integer"><cfreturn "cf_sql_integer"/></cfcase>
|
||||
<cfcase value="smallint"><cfreturn "cf_sql_smallint"/></cfcase>
|
||||
<cfcase value="tinyint"><cfreturn "cf_sql_tinyint"/></cfcase>
|
||||
<cfcase value="decimal"><cfreturn "cf_sql_decimal"/></cfcase>
|
||||
<cfcase value="numeric"><cfreturn "cf_sql_numeric"/></cfcase>
|
||||
<cfcase value="real"><cfreturn "cf_sql_real"/></cfcase>
|
||||
<cfcase value="float"><cfreturn "cf_sql_float"/></cfcase>
|
||||
<cfcase value="double"><cfreturn "cf_sql_double"/></cfcase>
|
||||
<cfcase value="char"><cfreturn "cf_sql_char"/></cfcase>
|
||||
<cfcase value="varchar,character varying,text"><cfreturn "cf_sql_varchar"/></cfcase>
|
||||
<cfcase value="date"><cfreturn "cf_sql_date"/></cfcase>
|
||||
<cfcase value="time"><cfreturn "cf_sql_time"/></cfcase>
|
||||
<cfcase value="timestamp,timestamptz,timestamp with time zone"><cfreturn "cf_sql_timestamp"/></cfcase>
|
||||
<cfdefaultcase><cfreturn "cf_sql_varchar"/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="translateDataType" output="No">
|
||||
<cfargument name="type"/>
|
||||
<cfswitch expression=#type#>
|
||||
<cfcase value="bit,bool,boolean"><cfreturn "bit"/></cfcase>
|
||||
<cfcase value="varchar,character varying,text"><cfreturn "varchar"/></cfcase>
|
||||
<cfcase value="timestamp,timestamptz,timestamp with time zone"><cfreturn "timestamp"/></cfcase>
|
||||
<cfdefaultcase><cfreturn #type#/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<!--- https://cfdocs.org/cfsqltype-cheatsheet
|
||||
CF_SQL_* JDBC DB2 Oracle SQL Server
|
||||
CF_SQL_ARRAY ARRAY N/A N/A N/A
|
||||
CF_SQL_BIGINT BIGINT BigInt N/A bigint
|
||||
CF_SQL_BINARY BINARY Char for Bit Data N/A binary, timestamp
|
||||
CF_SQL_BIT BIT N/A N/A bit
|
||||
CF_SQL_BLOB BLOB Blob blob, bfile longvarbinary
|
||||
CF_SQL_CHAR CHAR Char char, nchar char, nchar, uniqueidentifier
|
||||
CF_SQL_CLOB CLOB Clob clob, nclob N/A
|
||||
CF_SQL_DATE DATE Date N/A/ date
|
||||
CF_SQL_DECIMAL* DECIMAL Decimal number decimal, money, smallmoney
|
||||
CF_SQL_DISTINCT DISTINCT N/A N/A N/A
|
||||
CF_SQL_DOUBLE DOUBLE Double N/A float
|
||||
CF_SQL_FLOAT FLOAT Float number real
|
||||
CF_SQL_IDSTAMP CHAR Char char, nchar char, nchar, uniqueidentifier
|
||||
CF_SQL_INTEGER INTEGER Integer N/A int
|
||||
CF_SQL_LONGVARBINARY LONGVARBINARY Long Varchar for Bit Data long raw image
|
||||
CF_SQL_LONGNVARCHAR LONGNVARCHAR LONGVARGRAPHIC NVARCHAR2 ntext, xml
|
||||
CF_SQL_LONGVARCHAR LONGVARCHAR Long Varchar long text, ntext, xml
|
||||
CF_SQL_MONEY DOUBLE Double N/A float, money
|
||||
CF_SQL_MONEY4 DOUBLE Double N/A float, money
|
||||
CF_SQL_NCHAR NCHAR NCHAR NCHAR nchar
|
||||
CF_SQL_NCLOB CLOB NCLOB NCLOB nvarchar
|
||||
CF_SQL_NULL NULL N/A N/A N/A
|
||||
CF_SQL_NUMERIC* NUMERIC Numeric N/A numeric
|
||||
CF_SQL_NVARCHAR NVARCHAR NVARCHAR NVARCHAR2 nvarchar
|
||||
CF_SQL_OTHER OTHER N/A N/A N/A
|
||||
CF_SQL_REAL REAL Real N/A real
|
||||
CF_SQL_REFCURSOR REF N/A N/A N/A
|
||||
CF_SQL_SMALLINT SMALLINT Smallint N/A smallint
|
||||
CF_SQL_STRUCT STRUCT N/A N/A N/A
|
||||
CF_SQL_SQLXML N/A N/A N/A xml
|
||||
CF_SQL_TIME TIME Time N/A time
|
||||
CF_SQL_TIMESTAMP TIMESTAMP Timestamp date datetime, datetime2, smalldatetime
|
||||
CF_SQL_TINYINT TINYINT N/A N/A tinyint
|
||||
CF_SQL_VARBINARY VARBINARY Rowid raw varbinary, geometry, geography, udt
|
||||
CF_SQL_VARCHAR VARCHAR Varchar varchar2, nvarchar2 varchar, nvarchar --->
|
||||
|
||||
<cffunction name="fieldType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="127"><cfreturn "bigint"/></cfcase>
|
||||
<cfcase value="104"><cfreturn "integer"/></cfcase><!---bit--->
|
||||
<cfcase value="175"><cfreturn "char"/></cfcase>
|
||||
<cfcase value="40"><cfreturn "date"/></cfcase>
|
||||
<cfcase value="106"><cfreturn "decimal"/></cfcase>
|
||||
<cfcase value="62"><cfreturn "double"/></cfcase><!---float--cf_sql_double--->
|
||||
<cfcase value="59"><cfreturn "float"/></cfcase><!---real--cf_sql_float--->
|
||||
<cfcase value="36"><cfreturn "idstamp"/></cfcase><!---uniqueidentifier--->
|
||||
<cfcase value="56"><cfreturn "integer"/></cfcase>
|
||||
<cfcase value="108"><cfreturn "numeric"/></cfcase>
|
||||
<!---<cfcase value="59"><cfreturn "real"/></cfcase>--->
|
||||
<cfcase value="52"><cfreturn "smallint"/></cfcase>
|
||||
<cfcase value="41"><cfreturn "time"/></cfcase>
|
||||
<cfcase value="58,61,189"><cfreturn "timestamp"/></cfcase><!---smalldatetime,datetime,timestamp--->
|
||||
<cfcase value="48"><cfreturn "tinyint"/></cfcase>
|
||||
<cfcase value="165"><cfreturn "varbinary"/></cfcase>
|
||||
<cfcase value="167,231"><cfreturn "varchar"/></cfcase>
|
||||
<cfdefaultcase><cfreturn "varchar"/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="cfType" output="No">
|
||||
<cfargument name="xtype"/>
|
||||
<cfswitch expression=#xtype#>
|
||||
<cfcase value="127"><cfreturn "integer"/></cfcase>
|
||||
<cfcase value="104"><cfreturn "boolean"/></cfcase><!---bit--->
|
||||
<cfcase value="175"><cfreturn "string"/></cfcase><!---char--->
|
||||
<cfcase value="40"><cfreturn "date"/></cfcase>
|
||||
<cfcase value="106"><cfreturn "numeric"/></cfcase><!---decimal--->
|
||||
<cfcase value="62"><cfreturn "numeric"/></cfcase><!---float--cf_sql_double--->
|
||||
<cfcase value="59"><cfreturn "numeric"/></cfcase><!---real--cf_sql_float--->
|
||||
<cfcase value="36"><cfreturn "guid"/></cfcase><!---uniqueidentifier--->
|
||||
<cfcase value="56"><cfreturn "integer"/></cfcase>
|
||||
<cfcase value="108"><cfreturn "numeric"/></cfcase>
|
||||
<cfcase value="52"><cfreturn "integer"/></cfcase><!---smallint--->
|
||||
<cfcase value="41"><cfreturn "date"/></cfcase><!---time--->
|
||||
<cfcase value="58,61,189"><cfreturn "date"/></cfcase><!---smalldatetime,datetime,timestamp--->
|
||||
<cfcase value="48"><cfreturn "integer"/></cfcase>
|
||||
<cfcase value="165"><cfreturn "binary"/></cfcase>
|
||||
<cfcase value="167,231"><cfreturn "string"/></cfcase>
|
||||
<cfdefaultcase><cfreturn "string"/></cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<!---
|
||||
CF_SQL_BIGINT
|
||||
CF_SQL_BIT
|
||||
CF_SQL_CHAR
|
||||
CF_SQL_BLOB
|
||||
CF_SQL_CLOB
|
||||
CF_SQL_DATE
|
||||
CF_SQL_DECIMAL
|
||||
CF_SQL_DOUBLE
|
||||
CF_SQL_FLOAT
|
||||
CF_SQL_IDSTAMP
|
||||
CF_SQL_INTEGER
|
||||
CF_SQL_LONGVARCHAR
|
||||
CF_SQL_MONEY
|
||||
CF_SQL_MONEY4
|
||||
CF_SQL_NUMERIC
|
||||
CF_SQL_REAL
|
||||
CF_SQL_REFCURSOR
|
||||
CF_SQL_SMALLINT
|
||||
CF_SQL_TIME
|
||||
CF_SQL_TIMESTAMP
|
||||
CF_SQL_TINYINT
|
||||
CF_SQL_VARCHAR
|
||||
--->
|
||||
Reference in New Issue
Block a user