Home » SQL & PL/SQL » SQL & PL/SQL » HTP Package in UTf8
HTP Package in UTf8 [message #318415] |
Tue, 06 May 2008 16:15 |
amber.jah
Messages: 1 Registered: May 2008
|
Junior Member |
|
|
Hi,
I am trying to execute this code:
begin
-- Initialize owa with an empty array, just so we can use htp.
owa.init_cgi_env( param_val=>owa.cgi_var_name );
-- Add a header to avoid dealing with header-related code in htp.
htp.prn('Content-Type:text/plain');
htp.print('');
-- Add padding to get a total number of rows >= pack_after (60)
-- See the source of SYS.htp for details on pack_after.
for n in 1 .. 58 loop
htp.print('x');
end loop;
-- Now whatever we prn() goes into htp.htcurline, which is defined as
-- VARCHAR2(255)
-- Note: This means 255 BYTES by default, since NLS_LENGTH_SEMANTICS
-- has a default value of 'BYTE'.
-- Start with 242 characters/bytes.
htp.prn(rpad('x',242,'x'));
-- There is now room left for 13 bytes.
-- Add 4 characters / 12 bytes.
-- Note: characters are 4 UTF-8 encoded Tamil language characters.
htp.prn(utl_raw.cast_to_varchar2('E0AEA4E0AEAEE0AEBFE0AEB4'));
-- There is now room for (13-12=) 1 more byte. But htp thinks there is
-- room for (13-4=) 9 more, since it used length().
-- Adding 3 characters/bytes causes ORA-06502: PL/SQL: numeric or value
-- error: character string buffer too small
htp.prn('xxx');
end;
/
The error I am getting is
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SYS.HTP", line 1550
ORA-06512: at line 32
what i feel is that oracle Database UTF8 or AL32UTF8 characterset does not support htp package properly. When i run the code on another characterset, it runs errorfree except in UTF8 or AL32UTF8.
Is there any way to remove this problem?
|
|
|
|
Re: HTP Package in UTf8 [message #479707 is a reply to message #318415] |
Mon, 18 October 2010 15:06 |
mgr000
Messages: 3 Registered: October 2010
|
Junior Member |
|
|
I'm getting the same problem as amber.jah reported in May 2008 and can't seem to pinpoint the problem. Is there a resolution to this problem? Thanks (new to ORAFAQ).
|
|
|
|
Re: HTP Package in UTf8 [message #479710 is a reply to message #479708] |
Mon, 18 October 2010 15:47 |
mgr000
Messages: 3 Registered: October 2010
|
Junior Member |
|
|
Sorry, I thought that since the same problem was raised that I didn't have to post the code.
Calling this procedure, passing a language code of E (english) or F (french). In English everything works fine, in french it doesnt. I havbe to deal with french characters (é, à, è, etc).
(p_language_code IN VARCHAR2 DEFAULT 'E',
x IN VARCHAR2 DEFAULT NULL,
y IN VARCHAR2 DEFAULT NULL) IS
--report 1
CURSOR cur_sector(i_fy IN VARCHAR2) IS
SELECT DECODE(p_language_code,'E',dsd.level1_english_name,
dsd.level1_french_name) sector,
dsd.level1_sector_code level1_sector_code,
SUM(DECODE(dwff.fiscal_year_key,0,dwff.disbursement_amount,0)) hist_adj,
SUM(DECODE(dwff.fiscal_year_key,0,0,
1,0,
i_fy-4,0,
i_fy-3,0,
i_fy-2,0,
i_fy-1,0,
i_fy-0,0,
dwff.disbursement_amount)) cumm_hist,
SUM(DECODE(dwff.fiscal_year_key,i_fy-4,dwff.disbursement_amount,0)) fy_minus_4,
SUM(DECODE(dwff.fiscal_year_key,i_fy-3,dwff.disbursement_amount,0)) fy_minus_3,
SUM(DECODE(dwff.fiscal_year_key,i_fy-2,dwff.disbursement_amount,0)) fy_minus_2,
SUM(DECODE(dwff.fiscal_year_key,i_fy-1,dwff.disbursement_amount,0)) fy_minus_1,
SUM(DECODE(dwff.fiscal_year_key,i_fy-0,dwff.disbursement_amount,0)) current_fy,
SUM(DECODE(dwff.fiscal_year_key,i_fy-4,dwff.disbursement_amount,
i_fy-3,dwff.disbursement_amount,
i_fy-2,dwff.disbursement_amount,
i_fy-1,dwff.disbursement_amount,
i_fy-0,dwff.disbursement_amount,
0)) sum_last_5,
SUM(DECODE(dwff.fiscal_year_key,1,0,
dwff.disbursement_amount)) sum_disb
FROM dm_responsibility_dim drd,
dm_wbs_financial_fact dwff,
dm_sector_dim dsd,
dm_fund_dim dfd
WHERE dwff.responsibility_key = drd.responsibility_key
AND dsd.sector_key = dwff.sector_key
AND dwff.disbursement_amount <> 0
AND dfd.fund_key = dwff.fund_key
AND (dfd.authority_code in
(select group_value_code
from dw_group_value
where group_code = 'AUTH_CODE_AID')
or dfd.fund_number in
(select group_value_code
from dw_group_value
where group_code = 'FUND_NUMBER_AID'))
GROUP BY dsd.level1_sector_code,
DECODE(p_language_code,'E',dsd.level1_english_name,
dsd.level1_french_name)
ORDER BY 2, 1;
TYPE sector_type IS TABLE OF cur_sector%ROWTYPE INDEX BY BINARY_INTEGER;
sector_array sector_type;
total_array sector_type;
v_curr_fisc_yr VARCHAR2(4);
v_4_ago_fisc_yr_str VARCHAR2(20);
v_3_ago_fisc_yr_str VARCHAR2(20);
v_2_ago_fisc_yr_str VARCHAR2(20);
v_1_ago_fisc_yr_str VARCHAR2(20);
v_curr_fisc_yr_str VARCHAR2(20);
c_title VARCHAR2(200);
c_sector VARCHAR2(200);
c_priority VARCHAR2(200);
c_country VARCHAR2(200);
c_sector_percent VARCHAR2(200);
c_priority_percent VARCHAR2(200);
c_country_percent VARCHAR2(200);
c_project VARCHAR2(200);
c_executing_agency VARCHAR2(200);
c_project_start_date VARCHAR2(200);
c_original_budget VARCHAR2(200);
c_current_budget VARCHAR2(200);
c_spent_budget VARCHAR2(200);
c_outstanding_balance VARCHAR2(200);
c_profile_rpt_hdr1 VARCHAR2(2000);
c_profile_rpt_hdr2 VARCHAR2(2000);
c_profile_sector_rpt_title VARCHAR2(2000);
c_profile_sector_rpt_note1 VARCHAR2(2000);
c_profile_sector_rpt_note2 VARCHAR2(2000);
c_profile_priority_rpt_title VARCHAR2(2000);
c_profile_priority_rpt_note1 VARCHAR2(2000);
c_profile_priority_rpt_note2 VARCHAR2(2000);
c_profile_country_rpt_title VARCHAR2(2000);
c_profile_country_rpt_note1 VARCHAR2(2000);
c_profile_country_rpt_note2 VARCHAR2(2000);
c_profile_oper_prj_1_title VARCHAR2(2000);
c_profile_oper_prj_1_note1 VARCHAR2(2000);
c_profile_oper_prj_0_title VARCHAR2(2000);
c_profile_oper_prj_0_note1 VARCHAR2(2000);
c_href VARCHAR2(4000);
v_URL_country_name dm_location_dim.country_english_name%TYPE;
BEGIN
IF p_language_code = 'E' THEN
c_title := cw_constants.e_agency_profile_title;
c_sector := cw_constants.e_dac_sec;
c_priority := cw_constants.e_sof;
c_country := cw_constants.e_country;
c_sector_percent := cw_constants.e_dac_sec||chr(38)||'nbsp;%';
c_priority_percent := cw_constants.e_sof||chr(38)||'nbsp;%';
c_country_percent := cw_constants.e_country||chr(38)||'nbsp;%';
c_project := cw_constants.e_project;
c_executing_agency := cw_constants.e_executing_agency;
c_project_start_date := cw_constants.e_project_start_date;
c_original_budget := cw_constants.e_original_budget;
c_current_budget := cw_constants.e_current_budget;
c_spent_budget := cw_constants.e_spent_budget;
c_outstanding_balance := cw_constants.e_outstanding_balance;
c_profile_rpt_hdr1 := cw_constants.e_profile_rpt_hdr1;
c_profile_rpt_hdr2 := cw_constants.e_profile_rpt_hdr2;
c_profile_sector_rpt_title := cw_constants.e_profile_dac_sec_rpt_title;
c_profile_sector_rpt_note1 := cw_constants.e_profile_dac_sec_rpt_note1;
c_profile_sector_rpt_note2 := cw_constants.e_profile_dac_sec_rpt_note2;
c_profile_priority_rpt_title := cw_constants.e_profile_sof_rpt_title;
c_profile_priority_rpt_note1 := cw_constants.e_profile_sof_rpt_note1;
c_profile_priority_rpt_note2 := cw_constants.e_profile_sof_rpt_note2;
c_profile_country_rpt_title := cw_constants.e_profile_country_rpt_title;
c_profile_country_rpt_note1 := cw_constants.e_profile_country_rpt_note1;
c_profile_country_rpt_note2 := cw_constants.e_profile_country_rpt_note2;
c_profile_oper_prj_1_title := cw_constants.e_profile_oper_prj_1_title;
c_profile_oper_prj_1_note1 := cw_constants.e_profile_oper_prj_1_note1;
c_profile_oper_prj_0_title := cw_constants.e_profile_oper_prj_0_title;
c_profile_oper_prj_0_note1 := cw_constants.e_profile_oper_prj_0_note1;
ELSE
c_title := cw_constants.f_agency_profile_title;
c_sector := cw_constants.f_dac_sec;
c_priority := cw_constants.f_sof;
c_country := cw_constants.f_country;
c_sector_percent := '%'||chr(38)||'nbsp;'||cw_constants.f_dac_sec;
c_priority_percent := '%'||chr(38)||'nbsp;'||cw_constants.f_sof;
c_country_percent := '%'||chr(38)||'nbsp;'||cw_constants.f_country;
c_project := cw_constants.f_project;
c_executing_agency := cw_constants.f_executing_agency;
c_project_start_date := cw_constants.f_project_start_date;
c_original_budget := cw_constants.f_original_budget;
c_current_budget := cw_constants.f_current_budget;
c_spent_budget := cw_constants.f_spent_budget;
c_outstanding_balance := cw_constants.f_outstanding_balance;
c_profile_rpt_hdr1 := cw_constants.f_profile_rpt_hdr1;
c_profile_rpt_hdr2 := cw_constants.f_profile_rpt_hdr2;
c_profile_sector_rpt_title := cw_constants.f_profile_dac_sec_rpt_title;
c_profile_sector_rpt_note1 := cw_constants.f_profile_dac_sec_rpt_note1;
c_profile_sector_rpt_note2 := cw_constants.f_profile_dac_sec_rpt_note2;
c_profile_priority_rpt_title := cw_constants.f_profile_sof_rpt_title;
c_profile_priority_rpt_note1 := cw_constants.f_profile_sof_rpt_note1;
c_profile_priority_rpt_note2 := cw_constants.f_profile_sof_rpt_note2;
c_profile_country_rpt_title := cw_constants.f_profile_country_rpt_title;
c_profile_country_rpt_note1 := cw_constants.f_profile_country_rpt_note1;
c_profile_country_rpt_note2 := cw_constants.f_profile_country_rpt_note2;
c_profile_oper_prj_1_title := cw_constants.f_profile_oper_prj_1_title;
c_profile_oper_prj_1_note1 := cw_constants.f_profile_oper_prj_1_note1;
c_profile_oper_prj_0_title := cw_constants.f_profile_oper_prj_0_title;
c_profile_oper_prj_0_note1 := cw_constants.f_profile_oper_prj_0_note1;
END IF;
v_curr_fisc_yr := date_to_fy(SYSDATE);
v_4_ago_fisc_yr_str := TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 5)||'/'||TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 4);
v_3_ago_fisc_yr_str := TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 4)||'/'||TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 3);
v_2_ago_fisc_yr_str := TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 3)||'/'||TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 2);
v_1_ago_fisc_yr_str := TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 2)||'/'||TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 1);
v_curr_fisc_yr_str := TO_CHAR(TO_NUMBER(v_curr_fisc_yr) - 1)||'/'||TO_CHAR(TO_NUMBER(v_curr_fisc_yr));
htp.p('<table width="100%" align="center" border="0" cellspacing=".1" cellpadding="1">');
htp.p(' <tr>');
htp.p(' <td align="center">');
htp.p('<h3 align="center">'||c_title||'</h3>');
--Report 1
htp.p('<h6></h6>');
htp.p('<h4 align="center">'||UPPER(c_profile_priority_rpt_title)||'</h4>');
htp.p('<table width="100%" align="center" border=".1" cellspacing=".1" cellpadding="1">');
htp.p(' <tr height="55"><font size="2">');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||c_priority||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||c_profile_rpt_hdr1||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||c_profile_rpt_hdr2||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||v_4_ago_fisc_yr_str||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||v_3_ago_fisc_yr_str||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||v_2_ago_fisc_yr_str||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||v_1_ago_fisc_yr_str||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||v_curr_fisc_yr_str ||'</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>Total</b></td>');
htp.p(' <td align="center" bgcolor="#b0c4de"><b>'||c_priority_percent||chr(38)||'nbsp;(1)</b></td>'); -- 2008-04-11, SCF, SV
htp.p('</tr>');
--
total_array(1).hist_adj := 0;
total_array(1).cumm_hist := 0;
total_array(1).fy_minus_4 := 0;
total_array(1).fy_minus_3 := 0;
total_array(1).fy_minus_2 := 0;
total_array(1).fy_minus_1 := 0;
total_array(1).current_fy := 0;
total_array(1).sum_disb := 0;
total_array(1).sum_last_5 := 0;
--
-- 2008-04-11, SCF, SV: Start
--
FOR rec IN cur_sof(v_curr_fisc_yr) LOOP
sof_array(sof_array.COUNT+1) := rec;
total_array(1).hist_adj := rec.hist_adj + total_array(1).hist_adj;
total_array(1).cumm_hist := rec.cumm_hist + total_array(1).cumm_hist;
total_array(1).fy_minus_4 := rec.fy_minus_4 + total_array(1).fy_minus_4;
total_array(1).fy_minus_3 := rec.fy_minus_3 + total_array(1).fy_minus_3;
total_array(1).fy_minus_2 := rec.fy_minus_2 + total_array(1).fy_minus_2;
total_array(1).fy_minus_1 := rec.fy_minus_1 + total_array(1).fy_minus_1;
total_array(1).current_fy := rec.current_fy + total_array(1).current_fy;
total_array(1).sum_disb := rec.sum_disb + total_array(1).sum_disb;
total_array(1).sum_last_5 := rec.sum_last_5 + total_array(1).sum_last_5;
END LOOP;
--
FOR i IN 1..sof_array.COUNT LOOP
c_href := 'cms_project_selector.buildwhereclause?p_language_code='||p_language_code||''||chr(38)||'mySearchScreen_id=1'||
chr(38)||'rbReportType=PROJECTS'||chr(38)||'rbHistUnalloc=Yes'||chr(38)||'txtProject='||chr(38)||'txtProjectBegins='||
chr(38)||'FromFY=any'||chr(38)||'ToFY=any'||chr(38)||'txtProjectName='||chr(38)||'FromYear=any'||
chr(38)||'FromMonth=any'||chr(38)||'ToYear=any'||chr(38)||'ToMonth=any'||chr(38)||'FromBudget=any'||chr(38)||'ToBudget=any'||
chr(38)||'BranchList=any'||chr(38)||'DivisionList=any'||chr(38)||'SectionList=any'||chr(38)||'FundCentreList=any'||
chr(38)||'CountryList=any'||chr(38)||'dac_secList=any'||chr(38)||'SOFList='||sof_array(i).sof_code||'%7E'||sof_array(i).sof_code||'%2 0'||replace(sof_array(i).sof, ' ', '%20')||
chr(38)||'GEList=any'||chr(38)||'Policy_Markers_List=any'||chr(38)||'Policy_Marker_Rank_List=any'||Chr(38)||'FundNumberList=any'||chr (38)||'p_cea_vendor_id=%25'||
chr(38)||'p_cea_vendor_view=any'||chr(38)||'p_po_vendor_id=%25'||chr(38)||'p_po_vendor_view=any'||chr(38)||'OfficerList=any'||
chr(38)||'InvestmentTypeList=any'||chr(38)||'InvestmentCharList=any'||chr(38)||'DirectiveResponsiveList=any'||
chr(38)||'DeliveryMechanismList=any'||chr(38)||'StatusList=any'||chr(38)||'RowsPerPage=15'||chr(38)||'SortOrder=Project_number'||
chr(38)||'rbAndOr=AND'||chr(38)||'appfundlist=any'||chr(38)||'continentlist=any'||chr(38)||'subcontinentlist=any'||
chr(38)||'membershiplist=any'||chr(38)||'authoritylist=any'||chr(38)||'GEList=any';
htp.p('<tr height="30"><font size="2">');
htp.p(' <td><font size="1"><a class="rpt" href='||c_href||'>('||sof_array(i).sof_code||') '||upper(sof_array(i).sof)||'</a></td>');
/
/ getting an error on the above line, with the content of c_href.
Part of the c_href variable contains french characters, however this is ok:
Gouvernance%20d%Démocratique
This isnt :
Amélioration%20de%20la%20santé
get error on the htp.p call: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
If I remove the é and replace it works, but I still get occurences of the error later on in the code, and this time the string passed to htp contains no french characters. It's very inconsistent.
Oracle 10..??
NLS_CHARACTERSET AL32UTF8
Thanks
/
/
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).hist_adj, '$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).cumm_hist, '$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).fy_minus_4,'$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).fy_minus_3,'$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).fy_minus_2,'$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).fy_minus_1,'$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).current_fy,'$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(sof_array(i).sum_disb, '$999,999,999,999')||'</td>');
htp.p(' <td align="right">'||TO_CHAR(ROUND(cw_utility.div_by_zero(sof_array(i).sum_last_5,
total_array(1).sum_last_5)*
100,0))||'%</td>');
htp.p('</tr>');
END LOOP;
/
|
|
|
Re: HTP Package in UTf8 [message #479717 is a reply to message #479710] |
Mon, 18 October 2010 18:01 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
There's a lot of stuff going on in your example. It's worth trying to see if unistr() give the same issue. So basically try htp.prn(unistr('\0BA4\0BAE\0BBF\0BB4'));
It's also worth checking that your DAD is set to UTF-8 too. I used to print (binary) .JPG images to the browser in in 9iAS using HTP.prn (UTL_RAW.cast_to_varchar2 (l_raw)), and setting the DAD to match database characterset is the key.
-- my database characterset is al32utf8
/*----------------------------------------------------------------*/
/* CAST_TO_VARCHAR2 */
/*----------------------------------------------------------------*/
--FUNCTION cast_to_varchar2(r IN RAW) RETURN VARCHAR2;
-- pragma RESTRICT_REFERENCES(cast_to_varchar2, WNDS, RNDS, WNPS, RNPS);
-- Cast a raw to a varchar2
-- This function converts a raw represented using N data bytes
-- into varchar2 with N data bytes.
-- NOTE: Once the value is cast to a varchar2, string
-- operations or server->client communication will assume
-- that the string is represented using the database's
-- character set. "Garbage" results are likely if these
-- operations are applied to a string that is actually
-- represented using some other character set.
-- Input parameters:
-- r - raw (without leading length field) to be changed to a
-- varchar2)
-- Defaults and optional parameters: None
-- Return value:
-- varchar2 - containing having the same data as the input raw
-- null - if r input parameter was null
-- Errors:
-- None
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line('Ascii=E0AEA4E0AEAEE0AEBFE0AEB4');
3 dbms_output.put_line(asciistr(utl_raw.cast_to_varchar2('E0AEA4E0AEAEE0AEBFE0AEB4')));
4 end;
5 /
Ascii=E0AEA4E0AEAEE0AEBFE0AEB4
\0BA4\0BAE\0BBF\0BB4
PL/SQL procedure successfully completed.
SQL>
|
|
|
Re: HTP Package in UTf8 [message #479720 is a reply to message #479717] |
Mon, 18 October 2010 20:23 |
mgr000
Messages: 3 Registered: October 2010
|
Junior Member |
|
|
Yes there is a lot going on..didn't know what to include/exclude. Anyways, yes I have tried unistr(). Did not work. I'm not using the app server yet because I'm buffering the html lines (via htp), then using :
procedure post_to_table (i_proc in varchar2,
i_lang in varchar2)
is
v_thepage htp.htbuf_arr;
v_lines number default 99999999;
begin
owa.get_page(v_thepage,v_lines);
....
to store the html lines in a table. But will ask the DBA to check the DAD anyways to make sure it matches the db character set. I'm also noticing that something as simple as
htp.p('<tr height="55"><font size="2">');
is also generating an error. It seems that htp is confused.
Also
owa_util.get_cgi_env('REQUEST_IANA_CHARSET'); is 'WINDOWS-1252'
owa_util.get_cgi_env('REQUEST_CHARSET'); is 'WE8MSWIN1252'
Don't know if this matters.
|
|
|
Re: HTP Package in UTf8 [message #479846 is a reply to message #479720] |
Tue, 19 October 2010 13:40 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
WE8MSWIN1252 looks like your database characterset, and if so, that's essentially ISO-1 (ISO 8859.1) with a few additional Microsoft special chars like the matching opening and closing quotes you get in MS Word etc. WE8MSWIN1252= Western European, 8bit, Microsoft codepage 1252 (US Windows essentially).
For Tamil, you're likely to want UTF8 database characterset (AL32UTF8):
SELECT * FROM nls_database_parameters WHERE parameter like 'NLS%CHARACTERSET';
|
|
|
Goto Forum:
Current Time: Sat Oct 12 14:09:36 CDT 2024
|