Sql code problem
for example:
update vv_om_temp_tl t
set t.inventory_item_id =(select attribute6 from mtl_system_items_b
where inventory_item_id = t.inventory_item_id
and organization_id = p_organization_id)
where exists
(select 'X'
from oe_order_lines_all ol
where ol.price_list_id in (8118,8119)
and ol.line_id = t.order_line_id);
above example update table (vv_om_temp_tl ) through update function while i want to make the same result using one sql code.
who can help me?
thanks!
select decode( t.inventory_item_id,...................) inventory_item_id
from vv_om_temp_tl t,
mtl_system_items_b b,
where t.inventory_item_id = b.inventory_item_id
how to write that pl/sql code?
Similar Messages
-
PL/SQL code problem for LOV
Hi,
I have developed an application using Apex 4.0
Now, i am trying to make a LOV for two columns in my table. Say column A and column B.
Column A has four different values under it say x,y,z,w and column B has around 3 different values say 1,2 and 3.
How do i write a code for LOV for A and B.
SO that it shows me a drop down list for each and then display results accordingly.
Thanksuser13280446 (mind setting your name?),
The fix for this error is to find the subquery in your SQL that's returning more than one row; generally, you'll want to fix the subquery to return only one row, though in some rare situations it's appropriate to change an = to an in clause.
Example:
select *
from a_table a
where a.col1 = ( select b.col1
from b_table b
where b.col2 = 42 );Unless b.col2 is guaranteed to be unique (either PK or enforced through a unique constraint), sooner or later that subquery is going to return more than one row, producing the error you're seeing. These variations will all avoid this, though which one (if any) is/are correct is dependent on the data:
select *
from a_table a
where a.col1 = ( select min(b.col1) -- Ensure one row returned
from b_table b
where b.col2 = 42 );
select *
from a_table a
where a.col1 in ( select b.col1
from b_table b
where b.col2 = 42 );
select a.*
from a_table a,
b_table b
where a.col1 = b.col1
and b.col2 = 42;This is a very contrived example, of course, but without seeing the SQL for your LOV, we can't be any more specific than that...
-David -
Problem compiling PL/SQL code
I am having problmes compiling the following piece of pl/sql
code:
declare
v_servicekey services.servicekey%type;
v_tmodelkey tmodels.tmodelkey%type;
l_bindingid bindingtemplates.bindingid%type;
i_rowlimit number(28);
begin
select bindingid
into l_bindingid
from
(select b.bindingid as bindingid,
b.bindingkey,
nvl(b.accesspointurltype,''),
nvl(b.accesspointurl,''),
nvl(b.hostingredirector,''),
b.updated
from bindingtemplates b, services s
where s.serviceid=b.serviceid
and s.servicekey=v_servicekey
and (b.bindingid in (select i.bindingid
from instances
i,tmodels t
where
t.tmodelid=i.tmodelid
and
t.tmodelkey=v_tmodelkey)
or (b.hostingredirector is not
null
and b.hostingredirector in
(select bindingkey
from bindingtemplates
where bindingid in (select i.bindingid
from instances i,tmodels t
where t.tmodelid = i.tmodelid
and t.tmodelkey = v_tmodelkey))))
order by b.updated)
where rownum <= i_rowlimit;
end;
I get the compilation error
ERROR at line 30:
ORA-06550: line 30, column 27:
PLS-00103: Encountered the symbol "ORDER" when expecting one of
the following:
) * & = - + < / > in mod not rem with an exponent (**)
<> or != or ~= >= <= <> and or like between group having
intersect minus start union where connect is null is not ||
is dangling year DAY_
The symbol ")" was substituted for "ORDER" to continue.
ORA-06550: line 30, column 45:
PLS-00103: Encountered the symbol ")" when expecting one of the
following:
. ( , * @ % & - + ; / for mod rem an exponent (**) asc desc
||
Obviously there is only one SQL and it is complaining about the
ORDER BY clause. Please ignore the values for the host variables.
The same SQL when run from the SQL prompt with values
substituted for the host variables runs perfectly well. Am I
missing something or is there a catch with Oracle PL/SQL.
Please enlighten.
Thankssee
http://forums.oracle.com/forums/message.jsp?id=500260
I want to know that if there is any PL/SQL commad for compiling the code?
My problem is, I am working in an environment where we are using a Database tool named TOAD of QUEST Software. Every body can look into the code. I just want to hide this code from others. A Quick reply in this regard will be really very helpful. -
Problems compiling PL/SQL code
I am having problmes compiling the following piece of pl/sql
code:
declare
v_servicekey services.servicekey%type;
v_tmodelkey tmodels.tmodelkey%type;
l_bindingid bindingtemplates.bindingid%type;
i_rowlimit number(28);
begin
select bindingid
into l_bindingid
from
(select b.bindingid as bindingid,
b.bindingkey,
nvl(b.accesspointurltype,''),
nvl(b.accesspointurl,''),
nvl(b.hostingredirector,''),
b.updated
from bindingtemplates b, services s
where s.serviceid=b.serviceid
and s.servicekey=v_servicekey
and (b.bindingid in (select i.bindingid
from instances
i,tmodels t
where
t.tmodelid=i.tmodelid
and
t.tmodelkey=v_tmodelkey)
or (b.hostingredirector is not
null
and b.hostingredirector in
(select bindingkey
from bindingtemplates
where bindingid in (select i.bindingid
from instances i,tmodels t
where t.tmodelid = i.tmodelid
and t.tmodelkey = v_tmodelkey))))
order by b.updated)
where rownum <= i_rowlimit;
end;
I get the compilation error
ERROR at line 30:
ORA-06550: line 30, column 27:
PLS-00103: Encountered the symbol "ORDER" when expecting one of
the following:
) * & = - + < / > in mod not rem with an exponent (**)
<> or != or ~= >= <= <> and or like between group having
intersect minus start union where connect is null is not ||
is dangling year DAY_
The symbol ")" was substituted for "ORDER" to continue.
ORA-06550: line 30, column 45:
PLS-00103: Encountered the symbol ")" when expecting one of the
following:
. ( , * @ % & - + ; / for mod rem an exponent (**) asc desc
||
Obviously there is only one SQL and it is complaining about the
ORDER BY clause. Please ignore the values for the host variables.
The same SQL when run from the SQL prompt with values
substituted for the host variables runs perfectly well. Am I
missing something or is there a catch with Oracle PL/SQL.
Please enlighten.
Thanks"Order by" can not be used in the subqueries.
Order by should always be specified in the outer query only.
rajkiran -
Got the following reply from db-kernel: SQL-Code :-903
Dear Experts,
I am having a problem running MaxDB Data backup on Netbackup.... Please se log below and suggest.
2011-04-11 13:30:38
Using environment variable 'TEMP' with value 'C:\Windows\TEMP' as directory for temporary files and pipes.
Using connection to Backint for MaxDB Interface.
2011-04-11 13:30:39
Checking existence and configuration of Backint for MaxDB.
Using configuration variable 'BSI_ENV' = 'C:\Netbackup_Script\bsi_backint_daily.env' as path of the configuration file of Backint for MaxDB.
Setting environment variable 'BSI_ENV' for the path of the configuration file of Backint for MaxDB to configuration value 'C:\Netbackup_Script\bsi_backint_daily.env'.
Reading the Backint for MaxDB configuration file 'C:\Netbackup_Script\bsi_backint_daily.env'.
Found keyword 'BACKINT' with value 'D:\sapdb\KGP\db\bin\backint.exe'.
Found keyword 'INPUT' with value 'E:\sapdb\data\wrk\KGP\backint.input'.
Found keyword 'OUTPUT' with value 'E:\sapdb\data\wrk\KGP\backint.output'.
Found keyword 'ERROROUTPUT' with value 'E:\sapdb\data\wrk\KGP\backint.error'.
Found keyword 'PARAMETERFILE' with value 'C:\Netbackup_Script\backint_parameter_daily.txt'.
Finished reading of the Backint for MaxDB configuration file.
Using 'D:\sapdb\KGP\db\bin\backint.exe' as Backint for MaxDB program.
Using 'E:\sapdb\data\wrk\KGP\backint.input' as input file for Backint for MaxDB.
Using 'E:\sapdb\data\wrk\KGP\backint.output' as output file for Backint for MaxDB.
Using 'E:\sapdb\data\wrk\KGP\backint.error' as error output file for Backint for MaxDB.
Using 'C:\Netbackup_Script\backint_parameter_daily.txt' as parameter file for Backint for MaxDB.
Using '300' seconds as timeout for Backint for MaxDB in the case of success.
Using '300' seconds as timeout for Backint for MaxDB in the case of failure.
Using 'E:\sapdb\data\wrk\KGP\dbm.knl' as backup history of a database to migrate.
Using 'E:\sapdb\data\wrk\KGP\dbm.ebf' as external backup history of a database to migrate.
Checking availability of backups using backint's inquire function.
Check passed successful.
2011-04-11 13:30:39
Checking medium.
Check passed successfully.
2011-04-11 13:30:39
Preparing backup.
The environment variable 'BSI_ENV' has already the value 'C:\Netbackup_Script\bsi_backint_daily.env'.
Setting environment variable 'BI_CALLER' to value 'DBMSRV'.
Setting environment variable 'BI_REQUEST' to value 'NEW'.
Setting environment variable 'BI_BACKUP' to value 'FULL'.
Constructed Backint for MaxDB call 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\backint_parameter_daily.txt -i E:\sapdb\data\wrk\KGP\backint.input -c'.
Created temporary file 'E:\sapdb\data\wrk\KGP\backint.output' as output for Backint for MaxDB.
Created temporary file 'E:\sapdb\data\wrk\KGP\backint.error' as error output for Backint for MaxDB.
Writing 'D:\sapdb\pipe2 #PIPE' to the input file.
Prepare passed successfully.
2011-04-11 13:30:39
Starting database action for the backup.
Requesting 'SAVE DATA QUICK TO 'D:\sapdb\pipe2' PIPE BLOCKSIZE 8 NO CHECKPOINT MEDIANAME 'BACKDBFULL'' from db-kernel.The database is working on the request.
2011-04-11 13:30:39
Waiting until database has prepared the backup.
Asking for state of database.
2011-04-11 13:30:39 Database is still preparing the backup.
Waiting 1 second ... Done.
Asking for state of database.
2011-04-11 13:30:41 Database has finished preparation of the backup.
The database has prepared the backup successfully.
2011-04-11 13:30:41
Starting Backint for MaxDB.
Starting Backint for MaxDB process 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\backint_parameter_daily.txt -i E:\sapdb\data\wrk\KGP\backint.input -c >>E:\sapdb\data\wrk\KGP\backint.output 2>>E:\sapdb\data\wrk\KGP\backint.error'.
Process was started successfully.
Backint for MaxDB has been started successfully.
2011-04-11 13:30:41
Waiting for end of the backup operation.
2011-04-11 13:30:41 The backup tool is running.
2011-04-11 13:30:41 The database is working on the request.
2011-04-11 13:30:43 The database has finished work on the request.
Receiving a reply from the database kernel.
Got the following reply from db-kernel:
SQL-Code :-903
2011-04-11 13:30:43 The backup tool is running.
2011-04-11 13:30:44 The backup tool process has finished work with return code 2.
The backup operation has ended.
2011-04-11 13:30:44
Filling reply buffer.
Have encountered error -24920:
The backup tool failed with 2 as sum of exit codes. The database request failed with error -903.
Constructed the following reply:
ERR
-24920,ERR_BACKUPOP: backup operation was unsuccessful
The backup tool failed with 2 as sum of exit codes. The database request failed with error -903.
Reply buffer filled.
2011-04-11 13:30:44
Cleaning up.
Copying output of Backint for MaxDB to this file.
Begin of output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.output)----
Reading parameter file C:\Netbackup_Script\backint_parameter_daily.txt.
Using D:\sapdb\KGP\db\bin\backint.exe as Backint for Oracle.
Using C:\Netbackup_Script\nt_initKGPdaily.utl as parameterfile of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backinthistory.log as history file.
Using E:\sapdb\data\wrk\KGP\backintoracle.in as input of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backintoracle.out as output of Backint for Oracle.
Using E:\sapdb\data\wrk\KGP\backintoracle.err as error output of Backint for Oracle.
Using staging area D:\sapdb\Stage1 with a size of 2147483648 bytes.
Reading input file E:\sapdb\data\wrk\KGP\backint.input.
Backing up pipe D:\sapdb\pipe2.
Found 1 entry in the input file.
Starting the backup.
Starting pipe2file program(s).
Waiting for creation of temporary files.
1 temporary file is available for backup.
Calling Backint for Oracle at 2011-04-11 13:30:43.
Calling 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -p C:\Netbackup_Script\nt_initKGPdaily.utl -i E:\sapdb\data\wrk\KGP\backintoracle.in -c' .
Backint for Oracle ended at 2011-04-11 13:30:43 with return code 2.
Backint for Oracle output: Reading parameter file C:\Netbackup_Script\nt_initKGPdaily.utl.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.in as input of Backint for Oracle.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.out as output of Backint for Oracle.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backint4oracle.err as error output of Backint for Oracle.
Backint for Oracle output: Using staging area D:\sapdb\Stage1 with a size of 2147483648 bytes.
Backint for Oracle output: Using E:\sapdb\data\wrk\KGP\backinthistory.log as history file.
Backint for Oracle output: Using D:\sapdb\KGP\db\bin\backint.exe as Backint for Oracle.
Backint for Oracle output:
Backint for Oracle output: Reading input file E:\sapdb\data\wrk\KGP\backintoracle.in.
Backint for Oracle output: Backing up file D:\sapdb\Stage1.0.
Backint for Oracle output: Found 1 entry in the input file.
Backint for Oracle output:
Backint for Oracle output: Starting the backup.
Backint for Oracle output: Starting pipe2file program(s).
Backint for Oracle output:
Backint for Oracle output: Calling Backint for Oracle at 2011-04-11 13:30:43.
Backint for Oracle output: Calling 'D:\sapdb\KGP\db\bin\backint.exe -u KGP -f backup -t file -i E:\sapdb\data\wrk\KGP\backint4oracle.in -c' .
Backint for Oracle output: Backint for Oracle ended at 2011-04-11 13:30:43 with return code 2.
Backint for Oracle output: Backint for Oracle output: Reading parameter file .
Backint for Oracle output: Backint for Oracle output:
Backint for Oracle output: Backint for Oracle output:
Backint for Oracle output: Backint for Oracle error output: No staging area is defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The path of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the history file is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the input file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the output file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output: The name of the error output file of Backint for Oracle is not defined in the parameter file.
Backint for Oracle output: Backint for Oracle error output:
Backint for Oracle output:
Backint for Oracle output: Finished the backup unsuccessfully.
Backint for Oracle output:
Backint for Oracle output: #ERROR D:\sapdb\Stage1.0
Backint for Oracle output:
Backint for Oracle error output: Backint for Oracle was unsuccessful.
Backint for Oracle error output:
Finished the backup unsuccessfully.
#ERROR D:\sapdb\pipe2
End of output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.output)----
Removed Backint for MaxDB's temporary output file 'E:\sapdb\data\wrk\KGP\backint.output'.
Copying error output of Backint for MaxDB to this file.
Begin of error output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.error)----
Backint for Oracle was unsuccessful.
End of error output of Backint for MaxDB (E:\sapdb\data\wrk\KGP\backint.error)----
Removed Backint for MaxDB's temporary error output file 'E:\sapdb\data\wrk\KGP\backint.error'.
Removed the Backint for MaxDB input file 'E:\sapdb\data\wrk\KGP\backint.input'.
Have finished clean up successfully.> Requesting 'SAVE DATA QUICK TO 'D:\sapdb\pipe2' PIPE BLOCKSIZE 8 NO CHECKPOINT MEDIANAME 'BACKDBFULL'' from db-kernel.The database is working on the request.
This seems to be your problem, the pipe is wrongly defined. On Windows it looks like
\\.\pipe1
see
http://msdn.microsoft.com/en-us/library/aa365783.aspx
Markus -
PL/SQL reporting problem - "The webpage cannot be found" error
Dear All Expert,
I'm here having a problem on generating apex report using PL/SQL. "The webpage cannot be found" error appear when "Search" button pressed.
I'm appreciating if anyone can give their idea on this issue.
PL/SQL will be fired when "Search" button pressed.
My PL/SQL code as below;
DECLARE
lv_desc CLOB:='';
lv_note_desc varchar2(4000);
lv2 CLOB;
lv_title varchar2(2000);
lv_ti varchar2(10);
lv_tg varchar2(10);
lv_tr_cnt integer:= 0;
lv_ti_code varchar2(6);
lv_age number(6):= 0;
lv_note_flag varchar(1);
fv_note_flag varchar2(6);
fv_ti_code varchar2(6);
ti_code varchar2(20);
ti_name varchar2(50);
ti_tm_code varchar2(6);
ti_test_grp varchar2(6);
note_desc varchar2(4000);
ti_unit varchar2(20);
ti_insurance_code varchar2(20);
ti_price number(14);
ti_sex varchar(1);
ti_age varchar(10);
ti_tr_desc varchar(30);
ti_lolimit number(10);
ti_uplimit number(10);
ti_plolimit number(10);
ti_puplimit number(10);
lv_hkey number(10):= 0;
lv_found varchar2(1):= 'N';
lv_itpv varchar2(4000);
lv_lolimit char(15);
lv_uplimit char(15);
lv_tr char(15);
lv_tc char(30);
CURSOR READ_C1_REC IS
select ti_code, ti_name, ti_tm_code, ti_test_grp,ti_unit, ti_itpv_flag,ti_attached_cmt
from test_item
where ti_code like NVL(:P11104_TI_CODE,'%')
and ti_test_grp like NVL(:P11104_TG_CODE,'%')
and ti_code not like '0MB%'
order by ti_code;
C1_REC READ_C1_REC%ROWTYPE;
CURSOR READ_C2_REC IS
select tr_sex_code,tr_ageto,tr_agecode,tr_range_desc,tr_mrr_desc,tr_normal_lolimit,tr_upper_uplimit,tr_panic_lolimit,tr_panic_uplimit
from tr_range
where tr_ti_code = lv_ti_code
order by tr_ageto asc,tr_sex_code desc;
C2_REC READ_C2_REC%ROWTYPE;
cursor READ_C3_REC is
select tivh_key
from test_itpvh
where tivh_ti_code = ti_code
order by tivh_efd desc;
C3_REC READ_C3_REC%ROWTYPE;
cursor READ_C4_REC is
select tivd_lolimit,tivd_uplimit,tivd_value,tivd_rr_desc
from test_itpvd
where tivd_hkey = lv_hkey
order by tivd_seqno;
C4_REC READ_C4_REC%ROWTYPE;
BEGIN
lv_title := '<div style="overflow: auto;height: 500px; width: 1000px;"><table style="width: 500px" cellpadding="0" cellspacing="0"><thead><tr><th>Code</th><th>Name</th></tr></thead>';
htp.p(lv_title);
OPEN READ_C1_REC;
LOOP
FETCH READ_C1_REC INTO C1_REC;
EXIT WHEN READ_C1_REC%NOTFOUND;
lv_note_flag := 'N';
fv_note_flag := 'N';
fv_ti_code := c1_rec.ti_code;
ti_code := c1_rec.ti_code;
ti_name := ' '||c1_rec.ti_name;
ti_tm_code := c1_rec.ti_tm_code;
ti_test_grp := c1_rec.ti_test_grp;
lv_desc := '<tbody><tr><td><input type="hidden" name="f01" value="'||fv_ti_code||'" /></td>'||
'<td><input type="text" name="f02" size="20" maxlength="20" value="'||ti_code||'" /></td>'||
'<td><input type="text" name="f03" size="50" maxlength="50" value="'||ti_name||'" /></td>'||
'<td><input type="text" name="f04" size="6" maxlength="6" value="'||ti_tm_code||'" /></td>'||
'<td><input type="text" name="f05" size="6" maxlength="6" value="'||ti_test_grp||'" /></td>';
if c1_rec.ti_itpv_flag = 'Y' then
lv_note_flag := 'Y';
open read_c3_rec;
loop
fetch read_c3_rec into c3_rec;
exit when read_c3_rec%notfound;
lv_hkey := c3_rec.tivh_key;
lv_found := 'Y'; exit;
end loop;
close read_c3_rec;
if lv_found = 'Y' then
lv_lolimit := 'Lower limit'; lv_uplimit := 'Upper limmit';
lv_tr := 'Result'; lv_tc := 'Comment';
lv_itpv := 'INTERPRETED TEST RESULT'||chr(10)||'-----------------------'||chr(10)||lv_lolimit||lv_uplimit||lv_tr||lv_tc||chr(10);
open read_c4_rec;
loop
fetch read_c4_rec into c4_rec;
exit when read_c4_rec%notfound;
lv_lolimit := to_char(c4_rec.tivd_lolimit,'999990.999');
lv_uplimit := to_char(c4_rec.tivd_uplimit,'999990.999');
lv_tr := c4_rec.tivd_value;
lv_tc := c4_rec.tivd_rr_desc;
lv_itpv := lv_itpv||chr(10)||lv_lolimit||lv_uplimit||lv_tr||lv_tc;
end loop;
close read_c4_rec;
end if;
note_desc := lv_itpv||chr(10)||chr(10);
end if;
if ltrim(rtrim(c1_rec.ti_attached_cmt)) is not null then
lv_note_flag := 'Y';
note_desc := note_desc||'ATTACHED COMMENTS'||chr(10)||'-----------------'||chr(10)||ltrim(rtrim(c1_rec.ti_attached_cmt))||chr(10);
end if;
begin
select unit_name into ti_unit
from unit_tbl
where unit_code = c1_rec.ti_unit;
exception when no_data_found then
ti_unit := null;
end;
lv_desc := lv_desc ||'<td><input type="text" name="f06" size="20" maxlength="20" value="'||ti_unit||'" /></td>';
begin
select imh_insurance_code, imh_curr_p1 into ti_insurance_code, ti_price
from item_masterh
where imh_code = c1_rec.ti_code;
exception when no_data_found then
ti_insurance_code := null; ti_price := null;
end;
lv_desc := lv_desc ||'<td><input type="text" name="f07" size="20" maxlength="20" value="'||ti_insurance_code||'" /></td>'||'<td><input type="text" name="f08" size="14" maxlength="14" value="'||to_char(ti_price)||'" /></td>';
lv_ti_code := c1_rec.ti_code;
lv_tr_cnt := 0;
lv2 := '<table width="100%" border="0" bgcolor="#009900" cellspacing="0">';
OPEN READ_C2_REC;
LOOP
FETCH READ_C2_REC INTO C2_REC;
EXIT WHEN READ_C2_REC%NOTFOUND;
lv_tr_cnt := lv_tr_cnt + 1;
if c2_rec.tr_agecode = 'Y' then
lv_age := c2_rec.tr_ageto / 365;
elsif c2_rec.tr_agecode = 'M' then
lv_age := c2_rec.tr_ageto / 30;
else
lv_age := c2_rec.tr_ageto;
end if;
ti_sex := c2_rec.tr_sex_code;
ti_age := lv_age||c2_rec.tr_agecode;
ti_tr_desc := ' '||c2_rec.tr_range_desc;
ti_lolimit := c2_rec.tr_normal_lolimit;
ti_uplimit := c2_rec.tr_upper_uplimit;
ti_plolimit := c2_rec.tr_panic_lolimit;
ti_puplimit := c2_rec.tr_panic_uplimit;
if c2_rec.tr_range_desc = 'MRR' then
lv_note_flag := 'Y';
note_desc := 'MRR DESCRIPTION'||chr(10)||'---------------'||chr(10)||c2_rec.tr_mrr_desc||chr(10)||chr(10)||note_desc;
end if;
if lv_note_flag = 'Y' then
fv_note_flag := 'Y';
end if;
lv2 := lv2 || '<tr><td><input type="text" name="f09" size="1" maxlength="1" value="'||ti_sex||'" /></td>'||'<td><input type="text" name="f10" size="10" maxlength="10" value="'||to_char(ti_age)||'" /></td>'||'<td><input type="text" name="f11" size="30" maxlength="30" value="'||ti_tr_desc||'" /></td>'||'<td><input type="text" name="f12" size="10" maxlength="10" value="'||to_char(ti_lolimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f13" size="10" maxlength="10" value="'||to_char(ti_uplimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f14" size="10" maxlength="10" value="'||to_char(ti_plolimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f15" size="10" maxlength="10" value="'||to_char(ti_puplimit,'99990.999')||'" /></td></tr>';
END LOOP; lv2 := lv2||'</table>';
CLOSE READ_C2_REC;
if lv_tr_cnt = 0 then
if lv_note_flag = 'Y' then
fv_note_flag := 'Y';
end if;
end if;
lv_desc := lv_desc||'<td><input type="hidden" name="f16" value="'||fv_note_flag||'" /></td>'||'<td><input type="hidden" name="f17" value="'||note_desc||'" /></td>';
lv_desc := lv_desc||'<td>'||lv2||'</td></tr></tbody>';
htp.p(lv_desc);
END LOOP;
CLOSE READ_C1_REC;
htp.p('</table>');
END;
Thanks you very much in advance!First thing I'd say is that you're code doesn't compile:
lv_title := ' // <----Secondly, does no-one use comments anymore? Isn't this drilled into people in programming classes at colleges? There's a whole bunch of code there but not much in the way of explanation as to what you are trying to achieve. It might make perfect sense to you now but try going back to it in a year and see if you can untangle it's purpose.
Thirdly, is there a specific reason why you've chosen to manually generate a report in PL/SQL, rather than delegating it to a report region? I understand that for particular formatting requirements (denormalised data, cells-within-cells etc), it is occasionally necessary to go to these lengths but I can't help but feeling a well-written query could simplify a lot of this, particularly the references multiple cursors. -
Multiple SQL queries in additional PL/SQL code in Report
Hello gurus,
I have a form in my portal populated some searching parameters and these parameters inserted into some temporary tables such as name_temp, addr_temp. And then I have a report that run based on these parameters, I have added additional PL/SQL code in the report at the time after the header was displayed. The code is as follows:
declare
checkname varchar2(40);
checkaddr varchar2(100);
begin
select emp.name into checkname from emp
where name = (select name from name_temp);
select personnel.addr into checkaddr from personnel
where addr = (select address from addr_temp);
end;
The problem I have is always the first SQL statement was executed, but not the second one, nor the third one. Does PL/SQL only supports one SQL statement per call? Please help. Is there a better way to handle this case?
Thanks.
VinceHello gurus,
I have a form in my portal populated some searching parameters and these parameters inserted into some temporary tables such as name_temp, addr_temp. And then I have a report that run based on these parameters, I have added additional PL/SQL code in the report at the time after the header was displayed. The code is as follows:
declare
checkname varchar2(40);
checkaddr varchar2(100);
begin
select emp.name into checkname from emp
where name = (select name from name_temp);
select personnel.addr into checkaddr from personnel
where addr = (select address from addr_temp);
end;
The problem I have is always the first SQL statement was executed, but not the second one, nor the third one. Does PL/SQL only supports one SQL statement per call? Please help. Is there a better way to handle this case?
Thanks.
Vince -
How can one read a Excel File and Upload into Table using Pl/SQL Code.
How can one read a Excel File and Upload into Table using Pl/SQL Code.
1. Excel File is on My PC.
2. And I want to write a Stored Procedure or Package to do that.
3. DataBase is on Other Server. Client-Server Environment.
4. I am Using Toad or PlSql developer tool.If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
1. Get your DBA to create directory object in oracle using the following command:
create directory TEST_DIR as ‘directory_path’;
Note: This directory is on the server.
2. Grant read,write on directory directory_object_name to username;
You can find out the directory_object_name value from dba_directories view if you are using the system user account.
3. Logon as the user as mentioned above.
Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
function getData(p_filename in varchar2,
p_filepath in varchar2
) RETURN VARCHAR2 is
input_file utl_file.file_type;
--declare a buffer to read text data
input_buffer varchar2(4000);
begin
--using the UTL_FILE in built package
input_file := utl_file.fopen(p_filepath, p_filename, 'R');
utl_file.get_line(input_file, input_buffer);
--debug
--dbms_output.put_line(input_buffer);
utl_file.fclose(input_file);
--return data
return input_buffer;
end;
Hope this helps. -
APEX,PDF's, BI Publisher and SQL Query returning SQL code..
I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
Here is my dilemma:
I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
Thank you,
Tony Miller
UTMB/EHN
Title adjusted to allow people to know what I am talking about...
Message was edited by:
Tony MillerTony,
You can find the log as follows:
- go to http://[yourserver]:[yourport]/em
- logon to OC4J EM: oc4jadmin/[yourpassword]
- click on "logs" at the bottom of the page
- in the hgrid/tree, expand OC4J->home->Application
xmlpserver
- click on view log icon
You can also observe what's going on in BI Publisher
by going to the command prompt from where you started
it.
Or, as a third option, you can locate the file on
your file system, depending on your setup, the path
would be something similar to this:
\oracle\product\10.2.0\bip\j2ee\home\application-deplo
yments\xmlpserver\application.log
With that said though, I don't expect you'll find
much in there that would help with your particular
problem. I suspect you either get no rows in your XML
at runtime, due to some session state issues, or your
XML structure does in fact not match your RTF
template.
I'm not quite following your problem description,
i.e. when did you do what and are you associating
your report layout with a report query or report
region. So just some general notes, your query needs
to be parseable at design-time, when exporting the
XML, so that you get the XML file with the proper
column names derived from your query. If you want to
use your RTF template with a standard report region,
you must export the XML file first using the advanced
XML structure option. And of course the column names
in your report query need to match the column names
in your report region.
Perhaps this helps you further diagnose what's going
on, if you have additional information that could
help, let me know. And if you could stage this on
apex.oracle.com, I'd be happy to take a look.
Regards,
MarcMarc,
Thanks for looking at this issue. Below find my remarks to your questions..
Re: your query needs
to be parseable at design-time, when exporting the
XML, so that you get the XML file with the proper
column names derived from your query.At the start of this process, the query code was a function in a package. The function was returning an SQL select statement, for a report region on a page. I took the select statement, built an application query to build a sample of the xml for BI Publisher desktop (Add-on for Word). The code was producing the usual Col01, Col02.. since at design time that is were the column names.
When I then took the xml from this and built the rtf for loading into my APEX application.
When testing the Application Query with this RTF report layout, I am getting PDF's. When using it with the report region sending an xml feed to BI Publisher I am getting nothing back.
I have since taken the sql code and moved it back into the report region, and set the region to have a type of straight SQL Query. I have even tried to hard-code the parameters I was getting from the page to limit data returned.
Is it possible to see the xml being produced by the APEX page?
Re: Stage this on apex.oracle.com.. I would love to, but we would have HIPPA issues if I posted the data on a public website.
Can I send you the RTF file and the xml file that the application query is creating to see if there something weird about them?
Thank you,
Tony Miller
UTMB/EHN -
Performance tuning in PL/SQL code
Hi,
I am working on already existing PL/SQL code which is written by someone else on validation and conversion of data from a temporary table to base table. It usually has 3.5 million rows. and the procedure takes arount 2.5 - 3 hrs to complete.
Can I enhance the PL/SQL code for better performance ? or, is this OK to take so long to process these many rows?
Thanks!
YoginiCan I enhance the PL/SQL code for better performance ? Probably you can enhance it.
or, is this OK to take so long to process these many rows? It should take a few minutes, not several hours.
But please provide some more details like your database version etc.
I suggest to TRACE the session that executes the PL/SQL code, with WAIT events, so you'll see where and on what time is spent, you'll identify your 'problem statements very quickly' (after you or your DBA have TKPROF'ed the trace file).
SQL> alter session set events '10046 trace name context forever, level 12';
SQL> execute your PL/SQL code here
SQL> exitWill give you a .trc file in your udump directory on the server.
http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php
Also this informative thread can give you more ideas:
HOW TO: Post a SQL statement tuning request - template posting
as well as doing a search on 10046 at AskTom, http://asktom.oracle.com will give you more examples.
and reading Oracle's Performance Tuning Guide: http://www.oracle.com/pls/db102/to_toc?pathname=server.102%2Fb14211%2Ftoc.htm&remark=portal+%28Getting+Started%29 -
How to use new sequence when one is reached its maxvalue in PL SQL code
Hi,
Currently, I am populating a unique product serial number in a table column using a sequence call to generate new number. For different products, I have different sequences and in my PL SQL code usiing IF..Else block I populate serial number for different products. For one most selling product sequence, we are reaching a Max value in production in a month and to make sure that application will continue to work fine for various end users without getting any error on their screens, I want my code to switch to new sequence automatically. I just need to add another if condition but my problem is how to find accurately when max value is reached for old sequence.
As call to old sequence can happen in different sessions there could be inconsistency and can end up at error. My new sequence value has to start with AV1000. Please suggest.
My old sequence look like this :
SEQUENCE Prd
INCREMENT BY 1
START WITH AS1000
MAXVALUE AS9999
MINVALUE AS1000
CYCLE NOCYCLE
CACHE 2
Order Yes;
Edited by: user11695088 on Jul 15, 2009 12:14 AMCatch the exception and use your new sequence. But somehow, I'm not liking your alternative approach.
SQL> set line 300
SQL> set pages 50000
SQL> set serveroutput on
SQL> create sequence testing_seq increment by 1 start with 1 maxvalue 3
2 /
Sequence created.
SQL>
SQL> create or replace procedure test_seq_proc(p_seq out number)
2 is
3 begin
4 select testing_seq.nextval
5 into p_seq
6 from dual;
7 --
8 dbms_output.put_line(p_seq);
9 --
10 end;
11 /
Procedure created.
SQL> declare v_out number;
2 begin
3 test_seq_proc(v_out);
4 end;
5 /
1
PL/SQL procedure successfully completed.
SQL> /
2
PL/SQL procedure successfully completed.
SQL> /
3
PL/SQL procedure successfully completed.
SQL> /
declare v_out number;
ERROR at line 1:
ORA-08004: sequence TESTING_SEQ.NEXTVAL exceeds MAXVALUE and cannot be instantiated
ORA-06512: at "ETL_ADMIN.TEST_SEQ_PROC", line 4
ORA-06512: at line 3
SQL>Cheers
Sarma. -
Hi,
I have written a code to upload data from csv file to oracle table. it gives me a funny error. I have given below the sample contents of .csv file
"4951","TCSPL (TRADING A/C)","470","TISCO",20050419,"P",362.6550,212,0.00
"4951","TCSPL (TRADING A/C)","470","TISCO",20050419,"S",361.7500,212,-191.86
"4951","TCSPL (TRADING A/C)","477","ASHOKLEY",20050928,"P",28.5000,200,0.00
"4951","TCSPL (TRADING A/C)","477","ASHOKLEY",20050928,"S",28.4960,200,-0.80
for the first time if i run the sql code it uploads first 2 records and does not upload third record, if i change the figure of =-191.86 to 191.86 (if i remove - mark ) then it uploads all the records, if i reverse it back it does not the third record, the structure of the table is like this ( the data column where this data get inserted is number(15,4) datatype)
this type of problem is happening with that perticular row only, though several such kind of combination is there in the csv file.
sQL> desc UNITISCLTRXN
Name Null? Type
CLCODE VARCHAR2(10)
CLNAME VARCHAR2(120)
SCCODE VARCHAR2(10)
NSESYMBOL VARCHAR2(10)
TRDDATE DATE
PURSAL VARCHAR2(1)
RATE NUMBER(15,6)
CLQTY NUMBER(10,2)
PROFIT NUMBER(15,4)
the sql code i have written is as below
PROCEDURE upload_unitiscltrxn IS
file_id text_io.file_type;
crec unitiscltrxn%rowtype;
linebuf VARCHAR2(1000);
i number:=1;
len number:=0;
spos number:=0;
tpos number:=0;
var varchar2(1000);
mon varchar2(5);
cnt number:=0;
errnum NUMBER := ERROR_CODE;
errtxt VARCHAR2(80) := ERROR_TEXT;
errtyp VARCHAR2(3) := ERROR_TYPE;
begin
Delete from unitiscltrxn;
File_id := Text_IO.Fopen('M:\UNITIS\db\final.csv', 'r');
Text_IO.Get_Line(File_id,linebuf);
cnt :=1;
while linebuf is not null loop
IF CNT<>1 THEN
Text_IO.Get_Line(File_id,linebuf);
END IF;
cnt :=1+cnt;
len := length(linebuf);
spos :=1;
i:=1;
tpos :=0;
var:='';
mon:='';
while i < 10 loop
tpos := instr(linebuf,',',spos);
if tpos >0 then
var :=substr(linebuf,spos,tpos-spos);
else
var :=substr(linebuf,spos);
end if;
----------get values into variable.------------------
If i =1 then
Crec.clcode := Replace(var,'"','');
ElsIf i =2 then
Crec.clname := Replace(var,'"','');
ElsIf i =3 then
Crec.sccode := Replace(var,'"','');
ElsIf i =4 then
Crec.nsesymbol := Replace(var,'"','');
ElsIf i =5 then
select Decode(substr(var,5,2),1,'JAN',2,'FEB',3,'MAR',4,'APR',5,'MAY',6,'JUN',7,'JUL',8,'AUG',
9,'SEP',10,'OCT',11,'NOV',12,'DEC') into mon from dual;
Crec.trddate := to_date(substr(var,7)||'-'||mon||'-'||substr(var,1,4),'DD-MON-YYYY');
ElsIf i =6 then
If var = '"P"' Then
Crec.pursal :='P';
Elsif var = '"S"' Then
Crec.pursal :='S';
end if;
--Crec.pursal := var;
ElsIf i =7 then
Crec.rate := var;
ElsIf i =8 then
Crec.clqty := var;
ElsIf i =9 then
Crec.profit := var;
End If;
i:=i+1;
spos:=tpos+1;
end loop;
INSERT INTO UNITISCLTRXN VALUES(crec.clcode, crec.clname ,crec.sccode ,crec.nsesymbol,
crec.trddate,crec.pursal,crec.rate,crec.clqty,crec.profit);
text_io.new_line(file_id, 1);
End loop;
EXCEPTION
WHEN no_data_found THEN
Text_IO.Put_Line('Closing the file...');
Text_IO.Fclose(file_ID);
WHEN OTHERS THEN
Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt||'FF'||DBMS_ERROR_CODE);
Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt);
END;
END;
Thanks
UdayHi
Try to debug you procedure inserting a better exception handling and some dbms_output.put_line.
E.g.
ElsIf i =9 then
Crec.profit := var;
dbms_output.put_line(var || ' - ' Crec.profit);
End If; Try to put the exception handling in the loop ... while i < 10 loop ... .
I don't think that it's an Oracle bug. It's a human error in your code!
Bye, Aron -
hi
How can we solve SQL injection problem in JDBC ?
this means if we have a form with text field and the user must enter a number say 4 , instead he entered "4 or true" this will concatenated with the SQL query and return all records because of "or true"....
is there any solutions ?
i tried PreparedStatment and it words but not alwayes
good lucki clearfied this in my first post
if u didnt got what i mean u can google it
http://www.google.com
thanksYou didn't gently provide keywords, like I always do, so I cannot learn from you.
Well, with a "reproduceable example" I mean that you have to post a short but complete working code snippet which reproduces the problem. So that we can copy'n'paste it in our environment here and test/debug it ourself and then eventually confirm the SQL injection. -
Hi,
I am using java.sql.Date and preparedStatement for SQL select query, something like
: select app_id, entry_date, message from testTable where entryDate >= ? and entryDate <= ?
for example i'am supplying date as yesturday's date and i want data where
say: 24-Oct-2005 12:00:00AM to 24-Oct-2005 11:59:59PM, basically whole days data.
<code>
SimpleDateFormat formatter =
new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
SimpleDateFormat formatter1 =
new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss aaa", Locale.US);
String new1 = formatter1.format(formatter.parse(dateStr));
System.out.println("new1 : "+ new1);
Date date = new Date(formatter1.parse(new1).getTime());
long nextDate = date.getTime()+(23*60*60*1000);
System.out.println("d: " + date);
System.out.println("next: " + new Date(nextDate));
</code>
problem is this code giving me same outputs, whereas, i need to supply, different timings to the same date.
Thanks to anyone who can help me.I think the easier way is to use Calendar.getInstance() to return a Calendar instance and then use the various set() methods to set the time to midnight or the second before midnight of the next day.
See the API docs for java.util.Calendar.
- Saish -
Explain plans for PL/SQL code?
Hi!
I am pulling SQL statements (select, insert, update, delete, etc.) from PL/SQL code and producing explain plans. Some of the delete statements have "WHERE CURRENT OF" in them which produces an ORA-3001 error (feature not implemented) error. How can I do an explain plan of these statements? Can I replace "WHERE CURRENT OF" with "=" to get a plan? How far off will the plan be? Any suggestions, ideas, etc. greatfully appreciated!
This is Oracle 9.2.0.4/5 on AIX if it makes a difference.
Thanks!
Dave VenusWHERE CURRENT OF shouldn't be a problem. Here above an example on 9.2.0.4 on AIX5.2 :
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> create table TBL_USER_PROFILE_CATEGORY
2 as
3 select 654 id_category, 1103 id_user from dual union all
4 select 654 id_category, 1104 id_user from dual union all
5 select 18 id_category, 1103 id_user from dual union all
6 select 629 id_category, 1103 id_user from dual union all
7 select 110 id_category, 1103 id_user from dual union all
8 select 110 id_category, 1104 id_user from dual union all
9 select 18 id_category, 1104 id_user from dual union all
10 select 37 id_category, 1103 id_user from dual union all
11 select 24 id_category, 1103 id_user from dual union all
12 select 7 id_category, 104 id_user from dual union all
13 select 37 id_category, 1104 id_user from dual union all
14 select 22 id_category, 1103 id_user from dual union all
15 select 22 id_category, 1104 id_user from dual union all
16 select 25 id_category, 1104 id_user from dual union all
17 select 25 id_category, 1103 id_user from dual ;
Table created.
SQL>
SQL> alter table TBL_USER_PROFILE_CATEGORY add primary key (id_category, id_use
Table altered.
SQL>
SQL> CREATE OR REPLACE
2 PROCEDURE P$UPDATE_TBL_USER_PROFILE_CAT(p_id_cat_old IN NUMBER) AS
3 p_id_category number;
4 p_id_user number;
5 cursor mycur is select id_category, id_user
6 from TBL_USER_PROFILE_CATEGORY
7 where id_category = p_id_cat_old
8 for update of id_category;
9 BEGIN
10 open mycur;
11 LOOP
12 FETCH mycur INTO p_id_category, p_id_user;
13 EXIT WHEN mycur%NOTFOUND;
14 BEGIN
15 DELETE FROM TBL_USER_PROFILE_CATEGORY
16 WHERE CURRENT OF mycur;
17 END;
18 END LOOP;
19 CLOSE mycur;
20 COMMIT;
21 EXCEPTION WHEN OTHERS THEN rollback;
22 END;
23 /
Procedure created.
SQL>
SQL> exec P$UPDATE_TBL_USER_PROFILE_CAT(654)
PL/SQL procedure successfully completed.
SQL> select * from TBL_USER_PROFILE_CATEGORY;
ID_CATEGORY ID_USER
18 1103
629 1103
110 1103
110 1104
18 1104
37 1103
24 1103
7 104
37 1104
22 1103
22 1104
25 1104
25 1103
13 rows selected.
SQL> Please, paste here what's your code...
Nicolas.
Maybe you are looking for
-
For some reason, there is no audio on my computer. And it only happens when Im on the interenet and not when im offline.
-
Please reply to this query asap
Create a matrix query to display the job,salary for that job based on department number and the total salary for that job for all departments,giving each column an app: heading JOB DEPTNO(10) 20 30 SUM(SAL) ANALYST 0 100 0 100 SALARY AND JOB AND DEPT
-
Can't create directory while in fakeroot
Hi all, I'm trying to create a PKGBUILD for mplabx. When the installer tries to create the directory /opt/microchip, it gets the error permission denied. My pkgbuild: # This is an example PKGBUILD file. Use this as a start to creating your own, # and
-
i have a iphone 4 can and its severly damaged can i goto the apple store and they give me a replacement even if i didnt buy it there?
-
SP01, list of output requests
Hi, from trx ME9F an user tried to print a purchasing document (purchase order) System didn't print any output. From SP01 I checked and I clicked on one of the spool requests that reports an error but there is not the cause of the error, I can see th