Output variable value (DBMS_OUTPUT.PUT_LINE)
Hello,
I just started using ORACLE and am learning about PL/SQL. My question is how do you output a variable? I am running the following in an SQL Worksheet, but I can't output the value:
DECLARE
v_Temp VARCHAR2(200);
BEGIN
v_Temp :='help me';
DBMS_OUTPUT.PUT_LINE(v_Temp);
DBMS_OUTPUT.PUT_LINE('Text In Single');
END;
Thanks, sck10
SQL> DECLARE
2 v_Temp VARCHAR2(200);
3
4 BEGIN
5 v_Temp :='help me';
6 DBMS_OUTPUT.PUT_LINE(v_Temp);
7 DBMS_OUTPUT.PUT_LINE('Text In Single');
8 END;
9 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> /
help me
Text In Single
PL/SQL procedure successfully completed.
SQL> Nicolas.
Similar Messages
-
Printing messages in Log File and Output File using Dbms_output.put_line
Hi,
I have a requirement of printing messages in log file and output file using dbms_output.put_line instead of fnd_file.put_line API.
Please let me know how can I achieve this.
I tried using a function to print messages and calling that function in my main package where ever there is fnd_file.put_line. But this approach is not required by the business.
So let me know how I can achieve this functionality.
Regards
SandyWhat is the requirement that doesn't allow you using fnd_file.put_line?
Please see the following links.
https://forums.oracle.com/forums/search.jspa?threadID=&q=Dbms_output.put_line+AND+Log+AND+messages&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=%22dbms_output.put_line+%22+AND+concurrent&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
Please help if anyone knows.
I have an anonymous block that declares a variable as below:
v_return_code varchar2(32767);
I am appending characters that I am building in the begin end block to this variable and at the end printing it out using dbms_output
dbms_output.put_line(v_return_code);
I observe that the output is generated partially when I ran the block through PL/SQL developer SQL window.
My code appends a new line char chr(10) after each new value is appended to the variable.
I have the below settiing in the output window
buffer size: 2000000
Can someone please help why it prints the output partially?
Thanks in advance.
GirishHi Frank,
Thanks for your reply.
I figured out that some other developer in the team had same problem before and he had then written a library function to tokenise the variable into 255 chars and then dbms_output it. So I am good now.
Thanks for coming by and replying though.
Regards,
Girish -
HI all,
please see the following script where the variable length is more than a 100 charecters...
When i run this in sqlplus with SERVEROUTPUT ON, i see the ouput being truncated to 100 charecters.
sql> ed
Wrote file afiedt.buf
1 declare
2 l_var varchar2(400);
3 begin
4 l_var := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh
5 dbms_output.put_line(length(l_var));
6 dbms_output.put_line(l_var);
7* end;
8 /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvI think I am looking for a sqlplus "SET XXXX..." command, but my search has been futile so far.
Please advice.
Thanks,
John.Thanks for your reply .. Frank.
Sorry... I Previewed the post but did not notice my code being truncated in my sqlplus sesssion.
The actual script has the output to 130 charecters. but when i close the edit (afeidt.buf) and execute it, the display only shows 100 charecters...
My SQLPLUS version is 9.2.0.1.
I am using the "WE8ISO8859P1" charecter set.
declare
l_var varchar2(500) := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
begin
dbms_output.put_line(length(l_var));
dbms_output.put_line(l_var);
end;
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv
1 declare
2 l_var varchar2(500) ;
3 begin
4 for i in 1 .. 5 loop
5 l_var := l_var || 'abcdefghijklmnopqrstuvwxyz';
6 end loop;
7 dbms_output.put_line(length(l_var));
8 dbms_output.put_line(l_var);
9* end;
sql> /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -
How to print extract value in dbms_output.put_line
CREATE OR REPLACE PROCEDURE pr_srch_data
AS
xml_data_val xmltype:=null;
vPropertyName clob;
vstr varchar2(1000);
operation varchar2(1000);
vQuery VARCHAR2(4000):=NULL;
vQry VARCHAR2(4000):=NULL;
vPartyid VARCHAR2(2000):=NULL;
vPerson varchar2(4000);
BEGIN
FOR I IN (SELECT EAPP_XML_DATA
FROM binary_xml
WHERE extractvalue(eapp_xml_data,'/OLifE/Party[@id="Party1"]/Person/LastName') Like 'Rajesh%'
LOOP
BEGIN
SELECT extractvalue(value(t),'/Relation/@RelatedObjectID')
INTO vPartyid
FROM TABLE (XMLSEQUENCE (EXTRACT (xml_data_val,'/OLifE/Relation'))) t
WHERE extractvalue(value(t),'/Relation/RelationRoleCode')='Owner'
AND existsnode(value(t),'/Relation/@RelatedObjectID')=1 ;
END;
SELECT extract(value(t),'/OLifE/Party[@id='''||vPartyid ||''']/Person')
INTO vPerson
FROM TABLE (XMLSEQUENCE (EXTRACT (I.EAPP_XML_DATA,'/OLifE')))t;
dbms_output.put_line('vPerson'||'--'||vPerson);
END LOOP;
END;
But when i am printing vPerson i am getting error. I need to print that extract value.Things to remember (that you should know by now)
Please remind us of which version of 11g you are using in this post and all future posts.
Look at the FAQ under your sign-in name to see how to use the tag to retain formatting of your code as you have seen our examples to you look like.
We can't see your screen or your data so how about the error message and some data from your table?
Please start using either XMLTable or XMLCast/XMLQuery as odie_63 as shown you.
What are you trying to do? -
Viewing Bind variable values in TKPROF output
DB Version:10gR2
After tracing a Stored proc , i can see the bind variable values in the raw trace file. But the TKPROF output of this trace file doesn't show Bind variable values. Is there a way i could see Bind variable values in TKPROF output?I guess when you think about it, TKPROF is primarily intended to aggregate and summarise repeated SQLs and related statistics from raw trace files. While waits can reasonably be aggregated over multiple exeuctions of the same SQL, bind variables are explicitly associated with individual executions of an SQL and hence cannot be aggregated in the same fashion.
-
Output from dbms_output.put_line splits and move to next line
Hi All,
I am printing out a list using dbms_output.put_line its like
One or more of following Required Parameters are missing:
1. Primary Field
2. Structure Field
3. Structure
Table
4. List File Name
5. Query Directory
6. Query String
but I don't know why third option is splitting and moving to second line. any idea? its not that long even then.
thanksset linesize 150
or set it as per your requirement -
Problem in dbms_output.put_line boolean variable
hello guys m practicing PL/SQL when i try to exicute below code i get following error:
DECLARE
I BOOLEAN:=TRUE;
BEGIN
dbms_output.put_line(i);
END;
error:
Error starting at line 1 in command:
DECLARE
I BOOLEAN:=TRUE;
BEGIN
dbms_output.put_line(i);
END;
Error report:
ORA-06550: line 4, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:user13355933 wrote:
hello guys m practicing PL/SQL when i try to exicute below code i get following error:
DECLARE
I BOOLEAN:=TRUE;
BEGIN
dbms_output.put_line(i);
END;
error:
Error starting at line 1 in command:
DECLARE
I BOOLEAN:=TRUE;
BEGIN
dbms_output.put_line(i);
END;
Error report:
ORA-06550: line 4, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:DBMS_OUTPUT.PUT_LINE only accepts strings (VARCHAR2) datatype
what exactly do you expect to see, if in fact it worked as desired? -
Using a variable value in CDATA for generating an XML type in Oracle
Hello,
I have prepared a function given below where I have some input variables & I have to generate one XML with those input variables as tag attribute value:
create or replace function NEW_PROJECT_DETAILS
( p_ReferenceId in varchar2 ,
p_Project_No in varchar2,
p_Project_Name in varchar2,
p_Project_Desc in varchar2 ,
p_Project_Type in varchar2,
p_Project_Location in varchar2,
p_Project_Status in varchar2 )
return xmltype
as
payload xmltype;
begin
dbms_output.put_line('Payload Started');
payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
<ProjectDetails>
<RefID>'||p_ReferenceId||'</RefID>
<ProjectNo>'||p_Project_No||'</ProjectNo>
<ProjectName>'||p_Project_Name||'</ProjectName>
<ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
<ProjectType>'||p_Project_Type||'</ProjectType>
<ProjectLocation><![CDATA[p_Project_Location]]></ProjectLocation>
/* <ProjectLocation>'||p_Project_Location||'</ProjectLocation> */
<ProjectStatus>'||p_Project_Status||'</ProjectStatus>
</ProjectDetails>');
dbms_output.put_line('Payload Comp1');
return payload;
end;
This procedure works absolutely fine.
Now the problem which I am having is that the variable p_Project_Location has value like "6747:BBO&M SBV".
Due to the '*&*' in that value I have to use CDATA. But i dont know how to pass this variable directly in the CDATA in the XML.
Please help me with this asap.
Thanks & Regards,
Divya Aggarwal
Edited by: 784414 on Dec 2, 2010 4:15 AM
Edited by: 784414 on Dec 2, 2010 4:16 AMHi,
If you absolutely want to use a CDATA section, then :
payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
<ProjectDetails>
<RefID>'||p_ReferenceId||'</RefID>
<ProjectNo>'||p_Project_No||'</ProjectNo>
<ProjectName>'||p_Project_Name||'</ProjectName>
<ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
<ProjectType>'||p_Project_Type||'</ProjectType>
<ProjectLocation><![CDATA['||p_Project_Location||']]></ProjectLocation>
<ProjectStatus>'||p_Project_Status||'</ProjectStatus>
</ProjectDetails>');Alternatively, you can escape non valid characters with DBMS_XMLGEN.CONVERT, e.g. :
payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
<ProjectDetails>
<RefID>'||p_ReferenceId||'</RefID>
<ProjectNo>'||p_Project_No||'</ProjectNo>
<ProjectName>'||p_Project_Name||'</ProjectName>
<ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
<ProjectType>'||p_Project_Type||'</ProjectType>
<ProjectLocation>'||dbms_xmlgen.convert(p_Project_Location)||'</ProjectLocation>
<ProjectStatus>'||p_Project_Status||'</ProjectStatus>
</ProjectDetails>');which outputs :
<?xml version="1.0" encoding="UTF-8"?>
<ProjectDetails>
<RefID>1</RefID>
<ProjectNo>1</ProjectNo>
<ProjectName>PRJ1</ProjectName>
<ProjectDesc>This is project 1</ProjectDesc>
<ProjectType>P</ProjectType>
<ProjectLocation>6747:BBO&M SBV</ProjectLocation>
<ProjectStatus>S</ProjectStatus>
</ProjectDetails>Any basic XML parser should then convert back escaped characters when processing the document.
You can also use SQL/XML functions, which will take care of that automatically.
For example :
SELECT appendChildXML(
XMLType('<?xml version="1.0" encoding="UTF-8"?><ProjectDetails/>'),
XMLForest(
'1' as "RefID",
'1' as "ProjectNo",
'PRJ1' as "ProjectName",
'This is project 1' as "ProjectDesc",
'P' as "ProjectType",
'6747:BBO&M SBV' as "ProjectLocation",
'S' as "ProjectStatus"
FROM dual;or,
SELECT appendChildXML(
XMLType('<?xml version="1.0" encoding="UTF-8"?><ProjectDetails/>'),
XMLForest(
'1' as "RefID",
'1' as "ProjectNo",
'PRJ1' as "ProjectName",
'This is project 1' as "ProjectDesc",
'P' as "ProjectType",
XMLCData('6747:BBO&M SBV') as "ProjectLocation",
'S' as "ProjectStatus"
FROM dual; -
Hello
I will explain the scenario:
In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
My Email-id is : [email protected]
I will expect yor early mail.
With thanks
Pramod kumar.Hello Avi,
I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
drop type rectab;
create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
create or replace type rectab as table of rectype;
create or replace package ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
end ioStructArray;
create or replace package body ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
mdescription varchar2(150);
mpartnum varchar2(30);
mpno varchar2(30);
mdes varchar2(150);
mair varchar2(15);
mstat varchar2(1);
cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
cursor c2 is select partnum from ipc_master where partnum=mpartnum;
cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
cursor c4 is select partnum from superparts where partnum=mpartnum;
cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
mpno1 varchar2(30);
mpno2 varchar2(30);
mpno3 varchar2(30);
mpno4 varchar2(30);
mpno5 varchar2(30);
maircraft_type varchar2(15);
mstat1 varchar2(30);
mstat2 varchar2(30);
mstat3 varchar2(30);
mstat4 varchar2(30);
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
if mpno is not null and mdes is not null and mair is not null then
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
for i in c1 loop
mstat:='N';
mstat1:='N';
mstat2:='N';
mstat3:='N';
mstat4:='N';
mpno1:=i.partnum;
mpartnum:=i.partnum;
mdescription:=i.description;
maircraft_type:=i.aircraft_type;
for j in c2 loop
mpno2:=j.partnum;
end loop;
for k in c3 loop
mpno3:=k.partnum;
end loop;
for l in c4 loop
mpno4:=l.partnum;
end loop;
for m in c5 loop
mpno5:=m.part_no;
end loop;
if mpno2=mpartnum then
mstat1:=mpno2;
end if;
if mpno3=mpartnum then
mstat2:=mpno3;
end if;
if mpno4=mpartnum then
mstat3:=mpno4;
end if;
if mpno5=mpartnum then
mstat4:=mpno5;
end if;
if mpno1=mpartnum then
mstat:='Y';
orec.PartNo:=mpno1;
orec.Description:=mdescription;
orec.AIrcraft_type:=maircraft_type;
orec.status_IPC:=mstat1;
orec.status_ELOG:=mstat2;
orec.status_SUPCAT:=mstat3;
orec.STATUS_AIRODWH:=status_AIRODWH;
end if;
end loop;
end;
end if;
end testsch2;
end ioStructArray;
Expecting your early reply.
With thanks
Pramod kumar. -
Dbms_output.put_line not printing in inner for loop using a parameter
I cannot get the inner loop to print output. I can run both loops independent (hardcoding a value for the inner loop) Any help is apprecicated... Listed is the code
set serveroutput on
DECLARE
cursor ACCNO_CUR is
select accession_number from didb_studies where insert_time > to_date('02-JUN-12');
cursor PATH_CUR (p1_accno VARCHAR2) is
select distinct l.FILE_SYSTEM || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME
, l.image_size
, i.image_need_backup
, i.sop_class_uid
from medistore.didb_studies s
, medistore.didb_raw_images_table i
, medistore.didb_image_locations l
where s.accession_number = 'p1_accno'
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') = 0
UNION
select distinct(l.FILE_SYSTEM) as FULLY_QUALIFIED_IMAGE_NAME
, l.image_size
, i.image_need_backup
, i.sop_class_uid
from medistore.didb_studies s, medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = 'p1_accno'
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') > 0
order by 1;
BEGIN
FOR accno_rec in accno_cur LOOP
DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
FOR path_rec in path_cur(accno_rec.accession_number) LOOP
DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
END LOOP;
END LOOP;
END;Maybe
DECLARE
cursor ACCNO_CUR is
select accession_number
from didb_studies
where insert_time > to_date('02-JUN-12');
cursor PATH_CUR (p1_accno VARCHAR2) is
select distinct
l.FILE_SYSTEM || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME,
l.image_size,
i.image_need_backup,
i.sop_class_uid
from medistore.didb_studies s,
medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null
and INSTR(l.file_system, '.img') = 0
UNION
select distinct
l.FILE_SYSTEM as FULLY_QUALIFIED_IMAGE_NAME,
l.image_size,
i.image_need_backup,
i.sop_class_uid
from medistore.didb_studies s,
medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') > 0
order by 1;
BEGIN
FOR accno_rec in accno_cur
LOOP
DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
FOR path_rec in path_cur(accno_rec.accession_number)
LOOP
DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
END LOOP;
END LOOP;
END;Regards
Etbin -
I am not getting User Environment Variable Value
Hi Team,
I have been Trying to recover variables values using an anonym procedure from Windows XP SP3
I have already executed following procedure.
BEGIN
DECLARE
gf_filelog UTL_FILE.file_type;
v_file_log VARCHAR2 (1024) := ' ';
gv_path_log VARCHAR2 (1024) := ' ';
gv_path_log2 VARCHAR2 (1024) := ' ';
gv_file_log VARCHAR2 (1024) := ' ';
BEGIN
DBMS_OUTPUT.put_line ( 'obteniendo valores of vars: '
|| gv_path_log
|| ' '
|| gv_file_log
DBMS_SYSTEM.get_env ('ORACLE_HOME', gv_path_log);
DBMS_SYSTEM.get_env ('PATH_MODULO', gv_path_log2);
DBMS_SYSTEM.get_env ('FILELOG', v_file_log);
DBMS_OUTPUT.put_line ( 'valores vars ORACLE_HOME: '
|| gv_path_log
|| 'PATH_MODULO:'
|| gv_path_log2
|| ' FILELOG:'
|| v_file_log
gv_file_log :=
v_file_log || TO_CHAR (SYSDATE, 'yyyymmddHH24MISS')
|| '.log';
DBMS_OUTPUT.put_line ( 'Nombre de Archivo creado'
|| gv_path_log
|| ' '
|| gv_file_log
gf_filelog := UTL_FILE.fopen (gv_path_log, gv_file_log, 'w');
DBMS_OUTPUT.put_line ('Archivo creado' || gv_path_log || ' '
|| gv_file_log
UTL_FILE.put_line (gf_filelog,
|| TO_CHAR (SYSDATE, 'HH24:MI:SSSSS')
|| ']--> '
|| 'Prueba de escritura'
|| gv_path_log
|| ' '
|| v_file_log
UTL_FILE.fflush (gf_filelog);
UTL_FILE.fclose (gf_filelog);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( '[reporta_log]Error en :'
|| SQLCODE
|| ' - '
|| SQLERRM
raise_application_error (-20000,
'[reporta_log]Error en :'
|| SQLCODE
|| ' - '
|| SQLERRM
END;
END;
I show you data result after procedure was excecuted.
obteniendo valores of vars:
valores vars ORACLE_HOME: E:\oracle\product\10.2.0\db_1PATH_MODULO: FILELOG:
Nombre de Archivo creadoE:\oracle\product\10.2.0\db_1 20111122171625.log
[reporta_log]Error en :-29280 - ORA-29280: invalid directory path
BEGIN
ERROR at line 1:
ORA-20000: [reporta_log]Error en :-29280 - ORA-29280: invalid directory path
ORA-06512: at line 55
I see that only ORACLE_HOME variable value was got, question is why, of course, variable values are already defined as user variables.
Variables PATH_MODULO and FILELOG was defined using windows maintenance variable method, that is :
1.- settings
2.- system
3.- advanced options
4.- environment variables
Here my oracle version
SQL> select version from v$instance;
VERSION
10.2.0.1.0
SQL>
Is this an Oracle Issue or variables would be defined in another way?
ORACLE_HOME VARIABLE was created when oracle engine was installed.
I have got same result after computer was restart.
I appreciate wathever clue.Ok, that is , I only can read environment variables values, but not variables values at user profile. It happends in unix environment too. So I tried to use another instruction sequence in order to read user variables values.
Regards -
How to Populate a table with DBMS_OUTPUT.put_line
Hey Guys, it's Xev.
Please only pleasant people reply to this.
I have a PL/SQL Program that searches for strings and then at the end of it it prints out to DBMS_OUTPUT.put_line.
I have the owner, the table_name, the column name and the count, then it goes to DBMS_OUTPUT.put_line
What i want to do, is take the results of DBMS_OUTPUT.put_line and insert it into a table.
Here is the script I am talking about, as you can see it's simple, yet for me it works. I want to take the results of this and insert it into a table. How can i do that??
set serveroutput on size unlimited
execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
DECLARE
FND_GOVIDS INTEGER;
BEGIN
FOR t IN (SELECT owner, table_name, column_name
FROM all_tab_columns
WHERE owner = upper('&SCHEMA_NAME'))
LOOP
BEGIN
EXECUTE IMMEDIATE 'with a as ( select case when REGEXP_LIKE(' || t.column_name ||
--This searches for 8 Alpha Digits
',''^([[:alpha:]]{2}|[[:alpha:]]{4})?[ ]?[0-9]{8}[ ]?([[:alpha:]]{2}|[[:alpha:]]{4})?$'')
then ''Match Found''
else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
select count(*) from a where a.output=''Match Found'' '
INTO FND_GOVIDS ;
IF FND_GOVIDS > 0 THEN
DBMS_OUTPUT.put_line (
t.owner
|| '.'
|| t.table_name
|| ' '
|| t.column_name
|| ' '
|| FND_GOVIDS);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Generic Error '
|| t.column_name
|| ' from '
|| t.owner
|| '.'
|| t.table_name);
END;
END LOOP;
END;Nope, the table is empty....
But it ran without error??!?! Wait a minute, I think i have to commit right? Since it's not straight sql, ok, that's what I am going to try..
set serveroutput on size unlimited
execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
DECLARE
FND_GOVIDS INTEGER;
BEGIN
FOR t IN (SELECT owner, table_name, column_name
FROM all_tab_columns
WHERE owner = upper('&SCHEMA_NAME'))
LOOP
BEGIN
EXECUTE IMMEDIATE 'with a as ( select case when REGEXP_LIKE(' || t.column_name ||
--This searches for 6 Alpha Digits
',''^([[:alpha:]]|[[:alpha:]]{3})[0-9]{6}$'')
then ''Match Found''
else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
select count(*) from a where a.output=''Match Found'' '
INTO FND_GOVIDS ;
/*Table insert for resulting */
IF FND_GOVIDS > 0 THEN
INSERT INTO "SMEG"."DYNAMIC_COUNTS" (T_OWNER, T_TABLE_NAME, T_COLUMN_NAME, FND_GOVIDS) VALUES
('t.owner','t.table_name','t.column_name','FND_GOVIDS');
END IF;
/* dbms_output */
IF FND_GOVIDS > 0 THEN
DBMS_OUTPUT.put_line (t.owner || '.' || t.table_name || ' ' || t.column_name || ' ' || FND_GOVIDS);
END IF;
/* Exception Handeling */
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Generic Error '
|| t.column_name
|| ' from '
|| t.owner
|| '.'
|| t.table_name);
END;
END LOOP;
END; -
Dbms_output.put_line not displaying anything
I am running the below code (ssn_run.sql) using sqlplus 10.2.0.1.0 on my windows XP professional client PC.
The database is a Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit running on Solaris
I cracked my head for about one hour but couldn't figure out this :
accept input_ssn prompt 'Enter SSN :'
set feedback on
set serveroutput on
set echo on
set term on
set heading on
set pagesize 0
set linesize 10000
set verify on
undefne sdate input_ssn
col sdate new_value sdate
col input_ssn new_value input_ssn
select to_char(sysdate,'YYYYMMDD') sdate from dual;
spool C:\PERSON_DATA_&&sdate._&&input_ssn..TXT
select 'REPORT GENERATED ON : '||SYSDATE FROM DUAL;
begin
select personid into v_personid from person where SIN = '&&input_ssn';
INSERT INTO PERSON_OLD
(PERSONID, TITLE, FNAME, MNAME, LNAME, ACFM, SIN, UNAME, AKANAME, DCFM,
IROWID, SUFFIX, PTYPE, OLD_SSN)
SELECT PERSONID, TITLE, FNAME, MNAME, LNAME, ACFM, SIN, UNAME,
AKANAME, SIN FROM PERSON WHERE SIN = '&&input_ssn';
INSERT INTO MEMBER_OLD
(CLNT, MKEY, PERSONID, MEMNO, OLD_MEMNO)
SELECT CLNT, MKEY, PERSONID, MEMNO,MEMNO
FROM MEMBER WHERE PERSONID IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn');
UPDATE PERSON SET FNAME = TRANSLATE(SIN,'0123456789','ACEGIKMOQS'),
LNAME = TRANSLATE(SIN,'0123456789','SQOMKIGECA'),
UNAME = TRANSLATE(SIN,'0123456789','ACEGIKMOQS')||' '||TRANSLATE(SIN,'0123456789','SQOMKIGECA'),
AKANAME=NULL WHERE SIN = '&&input_ssn';
UPDATE MEMBER SET MEMNO = MKEY WHERE PERSONID IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn');
for i in(select personid person_other from person_relation where relpersonid in(select personid from
person where PERSONID = v_personid))
loop
dbms_output.put_line('i.person_other is : '||i.person_other);
UPDATE MEMBER SET MEMNO = MKEY WHERE PERSONID = i.person_other;
end loop;
EXCEPTION
WHEN OTHERS THEN
ecode := SQLCODE;
emesg := SQLERRM;
dbms_output.put_line('Error while data scrubbing: Error code is : ' || ' - ' || ecode);
dbms_output.put_line('Error message is :' || ' - ' || emesg);
end;
spool off;
set term on
set feedback on
set HEADING on
set verify on
--End of code
The SELECT statement that comes in the for loop should return data as v_personid has a value. (I tested this by a select statement)
However, I am just not able to display the line which comes in the inner loop :
dbms_output.put_line('i.person_other is : '||i.person_other);
The result of this dbms output put_line neither shows up on the screen, nor it gets written to the spool file...I am stumped with this...
The other dbms_output put_lines that display error displays okay, but not the one in the inner loop.... Can someone help me out if you see any obvious issues here........
Also my UPDATE MEMBER statement inside the for loop doesn't do anything whereas it was supposed to update a row !!
ThanksYou could display the number the query return by adding;
v_count number;After you assign v_personid;
dbms_output.put_line('v_personid is : '||v_personid );
(select count(*)
into v_count
from person_relation
where relpersonid in(
select personid
from person
where PERSONID = v_personid)).
dbms_output.put_line('v_count is : '||v_count ); -
How to pass Temp variable value instead of Table name in From clause.
Hi,
I have an requirement to pass the Temperorary variable value instead of Table name in FROM Clause in SQL.
But I am strugglint to pass this variable value.
E.g., a Varchar2(5) := 'aa';
Select * from a;
Here I come to mention a - 'aa'. But the SQL looks for 'a' as Table. But its should look into 'aa' as Table name.
Kindly guide me.
Thanks.SQL> declare
a varchar2 (5) := 'emp';
v varchar2 (100);
cur sys_refcursor;
begin
open cur for 'Select ename from ' || a;
fetch cur into v;
while cur%found
loop
dbms_output.put_line (v);
fetch cur into v;
end loop;
close cur;
end;
JAMES
SCOTT
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
KING
TURNER
ADAMS
FORD
MILLER
PL/SQL procedure successfully completed.
Maybe you are looking for
-
I accidentally deleted all my music from iTunes I was able to recover the music. How can I restore playlists?
-
PL/SQL : User defined Aggregate Functions ??
Is it possible to create (using whatever language) a user defined aggregate function for transparent usage within sql ? e.g. select median(myField) from myTable or select empirical_expectation(myField) from myTable thanx in advance .. Tobias Oberstei
-
IDOC_ERROR_ILLEGAL_TYPE
Hello, I am trying to send an IDOC INVOIC to an SAP system. Here I get error Application error: com.sap.mw.idoc.IDoc$Exception: (3) IDOC_ERROR_ILLEGAL_TYPE: Segment type "E1EDKA1" is not a valid child segment type. But when I print out Meta Data abou
-
Will the new watch be able to be used as a fob watch? In the NHS we are not allowed to wear wrist watches so this would a really useful feature.
-
Problem in Web adi for custom integrator.
Hi All, I never used Web ADI. i read some document and feel that it is easy... but facing problem while developing. The basic requirement as follows - 1. There is a custom database, say XXA. 2. A staging table (xxa_table) for upload data from csv fil