Dbms_output.put_line in this query
I want to put a dbms_output.put_line in this query so it will give my the property_id is checking first in the PM_EXCHANGE_PROPERTY_PRIORITY
(its part of a more bigger procedure)
dbms_output.put_line('RESORT ID one=> '||rci_dep_rec.resort_id);
with
base_prop as (
select /*+ MATERIALIZE */ property_id, priority
from PM_EXCHANGE_PROPERTY_PRIORITY ppp
where ppp.exchange_affiliation = 'RCI'
and ppp.master_property_id in (select ppp2.master_property_id
from P_PM_PROPERTY ppp1, PM_EXCHANGE_PROPERTY_PRIORITY ppp2
where ppp1.rci_id_number = rci_dep_rec.resort_id
and ppp1.property_active = 'Y'
and ppp1.exchange_affiliation = ppp.exchange_affiliation
and ppp2.property_id = ppp1.property_id)
union
select property_id, 99999
from P_PM_PROPERTY ppp
where ppp.rci_id_number = rci_dep_rec.resort_id
and ppp.property_active = 'Y'
and not exists (select 1 from PM_EXCHANGE_PROPERTY_PRIORITY ppp1 where ppp1.property_id = ppp.property_id)
order by 2
select pput.pm_unit_type_id
bulk collect into pm_unit_type_ids
from P_PM_UNIT_TYPE pput, S_PM_EXCHANGE_MAPPING spem, base_prop bp
where spem.exchange_affiliation = 'RCI'
and spem.resortcode = rci_dep_rec.resort_id
and ((spem.unitnumber = rci_dep_rec.unit_no and rci_dep_rec.resv_type = 'WEEKS')
or (spem.unitnumber = rci_dep_rec.unit_type and rci_dep_rec.resv_type = 'POINTS'))
and rci_dep_rec.start_dt between spem.begin_date and spem.end_date
and pput.property_id = spem.property_id
and pput.pm_unit_type_active = 'Y'
and instr(spem.unittypecode, pput.pm_unit_type) > 0
and spem.property_id = bp.property_id
ORDER BY bp.priority,pput.pm_unit_type_priority;
end;
dbms_output.put_line('RESORT ID => '||rci_dep_rec.resort_id);
but im not sure where i can put ii, i have it to give my the resort_id
i want to know which one the property_id is checking first, there is only two , one has a higher priority
for example if i hardcoded it
select /*+ MATERIALIZE */ property_id, priority
from PM_EXCHANGE_PROPERTY_PRIORITY ppp
where ppp.exchange_affiliation = 'EZY'
and ppp.master_property_id in (select ppp2.master_property_id
from P_PM_PROPERTY ppp1, PM_EXCHANGE_PROPERTY_PRIORITY ppp2
where ppp1.rci_id_number = '8789'
and ppp1.property_active = 'Y'
and ppp1.exchange_affiliation = 'RCI,II'
and ppp2.property_id = 'VDG')
union
select property_id, 99999
from P_PM_PROPERTY ppp
where ppp.rci_id_number ='8789'
and ppp.property_active = 'Y'
and not exists (select 1 from PM_EXCHANGE_PROPERTY_PRIORITY ppp1 where ppp1.property_id = 'VDG')
order by 2
i would get this
PROPERTY_ID|PRIORITY
VDR |1
VDG |2
thanks for help or tips
Hi Nat,
Your question is not very clear (other wise you would have an answer from this forum by now).
What you are showing is an SQL (which is part of bigger picture). Bigger picture is important. Is it a PL/SQL procedure or function?
DBMS_OUTPUT.PUTLINE is a procedures call, that can be called in PL/SQL. What you have shown us is a SQL from within the PL/SQL.
Please do NOT paste a larger piece of code.
The place where you ave shown the DBMSOUTPUT.PUT_LINE seems correct.
However,
You said
but im not sure where i can put ii, i have it to give my the resort_id
i want to know which one the property_id is checking first, there is only two , one has a higher priority
The sequence in which rows are processed does NOT matter in SQL and there is no such thing as "checking first". ALL the rows that satisfy the criteria. Since you have ORDER BY the rows will be returned in that order.
Please explain what problem you are trying to solve.
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Hope this helps.
vr,
Sudhakar
Similar Messages
-
Hi All,
This is Sindhu..
Here i got an error while excuting the following query related to BLOB data types in Oracle 11g.
I have to compare two blobs, because my report needs that.
for this..1st i ran the following package..
@ORACLE_HOME/rdbms/admin/dbmslob.sql
then i did this...
declare
src_lob BFILE := &src_lob;
amount INTEGER := &amount;
dest_offset INTEGER :=1;
src_offset INTEGER :=1;
dest_lob BLOB := &dest_lob;
BEGIN
dbms_lob.loadfromfile
dest_lob,
amount,
src_lob,
src_offset,
dest_offset
end;
SQL> /
Enter value for src_lob: 0820303623ECCFF8DCD9E0DFF11FDF1E1E7C3E6450E444E2E683A3D
B03FF7B7CFF34FC24244724CF07CBDBC8EB80C034000436007E018801016B01FEFFFEFEFEFE0F7F0
D07891FF198F1E9E1F304730C
old 2: 2 src_lob BFILE := &src_lob;
new 2: 2 src_lob BFILE := 0820303623ECCFF8DCD9E0DFF11FDF1E1E7C3E6450E444E2E
683A3DB03FF7B7CFF34FC24244724CF07CBDBC8EB80C034000436007E018801016B01FEFFFEFEFEF
E0F7F0D07891FF198F1E9E1F304730C;
Enter value for amount: 18446744073709551615
old 3: 3 amount INTEGER := &amount;
new 3: 3 amount INTEGER := 18446744073709551615;
Enter value for dest_lob: 8F2F1FE032E0E0C8C00CF91E2E1F0EDBDDF2D13292203E61614161
80C0E689FFAEFFD7FEDF38FC3818013941F1C7C4C74FF3FF90F218000D1CAD9F89ED00E000024404
D76DDFD6DF935F5B0E5C868E87
old 6: 6 dest_lob BLOB := &dest_lob;
new 6: 6 dest_lob BLOB := 8F2F1FE032E0E0C8C00CF91E2E1F0EDBDDF2D13292203E616
1416180C0E689FFAEFFD7FEDF38FC3818013941F1C7C4C74FF3FF90F218000D1CAD9F89ED00E0000
24404D76DDFD6DF935F5B0E5C868E87;
ERROR:
ORA-00972: identifier is too long
SQL> declare
2 lob_1 BLOB := &lob_1;
3 lob_2 BLOB := &lob_2;
4 amount INTEGER := 18446744073709551615;
5 offset1 INTEGER :=1;
6 offset2 INTEGER :=1;
7 templob INTEGER;
8 BEGIN
9 templob :=dbms_lob.compare(lob_1,lob_2,amount,offset1,offset2);
10 if (templob !=0 ) then
11 dbms_output.put_line('Files Are Different');
12 else
13 dbms_output.put_line('Files Are Same');
14 end if;
15 end;
16 /
Enter value for lob_1: 0820303623ECCFF8DCD9E0DFF11FDF1E1E7C3E6450E444E2E683A3DB0
3FF7B7CFF34FC24244724CF07CBDBC8EB80C034000436007E018801016B01FEFFFEFEFEFE0F7F0D0
7891FF198F1E9E1F304730C
old 2: lob_1 BLOB := &lob_1;
new 2: lob_1 BLOB := 0820303623ECCFF8DCD9E0DFF11FDF1E1E7C3E6450E444E2E683A3DB0
3FF7B7CFF34FC24244724CF07CBDBC8EB80C034000436007E018801016B01FEFFFEFEFEFE0F7F0D0
7891FF198F1E9E1F304730C;
Enter value for lob_2: 8F2F1FE032E0E0C8C00CF91E2E1F0EDBDDF2D13292203E6161416180C
0E689FFAEFFD7FEDF38FC3818013941F1C7C4C74FF3FF90F218000D1CAD9F89ED00E000024404D76
DDFD6DF935F5B0E5C868E87
old 3: lob_2 BLOB := &lob_2;
new 3: lob_2 BLOB := 8F2F1FE032E0E0C8C00CF91E2E1F0EDBDDF2D13292203E6161416180C
0E689FFAEFFD7FEDF38FC3818013941F1C7C4C74FF3FF90F218000D1CAD9F89ED00E000024404D76
DDFD6DF935F5B0E5C868E87;
ERROR:
ORA-00972: identifier is too long
i do not know why i got this problem.. is there any error in my program..
lobmaxsize=4GB
how to increase the size of the data type.
Please Help me.
Thank You.Hi Sindhu,
Your problem has not to with lob size.
The error ORA-00972: identifier is too long
tells you that
0820303623ECCFF8DCD9E0DFF11FDF1E1E7C3E6450E444E2E683A3D
B03FF7B7CFF34FC24244724CF07CBDBC8EB80C034000436007E018801016B01FEFFFEFEFEFE0F7F0
D07891FF198F1E9E1F304730C
becomes an identifier.
Look into this for how to use substitution variables
http://www.oracle.com/technology/support/tech/sql_plus/htdocs/sub_var.html
If you don't have time to go through it all, I suggest you at least read section 2.
This won't solve all your problems, but it should explain yur current ORA-00972.
Regards
Peter -
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. -
i have stuck in this query. it is giving compile error that v_customerloop invalid identifier. this does not make sense because if i comment the sql, it runs fine and i can actually see the count in the dbms output. i tried commenting out some of the where clauses but cannot pinpoint where i am making a mistake.
can some one see if i am doing something out of ordinary.
declare
-- Local variables here
o_errorcode NUMBER;
o_errortext VARCHAR2(1000);
o_LoopId NUMBER;
i_CustomerLoop Kroner.Pkgsldcommon.T_CUSTOMERLOOPTYPE;
To_CustomerLoop Kroner.Pkgsldcommon.T_CUSTOMERLOOPTYPE;
v_sql VARCHAR2(3000);
v_CustomerLoop Kroner.t_CustomerLoopElement := Kroner.t_CustomerLoopElement();
begin
i_CustomerLoop(1).Cable := '138-2';
i_CustomerLoop(1).coup := '501';
i_CustomerLoop(1).TermSysID := 1178050;
i_CustomerLoop(1).CentralOfficeName := 'TOROON45';
i_CustomerLoop(2).Cable := '138-2';
i_CustomerLoop(2).coup := '503';
i_CustomerLoop(2).TermSysID := 1178052;
i_CustomerLoop(2).CentralOfficeName := 'TOROON45';
FOR i IN 1..i_CustomerLoop.COUNT -- Create a instance of Kroner.o_CustomerLoopElement
LOOP
v_CustomerLoop.Extend();
v_CustomerLoop(i) := Kroner.o_CustomerLoopElement(co_clli => i_CustomerLoop(i).CentralOfficeName,
cable => i_CustomerLoop(i).Cable,
coup => i_CustomerLoop(i).coup,
termsysid => i_CustomerLoop(i).TermSysID,
landing_number => i
END LOOP;
dbms_output.put_line('v_CustomerLoop length' || v_CustomerLoop.Count);
v_sql:= 'select loop_f1.loopid
from nrms_interface.wdn_landing seg_f1, nrms_interface.wdn_loop_landing_association assoc_f1, nrms_interface.wdn_potential_loop_makeup loop_f1,
nrms_interface.wdn_landing seg_fx, nrms_interface.wdn_loop_landing_association assoc_fx,
table(cast( v_CustomerLoop as Kroner.t_CustomerLoopElement)) input_loop
where loop_f1.CO_CLLI = v_CustomerLoop(1).co_clli
and loop_f1.LOOPID = assoc_f1.LOOPID
and assoc_f1.landing_NUMBER = v_CustomerLoop(1).landing_number
and assoc_f1.landing_ID = seg_f1.landing_ID
and seg_f1.CABLE = v_CustomerLoop(1).cable
and (seg_f1.low_coup <= v_CustomerLoop(1).coup and seg_f1.high_coup >= v_CustomerLoop(1).coup)
and seg_f1.TERMSYSID = v_CustomerLoop(1).termsysid
and assoc_f1.landing_number = 1
and loop_f1.loopid = assoc_fx.loopid
and assoc_fx.landing_ID = seg_fx.landing_id
and assoc_fx.landing_number = input_loop.landing_number
and seg_fx.CABLE = input_loop.cable
and (seg_fx.low_coup <= input_loop.coup and seg_fx.high_coup >= input_loop.coup)
and seg_fx.termsysid = input_loop.termsysid
group by loop_f1.loopid
having max(assoc_fx.landing_NUMBER) = :noOflandings
and count(case when assoc_fx.landing_number = input_loop.landing_number then 1 else 0 end) = :noOflandings';
EXECUTE IMMEDIATE v_sql INTO o_LoopId
USING v_CustomerLoop.count,v_CustomerLoop.count;Hi,
I don't know much about object types, but I think that the error is due to the usage of v_CustomerLoop variable in a different context.
Imagine that using the EXECUTE IMMEDIATE you spawn a different process that communicates with the caller using prameters (USING) and return values (INTO).
In this case, the variable is not visible by the new environement (it is not the same behaviour of nesting a BEGIN/END block in a procedure and referencing a parent variable)
Hope this helps
Max -
Why there is a error in this query ?
why there is a error in this query ?
declare
v_exist pls_integer;
v_search varchar2(255) := '175';
v_sql varchar2(255);
begin
for s in
(select table_name, column_name
from user_tab_columns
where data_type like '%CHAR%'
order by table_name, column_name)
loop
v_sql := 'select count(*) from '||s.table_name||
' where instr('||s.column_name||',' || CHR(39)|| v_search|| CHR(39) ||') > 0';
execute immediate v_sql into v_exist;
if v_exist > 0 then
dbms_output.put_line(s.table_name||'.'||s.column_name||' matches the string.');
end if;
end loop;
end;
Error:
The following error has occurred:
ORA-00933: SQL command not properly ended
ORA-06512: at line 14
Edited by: user575089 on Dec 23, 2009 4:14 AM
Edited by: user575089 on Dec 23, 2009 4:14 AMSee, Right now i am in schema and see below :
set serveroutput on;
declare
v_exist pls_integer;
v_search varchar2(255) := 'SCOTT';
v_sql varchar2(255);
begin
for s in
(select '"'||table_name||'"' table_name,'"'||column_name||'"' column_name
from user_tab_columns
where data_type like '%CHAR%'
and table_name not like '%$%'
order by table_name, column_name)
loop
v_sql := 'select count(*) from '||s.table_name||' where instr('||s.column_name||',' || CHR(39)|| v_search|| CHR(39)||') > 0';
--dbms_output.put_line(v_sql);
--execute immediate v_sql;
execute immediate v_sql into v_exist;
if v_exist > 0 then
dbms_output.put_line(s.table_name||'.'||s.column_name||' matches the string.');
end if;
end loop;
end;
"EMP"."ENAME" matches the string.
"EXCEPTIONS"."OWNER" matches the string.
"FLOW_TABLE"."OBJECT_OWNER" matches the string.
"MYEMP"."ENAME" matches the string.
PL/SQL procedure successfully completed.
I am getting output; that i search "SCOTT" word in my search string. -
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 ); -
Hi Guys.
I upgraded from 1.2 and it appears that dbms_output.put_line is now broken.
Consider the following:
begin
dbms_output.put_line('hello world');
end;Process:
1. Load SQL Developer
2. Open a connection to DB
3. Go to DBMS Output tab
4. Enable server output
5. Type in the code (as above)
6. Hit F5
The bug/new feature:
After hitting f5, the DBMS Output tab switches to Script output where by I am presented with "anonymous block completed". In 1.2 (and previous versions) I used to see
anonymous block completed
hello world
in the Script Output tab.
Now I have to switch back to the DBMS Output tab. My problem with this is that there is far too much clicking. Why redirect me away from the tab that is going to actually display the script output only for me to have to click back into that tab? I just don't get it.
Regards
Kristian Jones
http://kristianjones.blogspot.com
Message was edited by:
Kris JonesHi,
I also have the problem with the new Released.
SQL Dev 1.2.0.29.98 upgraded with Check for Updates to 1.2.1.32.00
On Windows XP.
I did exactly as Kris Jones post, using Run Script
but, it seems that my SQL Developer doesn't do anything.
The progress bar is active like processing somthing, well, it processes forever.
I tried to cancel the process (button Cancel), but the panel shows that it is still trying to cancel the process (all buttons are disabled except Cancel), although I can do another select (use CTRL + Enter because F9 doesn't work) within the same SQL Worksheet and the panel goes back to the active panel again.
Well, there must be something wrong with the Run Script.
Since any query or pl/sql block seems running forever if I use Run Script.
I try on the SQL Developer 1.2.0.29.98 (luckily, I still keep the backup, just in case) and it shows the result as wanted.
Is there something wrong within my SQL Developer 1.2.0.32.00?
Or there is some patches which I should download?
Is it another bug?
Many thanks,
Buntoro -
hi,
i have a product table like
product month1 month2 month3 .................
soap 1200 1256 1895 ............
i want use a query where i can select column name with a parameter.
like
select month||:num from product;
in num variable it cud be 1 to 10 of value that is dependent on my program.
so how to make this query .
thxsHi,
Here is an example that i am helpful.
In the example , I am using a table 'table_name' which contains columns like
assign_attribute1
assign_attribute2
assign_attribute15
Now I will pass any number from 1 to 15 to the function.
create or replace procedure pass_col_number(v_number varchar2) as
v_sql varchar2(2000);
v_assign_attribute1 varchar2(150);
begin
v_sql := 'select assign_attribute'||v_number||' from table_name where person_id = 1345';
execute immediate v_sql into v_assign_attribute1;
dbms_output.put_line('v_assign_attribute1='||v_assign_attribute1);
end;Edited by: Sreekanth Munagala on Dec 18, 2008 1:18 AM -
What is wrong in this query?
Hi All,
Could anybody please help me in identifying the issue in the below code as i am getting error as:
declare
ERROR at line 1:
ORA-01006: bind variable does not exist
ORA-06512: at "SYS.DBMS_SYS_SQL", line 846
ORA-06512: at "SYS.DBMS_SQL", line 52
ORA-06512: at line 14
Below is my code :
declare
vSql varchar2(1000);
vSal number(10);
vName varchar2(20) := 'King';
hcur number;
lexe number;
Begin
hcur := dbms_sql.open_cursor;
vSql := 'select salary into :sal from employees where last_name = :name ';
dbms_sql.parse(hcur,vsql,dbms_sql.native);
dbms_sql.bind_variable(hcur,':name',vname);
dbms_sql.bind_variable(hcur,':sal',vSal,10);
lexe := dbms_sql.execute(hcur);
Loop
exit when dbms_sql.fetch_rows(hcur) = 0;
dbms_sql.variable_value(hcur,':sal',vSal);
end loop;
dbms_sql.close_cursor(hcur);
end;Tandra:
Sorry, there were a couple of errors in my code. This should work (I actually tested this time)
DECLARE vsql VARCHAR2(1000);
vsal NUMBER(10);
vname VARCHAR2(20) := 'King';
hcur NUMBER;
lexe NUMBER;
BEGIN
hcur := DBMS_SQL.Open_Cursor;
vsql := 'select salary from employees where last_name = :name ';
DBMS_SQL.Parse(hcur,vsql,DBMS_SQL.Native);
DBMS_SQL.Define_Column(hcur, 1, vsal);
DBMS_SQL.Bind_Variable(hcur,':name',vname);
lexe := DBMS_SQL.Execute(hcur);
LOOP
EXIT WHEN DBMS_SQL.Fetch_Rows(hcur) = 0;
DBMS_SQL.Column_Value(hcur, 1, vSal);
END LOOP;
DBMS_SQL.Close_Cursor(hcur);
END; You need to define the columns in the SELECT list of the query and match them with a variable of the correct type (the call to DBMS_SQL.Define_Column). Note that the variable noes not need to be the same one that you will alter use to get the column value (the call to DBMS_SQL.Column_Value), not does it need to be of the same length as the actual column, only the same type. For VARCHAR2, CHAR and RAW columns you need to pass the length of the column as well. A slightly more complex version:
SQL> DECLARE vsql VARCHAR2(1000);
2 vsal NUMBER(10);
3 vname VARCHAR2(20) := 'King';
4 vfirst VARCHAR2(20);
5 hcur NUMBER;
6 lexe NUMBER;
7 x NUMBER;
8 y VARCHAR2(1);
9 BEGIN
10 hcur := DBMS_SQL.Open_Cursor;
11 vsql := 'select first_name, salary from employees where last_name = :name ';
12 DBMS_SQL.Parse(hcur,vsql,DBMS_SQL.Native);
13 -- Note the dummy variables x and y in the call to Define_Column
14 DBMS_SQL.Define_Column(hcur, 1, y, 20);
15 DBMS_SQL.Define_Column(hcur, 2, x);
16 DBMS_SQL.Bind_Variable(hcur,':name',vname);
17 lexe := DBMS_SQL.Execute(hcur);
18 LOOP
19 EXIT WHEN DBMS_SQL.Fetch_Rows(hcur) = 0;
20 DBMS_SQL.Column_Value(hcur, 2, vSal);
21 DBMS_SQL.Column_Value(hcur, 1, vfirst);
22 DBMS_OUTPUT.Put_Line('First name: '||vfirst||' Salary: '||vsal);
23 END LOOP;
24 DBMS_SQL.Close_Cursor(hcur);
25 END;
26 /
First name: Janette Salary: 10000
First name: Steven Salary: 24000
PL/SQL procedure successfully completed.Now, I'm off to write "I will not post untested code" 100 times on the whiteboard.
HTH
John -
Dbms_output.put_line problem..
We have created delete script to some 150 tables using cursors suppose we r deleting with some condition and use to display the output as
dbms_output.put_line('Rows Deleted in the table distb_store_promo is '||SQL%ROWCOUNT);
its shows error like it exceeds the limit.so we made setserver output off and running the query it works fine.is any other solution to overcome this..> is any other solution to overcome this..
Yes. Do not use DBMS_OUTPUT. It is a very primitive API - useful for the odd debug display when debugging PL/SQL code. It should not be used for anything else. In fact, any DBMS_OUTPUT code in production PL/SQL requires serious reconsideration as those calls should be wrapped in a user PL/SQL proc.
The proper and correct method would be to create a log PL/SQL procedure to log messages into an Oracle table, using autonomous transactions. -
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; -
I am using Oracle 10.1.0.4.2 SQL Plus, and dbms_output.put_line is not working. It returns the dbms_output ONLY from outside the procedure. I have dbms_output INSIDE my procedure, and none of it gets returned. Please help!
Here is what I enter:
set serveroutput on size 1000000;
DECLARE
x number:=0;
begin
DBMS_OUTPUT.ENABLE;
c2reports.c2proc(x,'TEST');
DBMS_OUTPUT.PUT_LINE('testX');
END;
testX
There should be more besides the 'testX' that gets returned. The first line in my procedure has output code to print testY. Thanks in advance!This is the forum for the Oracle's SQL Developer (Not for general SQL/PLSQL questions). You should ask question like this in the PL/SQL forum
-
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 -
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? -
DBMS_OUTPUT.PUT_LINE
Hello I need a Help.
I use PHP Version 4.4.0 and Oracle 10g
I have create this procedure with php
$node_start = 670;
$node_end = 677;
$conn = @OCILogon("My_db", "My_pass", "My_host") or die ( "Connect KO to server <b>$My_host</b>!");
$plsql = "create or replace PROCEDURE PERCORSOSTRADA AS "
." path_id NUMBER;"
." res_numeric NUMBER;"
." res_array SDO_NUMBER_ARRAY;"
." indx NUMBER;"
." BEGIN"
." sdo_net_mem.network_manager.read_network('SDO_RETE_STRADALE', 'FALSE');"
." path_id := sdo_net_mem.network_manager.shortest_path('SDO_RETE_STRADALE', $node_start, $node_end);"
." res_array:= sdo_net_mem.path.get_node_ids('SDO_RETE_STRADALE', path_id);"
." DBMS_OUTPUT.PUT('This path has the following nodes: ');"
." FOR indx IN res_array.FIRST..res_array.LAST"
." LOOP"
." DBMS_OUTPUT.PUT(res_array(indx) || ' ');"
." END LOOP;"
." DBMS_OUTPUT.PUT_LINE(' ');"
." res_array:= sdo_net_mem.path.get_link_ids('SDO_RETE_STRADALE', path_id);"
." DBMS_OUTPUT.PUT('This path has the following links: ');"
." FOR indx IN res_array.FIRST..res_array.LAST"
." LOOP"
." DBMS_OUTPUT.PUT(res_array(indx) || ' ');"
." END LOOP;"
." DBMS_OUTPUT.PUT_LINE(' ');"
." END PERCORSOSTRADA;"
$s = OCIParse($conn, $plsql);
$istruzione = @OCIExecute($s);
This procedure run successfully
If I use sql*plus I have this result
-This path has the following nodes: 670 674 673 676 677
-This path has the following links: 824 818 2925 874
What I must to do for have the same result using a script php?
I have tried to read The Underground PHP and Oracle® Manual Release 1.4
of CHRISTOPHER JONES AND ALISON HOLLOWAY
but I am not able to find the right way.
Thank you in advance!
Edited by: angelo_z on Sep 8, 2008 12:34 PMExcuse me but I don't understand what I must to do after created this procedure: PERCORSOSTRADA
$node_start = 670;
$node_end = 677;
$conn = @OCILogon("My_db", "My_pass", "My_host") or die ( "Connect KO to server $My_host!");
$plsql = "create or replace PROCEDURE PERCORSOSTRADA AS "
." path_id NUMBER;"
." res_numeric NUMBER;"
." res_array SDO_NUMBER_ARRAY;"
." indx NUMBER;"
." BEGIN"
." sdo_net_mem.network_manager.read_network('SDO_RETE_STRADALE', 'FALSE');"
." path_id := sdo_net_mem.network_manager.shortest_path('SDO_RETE_STRADALE', $node_start, $node_end);"
." res_array:= sdo_net_mem.path.get_node_ids('SDO_RETE_STRADALE', path_id);"
." DBMS_OUTPUT.PUT('This path has the following nodes: ');"
." FOR indx IN res_array.FIRST..res_array.LAST"
." LOOP"
." DBMS_OUTPUT.PUT(res_array(indx) || ' ');"
." END LOOP;"
." DBMS_OUTPUT.PUT_LINE(' ');"
." res_array:= sdo_net_mem.path.get_link_ids('SDO_RETE_STRADALE', path_id);"
." DBMS_OUTPUT.PUT('This path has the following links: ');"
." FOR indx IN res_array.FIRST..res_array.LAST"
." LOOP"
." DBMS_OUTPUT.PUT(res_array(indx) || ' ');"
." END LOOP;"
." DBMS_OUTPUT.PUT_LINE(' ');"
." END PERCORSOSTRADA;"
$s = OCIParse($conn, $plsql);
$istruzione = @OCIExecute($s);
I have not clear next steps.
I'm doing this:
function SetServerOutput($conn, $p)
if ($p)
$s = "BEGIN DBMS_OUTPUT.ENABLE(NULL); END;";
else
$s = "BEGIN DBMS_OUTPUT.DISABLE(); END;";
$s = OCIparse($conn_obgeo, $s);
$r = OCIexecute($s);
OCIfreestatement($s);
return $r;
function GetDbmsOutput($conn)
$res = false;
$s = OCIparse($conn_obgeo, "BEGIN DBMS_OUTPUT.GET_LINE(:LN, :ST); END;");
if (ocibindbyname($s, ":LN", $ln, 255) &&
ocibindbyname($s, ":ST", $st)) {
$res = array();
while (($succ = ociexecute($s)) && !$st)
$res[] = $ln;
if (!$succ)
$res = false;
ocifreestatement($s);
return $res;
SetServerOutput($conn, true);
// Create some output
$s = ociparse($conn_obgeo, "call dbms_output.put_line('Hello, world!')");
ociexecute($s);
// Display the output
$output = GetDbmsOutput($conn);
foreach ($output as $line)
echo "$line<br>";
But What I must to do, what I must write instead of 'Hello, world!'?
I must create a function myfunc?
$plsql_fun = "create or replace package mypack AS "
." function myfunc(i_p in number) return varchar2;"
." end mypack;"
$s = OCIParse($conn, $plsql_fun);
$istruzione = @OCIExecute($s);
and then I must call procedure?
$call_procedura = OCIParse($conn, "call PERCORSOSTRADA()");
OCIexecute($call_procedura);
and then ???
$stmt = OCIparse($conn, "begin :ret := mypack.myfunc(); end;");
OCIbindbyname($stmt, ':ret', $r, 20);
OCIexecute($stmt);
echo "Name is: ".$r;
Thank you in advance!
Maybe you are looking for
-
IMac external display not recognised although previously it was recognised.
I have been using a secondary display for several months without problems. Now the iMac refuses to recognize it's existence. The secondary display gives message 'No Input Signal' Any ideas as to what has gone wrong?
-
Hi all I want to know if java can communicate with a device , for example a TPE (Terminal de Paiement Electronique), via the PC communication port . I want to send and receive informations between a java stored procedure and the TPE. Thank you very m
-
How do I can I install MS Office 2008 on a MacBook Air w/ a valid product key? Can I download files somewhere? Here's the scenario.... I've got a brand new gift MacBook Air 11" and I want to install Microsoft Office 2008 since I have a valid key lice
-
I am runnign 10g on Solaris 10 x864. Everything was running great. Then about a week ago I could not start the emca. After trying several things I went and reinstalled 10g and still have the same problem. I can start isqlplus and sqlplus. My time mat
-
Can anyone recommend a good learning resource for photshop scripting? Something other than the Adobe scripting JS reference guides or Java Script manuals. Ideally, a course focused on Photoshop Scripting.