最近备受01461问题困扰
metalink 上 有个解释,好像一个表如果有一个varchar2(4000)后, 如果还定义一个大于varchar2(1333)的column,那么在操作这个表时可能出这个错.
但我们伟大的developer 发现,只要你的pl/sql block 块里面有一个
大于varchar2(4000)的变量定义,并把它引用在DML语句中,oracle 在parse 时候就会报错,怪吧? 解决办法是DML之前就已经赋值到一个小于varchar2(4000)长度的变量里,问题解决,版本8.1.7.3,不知道其他版本会不会有类似问题,这个.. 算不算bug???
下面附上metalink 里ora-01461 解决方案供以后参考
Subject: Workarounds for bug 1400539: GETTING ORA-1461 INSERTING INTO A VARCHAR
Doc ID: Note:241358.1 Type: BULLETIN
Last Revision Date: 10-JUL-2006 Status: PUBLISHED
In this Document
Purpose
Scope and Application
Workarounds for bug 1400539: GETTING ORA-1461 INSERTING INTO A VARCHAR
References
_____
Applies to:
Oracle Server - Enterprise Edition - Version:
Information in this document applies to any platform.
Purpose
This note tries will describe reasons and workarounds for Bug 1400539. This bug describes the following problem:
Problem:
GETTING ORA-1461 WHEN INSERTING INTO A VARCHAR FIELD
Problem symptoms
* Using PRO*C or OCI.
* Database character set is set a multibyte character set. For example UTF8, AL32UTF8, JA16SJIS or JA16EUC.
* Trying to insert a VARCHAR2 into a column that is defined with a length of more than 1333 bytes.
* The same table either has another LONG column or at least 1 other VARCHAR2 with a length over 1333 bytes.
* NLS_LANG is set to a single-byte character set. For example american_america.WE8ISO8859P1)
Resulting error
ORA-1461: "can bind a LONG value only for insert into a LONG column"
Scope and Application
There are a number of ways to "hit" this bug, and some of the workarounds can be more or less relevant depending on the exact circumstances. However, in all cases the problem will be down to using a single byte client character set and a multibyte database character set. If that is not a setup you use then this is not a problem you have hit. If you indeed have a setup like that then there is a good chance that some of the workarounds given below will solve your problem.
Workarounds for bug 1400539: GETTING ORA-1461 INSERTING INTO A VARCHAR
Background
A character from the client character set (for example WE8ISO8859P1), can take up to 3 bytes of storage in the database character set UTF8 (we will focus on UTF8 here, but the same logic applies for other multi-byte character sets). That means that when you try to use this table from the client, the conversion ratio is set to 1:3. When connecting to a UTF8 server, then all character lengths are multiplied by 3 since this is the maximum length that the data could take up on the server.The maximum size of a VARCHAR2 is 4000 bytes. Anything bigger will be treated as a LONG. During run-time no check is made for the actual content of the columns. Even if a VARCHAR2(2000) column only contains 1 character, this is treated as if you're using a LONG (just like a LONG that contains only 1 character). If you have 1 of these columns plus a LONG, or simply 2 or more of these columns, effectively the database believes that you are binding 2 long columns. Since that is not allowed you receive this error.
The influence of NLS_LENGTH_SEMANTICS
NLS_LENGTH_SEMANTICS allows you to either set the size of columns in bytes or in characters, although internally most calculations are still based on bytes. If you define a column to be "VARCHAR2(20 CHAR)", we take the maximum length
that any character can be, and multiply the length by that. That way we get the maximum amount of bytes for that column. In UTF8 the maximum number of bytes for a character is 3. If you check DBA_TAB_COLUMNS you will see "DATA_LENGTH" is 60 for a "VARCHAR2(20 CHAR)" column. On top of that we also store the maximum number of characters (20) in the "CHAR_LENGTH" column. The logic of how you run into this bug applies to the DATA_LENGTH of a column, not the CHAR_LENGTH. So if you define the strings in terms of characters and define a column of "VARCHAR2(445 CHAR)", the DATA_LENGTH of that column will be 1335 and you might run into this problem (only if you have a LONG or another column like this in the same table of course). So where we talk about a maximum of 1333 bytes in this note, you could also read that as a maximum of 444 characters (in UTF8) if you choose to define lengths in characters.
Workarounds:
If you run into this problem there are 4 workarounds:
1. Limit the size of the buffer from within the OCI code
When you hit this problem in a OCI application you have control over, you should be able to work around it by setting the OCI_ATTR_MAXDATA_SIZE attribute of the bind variable to set the maximum size of the buffer that is used to 4000 bytes. That way there is a guarantee that the buffer will never exceed the size for a VARCHAR2, and therefore this problem cannot occur. You can set this attribute using a call to OCIAttrSet after you've done the bind (for example with OCIBindByName)
For example:
int maxdata_size = 4000;
...
OCIBindByName(stmthp1, &bnd1p, errhp, (oratext*)":ENAME",
(sb4) strlen((char *)":ENAME"), (void *) ename, sizeof(ename),
SQLT_STR, (void *)&insname_ind, (ub2 *) 0, (ub2 *) 0, (ub4) 0,
(ub4 *)0, OCI_DEFAULT);
OCIAttrSet((void *) bnd1p, (ub4) OCI_HTYPE_BIND, (void *) &maxdata_size, (ub4) 0,
(ub4) OCI_ATTR_MAXDATA_SIZE, errhp);
...
As you see in the example, after the bind statement we set the OCI_ATTR_MAXDATA_SIZE attribute of the bind variable to be "4000" (which is what maxdata_size is set to in the example). This means on that on the server side we will still treat this as a VARCHAR2 because the size does not exceed the maximum for that type.
2. Use the database character set also as the client character set This is possible for Web applications or other applications that can use Unicode/UTF8. If you application runs in the OS character set (ISO/ANSI/DEC/...) you cannot set the NLS_LANG to UTF8 unless the OS Locale itself runs in UTF-8. If you run on a Unix system, depending on what precise version and vendor, it might be possible to change the Unix Locale to UTF-8. Please see section 4 of Note 158577.1 for more information and links about that: If your application cannot use UTF8 then the best option is to use workaround 1 or 3.
3. Decrease the size of the columns
If you make sure that there is only 1 LONG and no VARCHAR > 1333 bytes, OR just 1 VARCHAR > 1333 bytes in the table, you cannot hit this problem. The following query will give you all the tables with such a combination of
columns:
SELECT * FROM
(SELECT TABLE_NAME, OWNER, count(*) NUM
FROM DBA_TAB_COLUMNS
WHERE DATA_TYPE='LONG'
OR (( DATA_TYPE='VARCHAR2'
or DATA_TYPE='CHAR'
or DATA_TYPE='NVARCHAR2'
or DATA_TYPE='NCHAR')
AND DATA_LENGTH > 1333)
AND OWNER NOT IN
('SYS','SYSTEM','SH','OLAPSYS','MDSYS','WKSYS','ODM','XDB','WMSYS')
GROUP BY TABLE_NAME, OWNER)
WHERE NUM > 1;
(by default this statement filters out the standard schema's that should not contain any user data, you can change that if needed)
These tables will have to be looked at. You need to decide if you can decrease the size of the (VAR)CHARs to 1333 bytes or less. Because you should hit this bug before production (in either development or testing) it should not take to long to determine if this is something that can be done and it should certainly not take too long to implement if it's decided to do so.
If you run into this problem because you have defined strings bigger than "VARCHAR2(444 CHAR)" then in most cases you should be able to redefine them as "VARCHAR2(1333 BYTE)" without loosing much of the lengths of the strings you can store. In practice it will not happen a lot that all characters you store in a string will use the full 3 bytes of storage. So, for example, if you tried to define a "VARCHAR2(1000 CHAR)" you could run into this problem. If you change that to "VARCHAR2(1333 BYTE)" you will in practice still be able to store around 1000 characters (for languages based on ASCII).
4. Do not use the multibyte character set as the database character set This is usually not a option if you hit this issue on JA16SJIS or JA16EUC, because there are no single-byte alternatives for this. However, if you store European or Arabic characters in a (AL32)UTF8 database and hit this problem then it could be an alternative to use a single byte character set. However, it is still better and usually easier to use one of the earlier mentioned workarounds than it is to go back to a single byte character set. Certainly if you hit this problem when you're developing a new application then the other 3 workarounds are the preferred option and it should certainly be possible to use either of those. In a scenario where you're changing character sets from an existing database and where the application does not change dramatically it could be difficult to use workaround 1 or 2. In that case workaround 3 should certainly be investigated.
Something to keep in mind is that if you're changing to a UTF8 database you can really only make full use of the new possibilities if your client also starts to use a Unicode character set. For example if you have a ANSI application that always runs on Western European Windows machines, changing to UTF8 storage wouldn't add any extra characters because the application can't handle them anyway. So changing the application into Unicode and using workaround 1 would really be the best option.
Fixes
In Oracle8i and Oracle9i this is a limitation for which you need to use one of the workarounds. This problem is 'fixed' in Oracle 10i. Because of the change in architecture that is required, this behavior will not change for Oracle8i and Oracle9i.
References
Bug 1400539 - Getting Ora-1461 When Inserting Into A Varchar Field Bug 1538990 - Ora-1461 When Inserting And Updating To Db(Sjis) From Client(Euc) Bug 2909286 - Ora-1461 Generated On Insert In Proc To A Utf-8 Database Bug 2998709 - Ora-01461: Can Bind A Long Value Only For Insert Into A Long Column Note 158577.1 - NLS_LANG Explained (How does Client-Server Character Conversion Work?) Note 179133.1 - The correct NLS_LANG in a Windows Environment Note 225912.1 - Changing the Database Character Set - a short overview Note 101578.1 - Example: OCI 8i Example on UCS2-encoding Note 223025.1 - Truncation of multi-byte characters within an OCI application. Note 60134.1 - Globalization (NLS) - Frequently Asked Questions Note 267942.1 - Globalization Technology (NLS) Knowledge Browser Product Page
Errors
ORA-1461 <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text=ORA-1461> can bind a LONG value only for insert into a LONG column
Key Facts
'MULTIBYTE <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:MULTIBYTE'> ' 'AL32UTF8 <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:AL32UTF8'> ' 'CHARACTER <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:CHARACTER'> ' 'CONVERSIONRATIO <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:CONVERSIONRATIO'> ' 'NLS_LANG <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:NLS_LANG'> ' 'ORA-1461 <http://metalink.oracle.com/metalink/plsql/ml2_gui.handleSearchRequest?p_search=Submit&p_text='KEYWORD:ORA-1461'> '
said; cytotechnology salary; cytotechnologist; cytotec; how to use cytotec for an abortion; cytotec; cytotechnologist position; cytotechnology schools; cytotec misoprostol; cytotec; cytotec; cytotec abortion; cytotec; cytotec; cytotec; cytotec es que; cytotechnologist jobs; cytotechnologist jobs; cytotec; cytotec 30 pills; cytotec; cytotec; cytotec induction; cytotec; cytotec; cytotec online; cytotechnology; cytotechnology history; misoprostol,
; cytotechnology schools; buy cytotec; cytotec 200mg; cytotec and rectal bleeding; cytotec 200 mg; cytotechnologist jobs; cytotech; buy cytotec; cytotec; cytotec effects side; cytotechnology; cytotec; cytotechnology; buy cytotec; buy cytotec; cytotec 100mg; cytotechnology salary; cytotec; cytotec 100 mg; cytotec; buy cytotec; cytotechnology history; cytotec; cytotec; order cytotec; order cytotec; cytotec 200mg; cytotec online; cytotec induction of labor; cytotechnology schools; cytotec; cheap cytotec; cytotec misoprostol; cytotechnology job; cytotec 30 pills; cytotec abortion; buy cytotec; cytotec; cytotec use; cytotechnology; cytotec; cytotec; buy cytotec; cytotec abortion; cytotechnologist; cytotec use; cytotec 100 mg;
作者 beauty — 04 07 2009, 05:12
east; cytotec 100 mg; cytotechnology hospital job; buy cytotec online; cytotec online; order cytotec; cytotechnologist jobs; how to use cytotec for an abortion; cytotec abortion; cytotechnology full hospital in in job time us; cytotec use; cheap cytotec; cytotechnologist salary; abortion cytotec; cytotec; abortion cytotec risk; cytotechnologist; cytotec; cytotec demise fetal; aborto con cytotec; cytotec induction of labor; abortion cytotec risk; cytotec effects side; buy cytotec online; cytotec; cytotec abortion; misoprostol; cytotec abortion; 6 cytotec in month pregnancy; cheap cytotec; cytotechnologist position; buy cytotec; cytotech; como usar cytotec; cytotec es que; cytotechnologist; cytotechnologist position; brasilia cytotec; cytotec 200 mg; cytotechnology hospital job; cytotechnology schools; cytotec es que; cytotec 200mg; cytotechnologist salary; cytotechnologist jobs; cytotechnology; buy cytotec online; cytotec; cytotechnology jobs; cytotec abortion; cytotech; cytotec abortion; cytotec; cytotec miscarriage; cytotec 100 mg; cytotec 30 pills; cytotec; 6 cytotec in month pregnancy;
作者 family — 04 07 2009, 06:46
blow; cytotec; buy cytotec; cytotechnology hospital job; cytotechnology program; cytotec; the manual of cytotechnology; cytotec; cytotec; cytotec abortion; cytotec; aborto con cytotec; cytotec induction; cytotec; cytotec 100 mg; 6 cytotec in month pregnancy; cytotec online; cytotechnology jobs; cytotechnology job; cytotec; order cytotec; cytotech; cytotechnology salary; cytotec induction; cytotechnologist position; cytotec induction of labor; cytotec miscarriage; cytotec; cytotec and rectal bleeding; cytotec; cytotechnologist position; cytotec abortion; cytotechnologist jobs; cytotec; cytotec effects side; cytotec; cytotec; buy cytotec; pastillas cytotec; cytotec abortion; cytotechnology; abortion cytotec; cytotec; vendo cytotec; cytotec 30 pills; cytotechnologist; cytotec misoprostol;
作者 office — 04 07 2009, 08:19
segment; cytotechnologist; cytotec; como usar cytotec; cytotec 100mg; cytotec use; buy cytotec; cytotechnologist; order cytotec; brasilia cytotec; cytotec; cytotec; como usar cytotec; cytotechnology program; cytotec; cytotec induction of labor; cytotec 100mg; cytotechnologists; cytotec 200mg; cytotec induction labor; cytotec 100mg; cytotechnologist; cytotec; order cytotec; order cytotec; cytotechnology program; cytotech; cytotechnology hospital job; cytotec; cytotechnology salary; cytotec use; cytotec; cytotechnology hospital job; abortion cytotec; abortion cytotec; buy cytotec; buy cytotec; buy cytotec; cytotechnologist; cytotech; buy cytotec online; how to use cytotec for an abortion; cytotec medicine; cytotec induction; misoprostol,
; cytotechnology hospital in in job ny state; cytotec; cytotec online; cytotec mexico; cytotechnologists; cytotechnology hospital job; cytotec induction; cytotec 100mg; how to use cytotec for an abortion; buy cytotec; cytotec use; cytotechnologist in jersey job new new york; order cytotec; cytotechnologists; buy cytotec online; vendo cytotec; cytotec; cytotechnologist position; brasilia cytotec; cytotec; cytotec effects side; cytotechnologist jobs;
作者 each — 04 07 2009, 09:54
crop; cytotechnology salary; cytotechnologist in jersey job new new york; cytotechnologists; cytotec medicine; cytotechnology jobs; como usar cytotec; cytotec; cytotechnology job; order cytotec; cytotec 200 mg; cytotechnologist salary; the manual of cytotechnology; cytotechnologist salary; cytotechnology hospital in in job ny state; cytotec mexico; cytotechnology job; cytotechnology; cytotec online; cytotec abortion; cytotec 30 pills; cytotechnology jobs; cytotec medicine; cytotechnologist jobs; cytotechnologist salary; cytotechnology history; cytotechnology salary; cytotec; cytotec; cytotec online; cytotec misoprostol; cytotec; cytotechnology history; cytotechnology program; cytotec induction of labor; cytotechnologist; cytotec mexico; how to use cytotec for an abortion; cytotechnologist salary; cytotec effects side; cheap cytotec;
作者 condition — 04 07 2009, 11:28
tail; cialis blood supply; viagra q a; affordable cialis; viagra metabolism; generic propecia india; viagra pills low price; buy viagra zenegra; other thigns besides viagra; buy acomplia cheap; problems with taking cialis and propecia; comparison cialis levitra viagra; viagra 2007 hmo california; viagra and ethics; which is better cialis levitra viagra; levaquin and motrin; buy zithromax tablets online; how to get viagra online; viagra and dizziness; propecia ups shipping; viagra usage dosage; reegalis cialis; viagra consult online; buy viagra online australia; viagra test results; propecia finasteride 1mg; viagra overnigh; 36 levitra overseas 52; cipro and gonorrhea; viagra generika; get viagra in person; facts about viagra; cialis pills coupon; pharmacy viagra online; phone orders viagra soft tabs; citrate meltabs and viagra; generic cipro rx 710; acomplia purchase; is acomplia as good as phentermine?; zithromax online doctor; sialis viagra; hemodynamics viagra; viagra with out prescription; cialis tadalafil 20mg; edinburgh viagra; shawala levitra; viagra order home page; levaquin diverticulitis; cialis pill splitting; viagra for sale in usa; cialis viagra online; dizziness with cipro; cheap gerneric viagra; primer plan socialista 2007 - 2013; cialis pharmacy; cialis prices; how do i get some viagra; viagra order online without prescription; cheap drug drug levitra propecia; overnight delivery cheap cialis; erythromycin +viagra; zithromax refund; erection viagra; viagra in malaysia; levitra side affects; ciprofloxacin joint pain; independent viagra; mixing viagra and; where can i buy levitra online; ask doctor about viagra; list of generic viagra non pescription; viagra soft 100mg pills; viagra facts price;
作者 path — 04 07 2009, 12:59
work; cialis mex; viagra partners; cheap pharmacy viagra; viagra phone; propecia rx; levitra drug indication; additional benefits of viagra; levitra 2b online 2b; buy cialis re; buying viagra in tijuana; cheap viagra pills generic; compounded viagra; viagra propecia buy online; viagra online fda; testimony viagra; ciprofloxacin uses alcohol; reliable online pharmacies viagra; viagra drug zenegra; cipro headache forum; purchase generic cialis pills online; rash viagra; viagra and nitrous oxide; us pharmacy viagra brand name online; zithromax drug reactions; hair loss propecia rogain; sildenafil cialis; 1cheap cialis online; best deal for levitra; cialis pills gwen travis; names of viagra in india; j 3generic meltabs viagra; canadian drug viagra; get viagra drug online; viagra+alpha blocker; how to take acomplia; 1 5mg propecia; nhs propecia; order generic levitra; viagra enhancement; levaquin joint aches; what viagra does to the penis; buying cheap viagra; cipro medicine; how to take viagra pills; low cost pharmacy and propecia; generic prescription viagra without; where to buy cialis online reputable; generic viagra 50mg; discount viagra christmas discounts; viagra not needed; viagra cap hat shirt; approved buy cialis fda genuine; zithromax stomach pain take protonix; ed tabs viagra; levitra no; cost of viagra covered by insurance; viagra lawsuits texas; 25mg blue generic pill viagra; 8 generic cialis softtabs; viagra and light sensitivity; viagra and for sale and strongest,
; zithromax and diarrhea; levitra ar viagra; generic viagra next day delivery; viagra online buy brand generic; viagra affects me; levitra new; best price on pfizer viagra; pharmacy for cipro; levitra ordering; generic cialis overnight cheapest; viagra borderline blood pressure; generic viagra online prescription; cialis online buy cialis without prescription;
作者 indicate — 04 07 2009, 14:20
mark; levitra without a; cialis viagra viagra viagra; normal viagra dosage; viagra+online,
; viagra 35008; does alcohol effect ciprofloxacin; acomplia, rimonabant; cialis specs; keyword viagra sale; rimonabant price; fans of viagra; compare zenerx with viagra; levitra and losing vision; 100mg viagra no consultation; viagra 100 mg tab pfizer; inexpensive precription viagra; 1what is cialis; acomplia package insert; age viagra; why buy brand-name zithromax; is viagra available in hong kong; codeine viagra erection priapism; viagra suppliers database; expired cipro; order viagra online cheap; zithromax working body; cialis and pleurisy; premium generic viagra; genuine ham percussor reflex viagra; reputable online pharmacy viagra; online viagra to buy; pharmacy online viagra prozac; levitra levitra dangers; viagra blocker; viagra at a low price;
作者 except — 04 07 2009, 15:42