How To Use String Buffer Instead Of String Query
May 9, 2008show an ex to use string buffer for select statemnt
View 1 Repliesshow an ex to use string buffer for select statemnt
View 1 RepliesI'm trying to create a table with a select statement. I want to populate this new table with the aggregated value from a VIEW. Following is the code used for creating the VIEW,
create or replace view FINAL_WEB_LOG
as
select SESSION_ID,
SESSION_DT,
C_IP,
CS_USER_AGENT,
tab_to_string(CAST(COLLECT(web_link) AS t_varchar2_tab)) WEBLINKS
from web_views_tab
group by C_IP, CS_USER_AGENT, SESSION_DT;
I want to create a table with WEBLINKS and SESSION_ID which is a sequence from another table.
CREATE TABLE FINAL_WEB
AS
SELECT weblinks
FROM final_web_log
UNION
SELECT session_id
FROM WEB_VIEWS_TAB;
This now gives me the following error,
SQL Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
This has to do with the field, Weblinks, it does have longer values.
I have researched this problem and checked my variable sizes over and over again. I have tested the procedure within the Oracle Express environment and it works fine; HOWEVER, when the procedure is called from my C# app it produces the ORA-06502 error.
The stored procedure signature looks like this...
Original - SQL Code
create or replace save_new_project (p_custorgid in number,
p_title in varchar2,
p_AOIName in varchar2,
p_description in varchar2,
p_receiveddate in date,
p_deadlinedate in date,
p_startdate in date,
[code]....
The OracleParameter in my C# app for the last out param is defined as such...
cmd.Parameters.Add(new OracleParameter("p_statustypedescrip", OracleDbType.Varchar2, 30, ParameterDirection.Output));
As I said at the beginning of this post, the procedure works fine in the Oracle environment. So why is it not working by simply calling it from C#? I've tried changing the OracleDbType to CLOB which eliminates the error but it returns a bizarre result. It returns this string, "Oracle.DataAccess.Types.OracleClob".
Since CLOB doesn't really work either I switch back to Varchar2 and specify a size of 5000 (in the database the field I am querying is defined as Varchar(30)). I still get the ORA-06502 error.
I am clueless as to what the problem is. It should work and it does if I run a series of SQL statements in an Oracle SQL Command window. The test that works fine looks like this...
Original - SQL Code
declare
v_projid projects.projectid%type;
v_statustypedescrip projectstatustypes.type%type; /* this is a varchar(30) */
begin
save_new_project(2, 'Some input text goes here', 'More input text', 'And more again','26-APR-2007','26-APR-2007','26-APR-2007','26-APR-2007','users name as inpujt text
[code]....
But calling save_new_project from C# throws ORA-06502. It identifies line 40 of my stored procedure. This is line 40...
Original - SQL Code
p_statustypedescrip := v_statustypedescrip;
p_statustypedescrip := v_statustypedescrip;
when I want to create a table.When I run my procedure I received :
PL/SQL: numeric or value error: character string buffer too small
create or replace PROCEDURE p_create_tmp_tables (p_result OUT NUMBER ) IS
string_sql varchar2(1000);
result NUMBER;
BEGIN
string_sql := 'CREATE TABLE TMP_CATEGORIES (CODE_CATEGORY NUMBER(6,0), NAME_CATEGORY VARCHAR2(25 BYTE))';
execute immediate string_sql;
[code]...
I am trying to execute this
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('');
[code]....
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.
Actually I am getting the following error while running my script.
Error:(Error): ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 9
Seems to be getting eror in the following line but not sure why its coming."select adary.dilution_strategy_seq.NEXTVAL into :dil_strat_seq_new from dual;"
Code snippet:
---------------------------------------------------------------
declare
dil_strat_seq_new NUMBER :=0;
disc_conc_seq_new NUMBER :=0;
disc_fold_seq_new NUMBER :=0;
begin
[code]...
i am getting above error while doing
ORA-06502 numeric or value error: character string buffer too small
ORA-06512 itw_item_add_ch at line 17
CREATE OR REPLACE procedure itw_item_add_ch (header_id1 number, folio out varchar2,tariff out varchar2) as
cursor item_add(header_id1 number) is
SELECT
DISTINCT c.attribute4 item_tariff_no,
c.attribute5 item_folio
FROM OE_ORDER_LINES_ALL b,
[code].....
Following are my declarations and query inside my procedure.i am getting "ORA-06502: PL/SQL: numeric or value error: character string buffer too smal" error when i try to execute the procedure
code :
request_owner request.SCC_USER_ID%TYPE := NULL;
receipt_location request.RECEIPT_LOCATION_LKP_ID%TYPE := NULL;
receipt_type request.RECEIPT_TYPE_LKP_ID%TYPE := NULL;
item_id request.ITEM_ID%TYPE := NULL;
[code]...
I am learning pl/sql and this is procedure i had created which got created successfully.then i created two variables name v_name, v_loc with command.
variable v_name varchar2; etc.
and executed procedure like
execute dept_proc2(10, :v_name, :v_loc);
and i am getting the error
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
1 create or replace procedure dept_proc2
2 (v_dno in number, v_name out varchar2, v_loc out varchar2)
3 is
4 cursor dept_cur is select dname, loc from dept
5 where deptno=v_dno;
[code]...
Actually I have an existing table in LOG RAW instead of BLOB. Which stores some transaction XML data. The data is very huge. When i trying with the following, gives me following error
SQL> declare
2 a varchar(255);
3 B LONG RAW;
4 cursor c1 is select xml FROM LOG_tab WHERE ID='13148' ;
5 begin
6 open c1;
7 loop
8 fetch c1 into b ;
[code]....
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 10
Since dbms_output.put_line has buffer limitation.Can we write the result of a select statement into client LOCAL disk files using PL/SQL.
I am getting an error as below
ORA-06502: PL/SQL: numeric or value error: character string buffer too small.
Here is complete code
CREATE OR REPLACE
TYPE MDI.ACCUM_STRING_TYPE2 AS OBJECT (
rvalue VARCHAR2 (32767
STATIC FUNCTION odciaggregateinitialize (sctx IN OUT accum_string_type2)
RETURN NUMBER
[code]...
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 8
I am reexecuting this view:
set serveroutput on buffer 2560000
;
CREATE OR REPLACE VIEW VIEW_TRIP_ASSIGNMENTS
(COMPANY_ID, TRIP_ID, TRIP_STOP_ID, TRIP_CODE, TRIP_NAME,
TRIP_DESC, TRIP_NUMBER, TRIP_START_TIME, TRIP_END_TIME, TRIP_LOADING_TIME,
TRIP_UNLOADING_TIME, FREQUENCY_ID, FREQUENCY_CODE, FREQUENCY_NAME, FREQUENCY_DESC,
FREQUENCY_CODE_NUMBER, CUSTOMER_ID, CUSTOMER_NUMBER, CUSTOMER_NAME, CUSTOMER_DESCRIPTION,
CUSTOMER_TYPE_ID, CUSTOMER_TYPE_NAME, CUSTOMER_TYPE_CODE, DAY_PHONE_NUMBER, EMAIL_ADDRESS,
CONTRACT_ID, CONTRACT_NUMBER, CONTRACT_DESCRIPTION, WORK_LOCATION_ID, ROUTE_ID,
[code]....
before reexecuting above view I was counting the column and was getting below error:
ora-00600 internal error code,arguments:[qctopn1], [],[],[]...
i am generating html format mail from oracle 10g database.
For displaying data into html format, message body data is exceeding more than 32k.
ORA-06502: PL/SQL: numeric or value error:character string buffer too small
i am using long data type for message body data.
Trying to learn and understand Triggers, PL/SQL code, etc. When I execute a simple insert using Toad for Oracle, all is fine. When I try the identical insert in SQL*Plus, it throws error ORA-06502 during execution of the trigger.
Here is the error info:
insert into AAAJOB(PROCEDURENAME,DESCRIPTION) VALUES('OOO','PPP')
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "PMSC0.AAAJOB_TIMING", line 10
ORA-04088: error during execution of trigger 'PMSC0.AAAJOB_TIMING'
===
Here is the table and the trigger:
CREATE TABLE PMSC0.AAAJOB
(
CREATETS TIMESTAMP(0) DEFAULT current_timestamp,
PROCEDURENAME VARCHAR2(100 CHAR),
DESCRIPTION VARCHAR2(100 CHAR),
LASTUPDATEDBY VARCHAR2(9 CHAR)
)
[code]....
The error seems to be on this:
SELECT current_timestamp
INTO :new_row.createTS
I have this error (and solution):
ORA-02085: database link string connects to string
Cause: a database link connected to a database with a different name. The connection is rejected.
Action: create a database link with the same name as the database it connects to, or set global_names=false.
Where should I set global_names=false ?
I'm facing some problem even after using INSTR function in Oracle.The problem is I have written the logic in the PL/SQL block which appends all the values fetched in a loop on the basis of whether the string is present or not.
For ex:
The first value fetched from the select query first is ABCDEFG which gets appended to a variable
The next value fetched is AB even this has to be appended to the variable since this exactly doesn't match with ABCDEFG.
The next value fetched is BCDEF even this has to be appended to the variable since this exactly doesn't match with ABCDEFG.
The third Value fetched is ABCDEFG this will not get appended presently according to the logic which is correct.
writing that piece of code to append the value fetched which doesn't exactly match with the existing string
FUNCTION get_attributed_sedol( p_ref_number IN VARCHAR2,
p_field IN VARCHAR2 )
RETURN VARCHAR2
IS
l_query VARCHAR2(1000);
[code]...
It gives me an error on the line where the execute immediate statement is.
Quote:
ORA-00905
missing keyword
Cause: A required keyword is missing.
Action: Correct the syntax.
But when I check my stack trace table to see what the actual query string looks like, I see this
Quote:
SELECT sedol INTO l_attributed_sedol_code FROM integration.tmp_attributed_sedol WHERE CLIENT_LEDGER_REF='LEAE057090' AND ROWNUM=1
There's nothing wrong with that, is there? It executes fine if I try it manually.
I have a dynamic query which has this clause in it: WHERE [COLUMN NAME] IN (' || theString || ')
My problem is that theString is being passed in through a C# call and the variable is a bunch of strings concatenated together and separated by a comma. Ex: theString = "'val1','val2'"
How many quotes are supposed to go around val1 and val2?
I've tried the following and none work:
'val1','val2'
''val1','val2''
''val1'',''val2''
'''val1'',''val2'''
''''val1'',''val2''''
When I run the procedure in Oracle it works with '''val1'',''val2'''
Select * from XXX where xxx.a in �123,456�-----> this values comes dynamic to my query.
Here xxx.a will contain values like 123 or 456 like that .
i try to insert Concatenation string to my table,i need that all traps that has 12 length will be insert the new trapnum like this:
for example: 26001005CC45 = 260001005CC0045 ....... 08060027RF05 = 080600027RF0005 ......... and so....
update trap set TrapNum = (
select trim(both from to_char(substr(TrapNum,1,4),'0000'))||
trim(both from to_char(substr(TrapNum,5,1),'00'))||
trim(both from to_char(substr(TrapNum,6,3),'000'))||
substr(TrapNum,9,2)||
trim(both from to_char(substr(TrapNum,11,2),'0000')) from Trap)
where length(Trapnum)=12
but i got error ORA-01427
I am using this query to split numeric values i.e ('1,2,3,4,5,6')but when i am trying with char value i.e ('a,b,c,d'), its not working.
select id
FROM employee e
WHERE e.id IN
( SELECT TO_NUMBER(xt.column_value)
FROM XMLTABLE('1,2,3,4,5,6') xt );
I want to convert a column value to a delimited string using a query.
Example
TableA
Col1 Col2 Col3
1 x200 MIS-X
2 x200 BTS-X
3 x200 TYR-X
4 x100 YRY-X
Select Col3 From TableA where Col2 = 'x200'
Expected Output:
'MIS-X','BTS-X','TYR-X'
How can we get 'space in every character of a string with Single select query'
for example:-
string 'INDIA'
result should be 'I N D I A'
Having following table:
UserID REC_TYP REC_CD
12345 'OFFR' 12
23456 'MSG' 13
I'd like to construct the query which in this particular case would return the REC_CD as 'Record_ID' for REC_TYP='OFFR' where USERID=? (always fetched by the application) and if such USER_ID doesn't exists (for the particular REC_TYP of course) to return string or any other value. e.g. The result for this query in case of user_id 23456 = would be "doesn't exist" or sth for instance 'FALSE' and for 123456 it would be '12'
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
==============================================
SQL> select * from books_cat;
ID CAT QRY
---------- -------------------- --------------------------------------------------
141 Oracle {Oracle} OR {RDBMS}
142 Russia {Russia} OR {Russian}
SQL> select id, file_desc from books;
[code]....
I am learning Oracle Text and created the above routine to check whether Russia/Russian appears in the OracleTextDeveloper.txt file (text version of the standard Oracle documentation - B28303-03).
Some more information: -
DBMS_METADATA.GET_DDL('INDEX','IDCTXR_BOOKS_CAT')
--------------------------------------------------------------------------------
CREATE INDEX "READER"."IDCTXR_BOOKS_CAT" ON "READER"."BOO
KS_CAT" ("QRY")
INDEXTYPE IS "CTXSYS"."CTXRULE"
SQL> select token_text, token_type from dr$idctxr_books_cat$i;
[code]....
A sample query to check whether a string contains 2 upper characters and numbers are present in that character using regular_exp .
View 12 Replies View RelatedI want to write a plsql program to display half part of a string .Example there is a string like gillmadden@myharbour.org.uk
I want to display only the later part of the string
myharbour.org.uk as output.
Can we write using string functions in plslql?
I am trying to search a word which starts with 'FRA' in any columns and any tables.
I am unable to find what is generating a join datasets in the webservice from teh database as it is not apparent within the 100 tables.
I ahve looked into
Re: How to search in all rows and all columns?
Re: SQL Search Query?
but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat a dictionary I can view
select distinct substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from all_cons_columns,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || 'fra'
|| '%'')'
).extract ('ROWSET/ROW/*')
)
) t
order by "Table";
running teh above query got me thsi error:
ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
ORA-06512: at line 1
19202. 00000 - "Error occurred in XML processing%s"
*Cause: An error occurred when processing the XML function
*Action: Check the given error message and fix the appropriate problem
I have a string like below:
string = 'HEADER||MEAL||15'
How to get 'MEAL' string? The length of the string can be various. Means, 'MEAL' can be 'INFLIGHT'. So, i cant use the substr. Is there a function that can recognize the pipeline? so that i can remove all the string before the pipeline and after the pipeline to get the string between the pipeline?
I want to know what exact process happens in oracle architecture when an update query is fired.
View 1 Replies View Related