Database Reference
In-Depth Information
We will save the NLS _ DATE _ FORMAT into a variable so we can change it to a format that preserves the date and time
when dumping the data to disk. In this fashion, we will preserve the time component of a date. We then set up an
exception block so that we can reset the NLS_DATE_FORMAT upon any error:
106 select value
107 into l_datefmt
108 from nls_session_parameters
109 where parameter = 'NLS_DATE_FORMAT';
110
111 /*
112 Set the date format to a big numeric string. Avoids
113 all NLS issues and saves both the time and date.
114 */
115 execute immediate
116 'alter session set nls_date_format=''ddmmyyyyhh24miss'' ';
117
118 /*
119 Set up an exception block so that in the event of any
120 error, we can at least reset the date format.
121 */
122 begin
Next we will parse and describe the query. The setting of G_DESCTBL to L_DESCTBL is done to reset the global table;
otherwise, it might contain data from a previous DESCRIBE in addition to data for the current query. Once we have
done that, we call DUMP_CTL to actually create the control file:
123 /*
124 Parse and describe the query. We reset the
125 descTbl to an empty table so .count on it
126 will be reliable.
127 */
128 dbms_sql.parse( g_theCursor, p_query, dbms_sql.native );
129 g_descTbl := l_descTbl;
130 dbms_sql.describe_columns( g_theCursor, l_colCnt, g_descTbl );
131
132 /*
133 Create a control file to reload this data
134 into the desired table.
135 */
136 dump_ctl( p_dir, p_filename, p_tname, p_mode, p_separator,
137 p_enclosure, p_terminator );
138
139 /*
140 Bind every single column to a varchar2(4000). We don't care
141 if we are fetching a number or a date or whatever.
142 Everything can be a string.
143 */
 
Search WWH ::




Custom Search