Home » SQL & PL/SQL » SQL & PL/SQL » Trying to run procedure from sqlplus (getting errors with varchar2)
Trying to run procedure from sqlplus (getting errors with varchar2) [message #158291] |
Thu, 09 February 2006 14:37  |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
I'm trying to run a procedure but it is giving me errors with varchar2. It's really strange. (I am working with 10g)
1 declare
2 in1 number := 5555;
3 in2 number := 1;
4 io1 number;
5 io2 number;
6 io3 varchar2;
7 io4 varchar2;
8 io5 number;
9 io6 varchar2;
10 io7 varchar2;
11 io8 varchar2;
12 io9 number;
13 io10 date;
14 io11 date;
15 begin
16 select_site_content_(in1,in2,io1,io2,io3,io4,io5,io6,io7,io8,io9,io10,io11,io12);
17* end;
My table consists of appropiate numbers and date columns and 5 varchar2(2000 columns) and 1 varchar2(4000) column.
It gives me the following erros when I try to run the above script.
ERROR at line 1:
ORA-06550: line 6, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 7, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 9, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 10, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 11, column 5:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 16, column 84:
PLS-00201: identifier 'IO12' must be declared
ORA-06550: line 16, column 1:
PL/SQL: Statement ignored
If I change my varchar2 to a clob in my script to runa procedure than I don't get those messages?
I shouldn't need to use clob, right?
What am I doing wrong?
|
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158300 is a reply to message #158291] |
Thu, 09 February 2006 15:24   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
I needed to declare (n) for the varchar2's and the missing io12.
declare
in1 number := 2101;
in2 number := 1;
io1 number;
io2 number;
io3 varchar2(2000);
io4 varchar2(4000);
io5 number;
io6 varchar2(2000);
io7 varchar2(2000);
io8 varchar2(2000);
io9 number;
io10 number;
io11 date;
io12 date;
begin
select_intranet_homepage_dtl(in1,in2,io1,io2,io3,io4,io5,io6,io7,io8,io9,io10,io11,io12);
end;
Now for the real problem i am having :
ORA-06502: PL/SQL: numeric or value error: host bind array too small ORA-06512: at line 1
Is my result form running my script above and is exactly the ewrror the client is is gettign too.
I have been looking high and low on the internet, ask tom and what about a problem that I am having with a recent migration from 8.7.1 to 10gr2.
I have pinpointed the exact problem to be directly linked to the o_text column below ( it is the only varchar2(4000). For some reason the dbms_output is maxed at 2000 bytes ?
I'm not sure why or how I cna change it....do I have to set it in the procedure or actually have the dba change a coniguration?
Please note the numeric and date values are truly fine, I have tested everything...the only issue is that one column that has over 2K.
Here is my code , and I humbly thank you for any help you can provide before I pull my hair out lol, it's been three days and i haven't been able to make progress on this issue
The client is running an asp page and calling the procedure
CREATE OR REPLACE PROCEDURE select_site_content_
(i_document_header_id in document.document_header_id%type
,i_interface_code in document.interface_code%type
,o_document_header_id out document.document_header_id%type
,o_interface_code out document.interface_code%type
,o_document_title out document.document_title%type
,o_text out document.text%type
,o_port_sub_type_code out document.portal_sub_type_code%type
,o_media_caption out document_media.media_caption%type
,o_picture_filename out media.filename%type
,o_URL_filename out media.filename%type
,o_urgency_type_code out document_publishing.urgency_type_code%type
,o_priority_type_code out document_publishing.priority_type_code%type
,o_date_start out publishing_schedule.date_start%type
,o_date_end out publishing_schedule.date_end%type)
is
begin
select doc.document_header_id
,doc.interface_code
,doc.document_title
,doc.text
,doc.portal_sub_type_code
,dm1.media_caption
,m_picture.filename
,m_url.filename
,dp.urgency_type_code
,dp.priority_type_code
,ps.date_start
,ps.date_end
into o_document_header_id
,o_interface_code
,o_document_title
,o_text
,o_port_sub_type_code
,o_media_caption
,o_picture_filename
,o_URL_filename
,o_urgency_type_code
,o_priority_type_code
,o_date_start
,o_date_end
from document doc
,document_media dm1
,document_media dm2
,media m_picture
,media m_url
,document_publishing dp
,publishing_schedule ps
where doc.document_header_id = i_document_header_id
and doc.interface_code = i_interface_code
and doc.document_id = i_interface_code
and doc.document_header_id = dm1.document_header_id(+)
and doc.document_id = dm1.document_id(+)
and doc.document_header_id = dm2.document_header_id(+)
and doc.document_id = dm2.document_id(+)
and dm1.media_id = m_picture.media_id(+)
and m_picture.media_type_code(+) = 10 -- Picture
and m_picture.source_type_code(+) = 20
and dm2.media_id = m_url.media_id(+)
and m_url.media_type_code(+) = 30 -- Redirection/URL Link - External
and m_url.source_type_code(+) = 20
and doc.document_header_id = dp.document_header_id
and dp.document_header_id = ps.document_header_id
and dp.publish_id = ps.publish_id
and rownum < 2;
dbms_output.put_line (o_text);
end select_site_content_;
/
[Updated on: Fri, 10 February 2006 09:25] Report message to a moderator
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158319 is a reply to message #158291] |
Thu, 09 February 2006 21:57   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
You mean I put it in the procedure itself?
Like something like this?
SET SERVEROUTPUT ON (2000)
dbms_output.put_line (o_text);
I tried that but gave me errors
SET SERVEROUT[PUT] {ON|OFF} [SIZE n] [FOR[MAT] {WRA[PPED]|WOR[D]WRAPPED]|TRU[NCATED]}]
I guess I got to put (on) (2000) but what about format , wrappped, wrd amd tru? are they default variables for those or should I use something conisten?
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158400 is a reply to message #158344] |
Fri, 10 February 2006 10:01   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
scottwmackey wrote on Fri, 10 February 2006 01:34 | SET SERVEROUTPUT ON SIZE 1000000
|
It loads with errors (is doesn't like the set server output in the procedure.
66 and rownum < 2;
67
68 SET SERVEROUTPUT ON SIZE 1000000
69
70 dbms_output.put_line (o_text);
71
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE select_site_content_;:
LINE/COL ERROR
-------- -----------------------------------------------------------------
68/3 PL/SQL: SQL Statement ignored
68/7 PL/SQL: ORA-00922: missing or invalid option
Am I not putting it in the right place?
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158403 is a reply to message #158402] |
Fri, 10 February 2006 10:34   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
All indications from my tests show that the Varchar2(4000) is the problem...
I went back to my procedure and ran the test without the o_text but using the document_title..
my result
SQL> @test
20 /
Swimming and Beaches
PL/SQL procedure successfully completed.
So it works fine except I'm trying to query a column in my oracle table that has 4000 bytes. And for some reason it doesn't like it.
Any columns 2000 and under works fine...can this be some sort of bug?
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158412 is a reply to message #158403] |
Fri, 10 February 2006 12:03   |
scottwmackey
Messages: 515 Registered: March 2005
|
Senior Member |
|
|
Arrgh. I'm sorry. I neglected to actually read your code and focused on what you thought you needed. Your problem is not that the dbms buffer is too small. Your problem is that you are trying to pass too large a string to dbms_output.put_line. The limit is 255 characters. You need to include something like this "log" procedure. With regard to SET SERVEROUTPUT..., it is a SQL+ command and cannot be included inside the procedure. You issue the command before you execute the procedure.
CREATE OR REPLACE PROCEDURE select_site_content_(i_document_header_id IN document.document_header_id%TYPE,
i_interface_code IN document.interface_code%TYPE,
o_document_header_id OUT document.document_header_id%TYPE,
o_interface_code OUT document.interface_code%TYPE,
o_document_title OUT document.document_title%TYPE,
o_text OUT document.text%TYPE,
o_port_sub_type_code OUT document.portal_sub_type_code%TYPE,
o_media_caption OUT document_media.media_caption%TYPE,
o_picture_filename OUT media.filename%TYPE,
o_url_filename OUT media.filename%TYPE,
o_urgency_type_code OUT document_publishing.urgency_type_code%TYPE,
o_priority_type_code OUT document_publishing.priority_type_code%TYPE,
o_date_start OUT publishing_schedule.date_start%TYPE,
o_date_end OUT publishing_schedule.date_end%TYPE) IS
PROCEDURE log(iMessage VARCHAR2)
IS
vMaxLength NUMBER := 200;
vSpace NUMBER;
vMessage VARCHAR2(32000) := iMessage;
BEGIN
LOOP
EXIT WHEN vMessage IS NULL;
vSpace := instr(vMessage, ' ', vMaxLength);
IF vSpace = 0 THEN
vSpace := vMaxLength + 1;
END IF;
dbms_output.put_line(vMessage, 1, vSpace - 1);
vMessage := substr(vMessage, vSpace);
END LOOP;
END log;
BEGIN
SELECT doc.document_header_id,
doc.interface_code,
doc.document_title,
doc.text,
doc.portal_sub_type_code,
dm1.media_caption,
m_picture.filename,
m_url.filename,
dp.urgency_type_code,
dp.priority_type_code,
ps.date_start,
ps.date_end
INTO o_document_header_id,
o_interface_code,
o_document_title,
o_text,
o_port_sub_type_code,
o_media_caption,
o_picture_filename,
o_url_filename,
o_urgency_type_code,
o_priority_type_code,
o_date_start,
o_date_end
FROM document doc,
document_media dm1,
document_media dm2,
media m_picture,
media m_url,
document_publishing dp,
publishing_schedule ps
WHERE doc.document_header_id = i_document_header_id
AND doc.interface_code = i_interface_code
AND doc.document_id = i_interface_code
AND doc.document_header_id = dm1.document_header_id(+)
AND doc.document_id = dm1.document_id(+)
AND doc.document_header_id = dm2.document_header_id(+)
AND doc.document_id = dm2.document_id(+)
AND dm1.media_id = m_picture.media_id(+)
AND m_picture.media_type_code(+) = 10 -- Picture
AND m_picture.source_type_code(+) = 20
AND dm2.media_id = m_url.media_id(+)
AND m_url.media_type_code(+) = 30 -- Redirection/URL Link - External
AND m_url.source_type_code(+) = 20
AND doc.document_header_id = dp.document_header_id
AND dp.document_header_id = ps.document_header_id
AND dp.publish_id = ps.publish_id
AND rownum < 2;
--
log(o_text);
END select_site_content_;
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158414 is a reply to message #158412] |
Fri, 10 February 2006 12:34   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
Thank you for the ideas scott, I'm printing it up now and will try to implement the concept...I'm hoping I can get it to work.
A couple of questions, wondering if you may know
1) It sounds like the set server ouput may never have been a problem, but just out of curiosity....if I should still need to set it, since this procedure is stored and being called by an asp page, how would I issue the server output command?
2) Back to your recognition that the dbms buffer is too small , Do you have any idea why my code would work fine in Oracle version 8.171 and then all of a sudden not work in 10g-r2?
It was only after our migration that this became a problem. This code has existed and worked for several years.
Thanks again Scott, you have been very helpful and I'm grateful.
[Updated on: Fri, 10 February 2006 12:42] Report message to a moderator
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158421 is a reply to message #158291] |
Fri, 10 February 2006 13:40   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
I tried it but it doesn't like this line
dbms_output.put_line(vMessage, 1, vSpace - 1);
LINE/COL ERROR
-------- -----------------------------------------------------------------
29/7 PL/SQL: Statement ignored
29/7 PLS-00306: wrong number or types of arguments in call to
'PUT_LINE'
I'm guessing that I may need pipes || to combine the arguments...
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158424 is a reply to message #158291] |
Fri, 10 February 2006 14:30   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
Ah ok that makes sense, I wasn't sure about the other arguments.
My procedure loaded succesfully when I implemented your suggestions, however it still gives me the same error, I was expectign to see my 3300 chracters from the o_text.
SQL> SET SERVEROUTPUT ON SIZE 100000
SQL> @test
20 /
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
PL/SQL procedure successfully completed.
[Updated on: Fri, 10 February 2006 14:31] Report message to a moderator
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158640 is a reply to message #158426] |
Mon, 13 February 2006 13:05   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
Thanks alot Scott.
I managed to get this to work in my test.
Now I need to think about applying this logic within my package.
I worked on this morning and can't think of a simple way to go about it.
Can I ask you for some suggestions?
You see my dbm_output_line from my original code was placed there so I can run the test itself , through my research I learned that the dbms_output_line is soemthing that runs
in the background when you have asp scrip calling your procedure.
Therefore my questions are :
1) Since I am dealing with a package with abotu 12 procedures, should I take the new procedure you wrote and make it's own procedure....then simply call it from whatever points I need to in the various parts of the package?
2)Can I replace the dbms_output.put_line(substr(vMessage, 1, vSpace - 1));, with (substr(o_text, 1, vSpace - 1)); since I'm not outlining the dbms_output.put_line specifically and the package/procedure is doing that already?
[Updated on: Mon, 13 February 2006 13:48] Report message to a moderator
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158644 is a reply to message #158643] |
Mon, 13 February 2006 13:47   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
the original procedure (attached below)actually is excluding that one dbms_output.put_line (o_text);....which I put in to try to track and debug why I was getting those errors.
the solution you gave me applies to making the dbms_out.put_line for the o_text variable which has 4000 characters...but since the actual procedure doesn't use that dbms_output.put_line, I'm assuming my error was simply happening directly with o_text.
so can I apply that solution to o_text in some way?
------------------------------------------------------------
CREATE OR REPLACE PROCEDURE select_site_content_
(i_document_header_id in document.document_header_id%type
,i_interface_code in document.interface_code%type
,o_document_header_id out document.document_header_id%type
,o_interface_code out document.interface_code%type
,o_document_title out document.document_title%type
,o_text out document.text%type
,o_port_sub_type_code out document.portal_sub_type_code%type
,o_media_caption out document_media.media_caption%type
,o_picture_filename out media.filename%type
,o_URL_filename out media.filename%type
,o_urgency_type_code out document_publishing.urgency_type_code%type
,o_priority_type_code out document_publishing.priority_type_code%type
,o_date_start out publishing_schedule.date_start%type
,o_date_end out publishing_schedule.date_end%type)
is
begin
select doc.document_header_id
,doc.interface_code
,doc.document_title
,doc.text
,doc.portal_sub_type_code
,dm1.media_caption
,m_picture.filename
,m_url.filename
,dp.urgency_type_code
,dp.priority_type_code
,ps.date_start
,ps.date_end
into o_document_header_id
,o_interface_code
,o_document_title
,o_text
,o_port_sub_type_code
,o_media_caption
,o_picture_filename
,o_URL_filename
,o_urgency_type_code
,o_priority_type_code
,o_date_start
,o_date_end
from document doc
,document_media dm1
,document_media dm2
,media m_picture
,media m_url
,document_publishing dp
,publishing_schedule ps
where doc.document_header_id = i_document_header_id
and doc.interface_code = i_interface_code
and doc.document_id = i_interface_code
and doc.document_header_id = dm1.document_header_id(+)
and doc.document_id = dm1.document_id(+)
and doc.document_header_id = dm2.document_header_id(+)
and doc.document_id = dm2.document_id(+)
and dm1.media_id = m_picture.media_id(+)
and m_picture.media_type_code(+) = 10 -- Picture
and m_picture.source_type_code(+) = 20
and dm2.media_id = m_url.media_id(+)
and m_url.media_type_code(+) = 30 -- Redirection/URL Link - External
and m_url.source_type_code(+) = 20
and doc.document_header_id = dp.document_header_id
and dp.document_header_id = ps.document_header_id
and dp.publish_id = ps.publish_id
and rownum < 2;
end select_site_content_;
/
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158656 is a reply to message #158644] |
Mon, 13 February 2006 16:05   |
scottwmackey
Messages: 515 Registered: March 2005
|
Senior Member |
|
|
I could be wrong here, but I think you are running into a problem of changing too many variables between tests. Unless something changed, it seems you had a block of code that defined some variables and called a procedure. That block failed. You assumed it had something to do with the procedure and you altered the procedure to print (dbms_output) a variable from within the procedure. It still didn't work. You posted on this site for help. mchadder pointed out that you defined the variables in your PL/SQL block incorrectly. That, most likely, would have solved your problem had you not altered the procedure with the dbms_output. But you did, and now that it actually made it to the point where it executed the procedure, it raised a different error. If you don't need the dbms_output, just remove it from the procedure and you don't need the little procedure I gave you because nothing will be calling it. If you want to see the values that are passed back from the procedure, there are other ways to do that in SQL+.
SQL> CREATE OR REPLACE PROCEDURE test_proc(p1 IN VARCHAR2,
2 p2 OUT VARCHAR2)
3 IS
4 BEGIN
5 p2 := p1;
6 END;
7 /
Procedure created.
SQL> var x2 varchar2(200);
SQL> exec test_proc('Hello World', :x2);
PL/SQL procedure successfully completed.
SQL> print x2
X2
----------------------------------------------------------------
Hello World
SQL>
If you still want to use dbms_output to print the value that you got from the procedure, you could define the log procedure I gave you as a stand-alone procedure or include it in a package (the package is usually better if you have something that is appropriate like a utilities package) and then call it after the call to the procedure.
DECLARE
x VARCHAR2(2000);
BEGIN
test_proc('Hello World', x);
log(x);
END;
Either way, I would not alter the original procedure. It was, most likely, fine all along. Finally, make sure you are only changing one thing at a time when testing.
|
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158835 is a reply to message #158830] |
Tue, 14 February 2006 11:42   |
scottwmackey
Messages: 515 Registered: March 2005
|
Senior Member |
|
|
Tony,
If I came across as harsh or critical in my previous post, I am sorry. That certainly wasn't my intention. I was just trying to work with you to get through this problem. But back to the problem. Your attempt to run the procedure within in PL/SQL block is the right way to go. My only suggestion is that, going forward, you assume that any PL/SQL procedure that works on 8 will work on 10. If you call a procedure from a block and it doesn't work, the problem is very likely with the way you called it. Don't even think about changing the procedure until you have at least executed it once successfully from within the block. So, did you call the original procedure from within the block without trying to display any output? Just make sure it runs. If it does, and my guess is it will, then you can think about how to display any results you get back from the procedure. My guess is that the problem lies somewhere else, like the interface between ASP and Oracle. But you do have to eliminate the possibility that the procedure doesn't run. If you can call it from SQL+ as you have been trying, then you have eliminated that possibility.
|
|
|
Re: Trying to run procedure from sqlplus (getting errors with varchar2) [message #158848 is a reply to message #158835] |
Tue, 14 February 2006 13:17   |
Tony Grace
Messages: 23 Registered: August 2003
|
Junior Member |
|
|
Scott
No you didn't come accross as harsh at all. I guess I'm just nervous because this problem is quite baffling and a lot of people are stressed over it. Being new I think if someone more experienced were to look at this , they can find a solution quicker.
I think your right.
When I call the procedure from the block without the dbms_output it says it runs succesfully but of course I don't see the results.
In the case with calling the case from the block with dbms_output I got the error, same as asp.
I have tested the odbc and I was able to pull the full string into a crystal report. (just a theory to test the odbc)
But maybe there is more, I'm also not convinced the right solution is changing the code from either the procedure or the asp since it worked fine in 8i.
I talked to my dba about the nls_lang configuration and he was pretty convinced there was no problem with that at all, since a configuration problem would result in a problem with all applications.
So the answer is yes the procedure does in fact run.
[Updated on: Tue, 14 February 2006 13:19] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Tue Aug 19 15:59:34 CDT 2025
|