Stored Outline for Bind Variable
Hi,
Please let me know the use of stored outline to maintain the same execution plan for a sql which contains bind variable.
I know how to use stored outline for a sql which does not contain bind variable. But I want the use of stored outline for sql where bind variables have been used. Please provide an example.
Thanks,
Mrinmoy
Edited by: user3001930 on Aug 10, 2010 11:22 PM
Not sure as I don't use them myself, but on AskTom:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1396058400346694178
He says:
>
stored outlines are deprecated in 11g - replaced by query plan baselines.
http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/sqlplsql.htm#sthref2589
Similar Messages
-
Creating stored outlines for date datatype bind variable
While trying to create stored lines for a query having date datatype I get
ORA-00932: inconsistent datatypes: expected DATE got NUMBER error:
desc table_t1;
col1 number,
datecol date
CREATE OR REPLACE OUTLINE TEST FOR CATEGORY TEST
ON
select * from table_t1
WHERE T1.COL1 IS NOT NULL
AND T1.DATECOL BETWEEN TRUNC (:D1)
AND TRUNC (:D2)
+ 1Can someone please help me what am I doing wrong?
I also tried to declare variable of date from sqlplus but it seems sqlplus doesn't have any support for date datatype var declaration as bind variable.
Thanks
Kev
Edited by: Kevin_K on Jan 3, 2011 4:48 AMI think in this case you would have to take an approach like this:
alter session set set create_stored_outlines=true;
run your sql-statement (with a date bind variable), using anonymous plsql block.
alter session set create_stored_outlines=false;
Not sure though. It's been a while since I played around with outlines. -
Asking for bind variable where none is needed
Good Morning,
I am still working these regexp date_time project.
I have a problem where oracle is asking for a bind variable where it doesn't need any as far as I can see. I am trying to capture various date times in a column and formatting them into one default format used by oracle. Here is what I got which works before I wrap it in the TO_DATE function
There are many when then's but I am using only one here.
select case
when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
then regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')
else date_time
end as new_time
from raw_data;
The above statement works
Now when I want to format the date that I found with this:
select case
when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
else date_time
end as new_time
from raw_data;
I get a request to insert a value for the digit as a bind variable. The digit should be populated from the when statement when it returns not null when a date is found.
Could some one please tell me even if what I wrote here is even possible or make a suggestion to the syntax to get around this issue?
All this is going to be incorporated into an update statement later on.
I am running this on sql developer, oracle 11g.
Thanks for your help in this matter in advance.
regards,
AlFrom looking at the code, as you have not supplied any scripts to create a table and demonstrate the error...
Your case statement is trying to return two types
select case
when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
else date_time
end as new_time
from raw_data;or simply
select case when <expr>
then <RETURN A DATE>
else <RETURN A VARCHAR2>
end as new_time
from raw_data;The column cannot be both.
Sorry I don't know your requirements.
You could drop the else part and just return the converted date.
You could fetch it back in two columns, the ones you can convert in one column (Which would be an oracle date type),
the ones you cannot convert in another (which would be varchar2).
Cheers,
GP> -
How to use function v( ) for bind variable 30 char
I have the following process, try to load columns from table to the page. One of the column complains about > 30 char cannot use bind variable. I change to
V('c1.OBJ_OUT_SOURCIING_WAD_TYPE') but still not work.
Please help;
BEGIN
FOR c1 in ( SELECT *
FROM #OWNER#.OBJECT_OUT_SOURCING
WHERE OBJ_NAME = :P503_OBJ_NAME AND
OBJ_OWNER = :P503_OBJ_OWNER AND
DATABASE_NAME = :P503_DATABASE_NAME)
LOOP
:P503_OBJ_NAME := c1.OBJ_NAME;
:P503_OBJ_OWNER := c1.OBJ_OWNER;
:P503_DATABASE_NAME := c1.DATABASE_NAME;
:P503_APPL_NAME := c1.APPL_NAME;
:P503_OBJ_TYPE := c1.OBJ_TYPE;
:P503_OBJ_OUT_SOURCIING_WAD_TYPE := V('c1.OBJ_OUT_SOURCIING_WAD_TYPE');
END LOOP;
END;Che-Hwa,
Change this statement: :P503_OBJ_OUT_SOURCIING_WAD_TYPE := V('c1.OBJ_OUT_SOURCIING_WAD_TYPE'); to: htmldb_application.update_cache_with_write(p_name=>'P503_OBJ_OUT_SOURCIING_WAD_TYPE',p_value=>c1.P503_OBJ_OUT_SOURCIING_WAD_TYPE);Scott -
Prompt for bind variables in SQL developer
Hi!
Just installed the latest 3.2 version of SQL Developer, and tried to do an explain plan.
Now the tool prompts me for values for the bind variable. It didn't do that in my previous version (version 3. something).
Thats anoying :-)
How do I disable that feature?
Example:
explain plan for
select * from emp
where department_id = :1;
If i right click on the statement or press F10, I get no prompt for the bind variable...
Regards
SørenOld fashioned way, like this:
EXPLAIN PLAN FOR
SELECT * FROM scott.emp
where deptno = :1;
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
Executed with F5 gives me this output
plan FOR succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 190 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 5 | 190 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DEPTNO"=TO_NUMBER(:1))
13 rows selected -
Stored Procedure with bind variables
Hello,
I have problems when executing this sample code:
Procedure Test (..., in_Param IN CHAR, ...)
Query_Str := 'Select * from Table1 where column1 IN :in_Param';
Open Cursor1 For Query_Str Using in_Param;
This Cursor retuns rows when in_Param is 'A'
This Cursor does not return any row if in_Param is ('A', 'B')
Can you please help to track the error in this Query?
Many thanksIt seems to be that the bind variable is treated as a single discrete object. Hence
'Select * from Table1 where column1 IN :in_Param';
is functionally the same as
'Select * from Table1 where column1 = :in_Param';
so when in_Param is ('A', 'B'), what actually gets executed is
Select * from Table1 where column1 = 'A, B';
Not surprisingly this returns no rows.
You can of course do this:
'Select * from Table1 where column1 in( :x, :y, :z)';
Open Cursor1 For Query_Str Using :i, :j, :k;
So you could parse in_param yourself, populating the unused variables with nulls, so that if in_param = ('A, B') then i=A, j=B and k=null. Given that in 8i an IN string can have 1000 variables this could be a right mare if you don't put a cap on in_param.
Your alternative is not to use a bind variable for this statement.
rgds, APC -
Getting error for bind variables
Hello Experts ;
SQL> DECLARE
2 l_eid number;
3 l_name varchar2(30);
4 BEGIN
5 l_eid:=1000;
6 select name into l_name from tab1 where no = l_eid;
7 l_eid:=9999;
8 select name into l_name from tab1 where no = l_eid;
9 l_eid:=299999;
10 select name into l_name from tab1 where no = l_eid;
11* END;
PL/SQL procedure successfully completed.
when creating bind variables i am getting error :
SQL> variable b1 number;
SQL> exec :b1 :='select name from tab1 where no = :b1';
BEGIN :b1 :='select name from tab1 where no = :b1'; END;
* ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 1@ SY
SolomonYakobson wrote:
You need to explain "method not workable for me". I have no idea what method you are talking about and what are you trying to achieve.
SY.
SQL>DECLARE
v_value number;
v_dispaly varchar2(30);
BEGIN
v_value :=100000;
select name into v_display from tab1 where no = :v_value;
DBMS_OUTPUT.PUT_LINE(v_display);
v_value :=20000;
select name into v_display from tab1 where no = :v_value;
DBMS_OUTPUT.PUT_LINE(v_display);
v_value :=250000;
select name into v_display from tab1 where no = :v_value;
DBMS_OUTPUT.PUT_LINE(v_display);
* END;
RS>/
PL/SQL procedure successfully completed.
>> This is not workable for me , Here getting error >>
SQL> DECLARE
2 variable b1 number;
3 exec :b1;
4 BEGIN
5 select name from tab1 where no =: b1;
6* END;
RS>/
variable b1 number;
ERROR at line 2:
ORA-06550: line 2, column 13:
PLS-00103: Encountered the symbol "NUMBER" when expecting one of the following:
:= . ( @ % ; not null range default character
Thanks ! -
How to see values for bind variables in statspack output
Hi all.
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
PL/SQL Release 9.2.0.4.0 - Production
CORE 9.2.0.3.0 Production
TNS for Solaris: Version 9.2.0.4.0 - Production
NLSRTL Version 9.2.0.4.0 - Production
Running sprepsql.sql to get full sql and explain plan from hash value...
SQL comes back with bind variables :1, :2, :3 etc.
How can I find out what the values are for the bind variables so i can plug them in and run them in test db?
Thanks for all your help.I don't have a trace file...
I need to know what the values are and if there is anyway to see them from the output of the sprepsql...
currently looks like:
select
r.status,
NVL(r.required_date, to_date('12/31/3999', 'MM/DD/YYYY')),
r.calc_qty,
r.issued_qty,
r.workorder_type,
r.workorder_base_id,
r.workorder_lot_id,
r.workorder_split_id,
r.workorder_sub_id,
r.operation_seq_no,
r.piece_no,
r.warehouse_id,
0,
wbs_code
from
REQUIREMENT r
where r.part_id = *:1*
and r.workorder_type = 'W'
and r.calc_qty > r.issued_qty
and r.subord_wo_sub_id is null
AND STATUS IN ('R', 'S','U','H','F')
AND WAREHOUSE_ID = *:2*
Thanks for your help. -
Memory Dump for Bind Variable included in 10046 trace file
A curious thing I've seen today. While looking through an extended Oracle Trace file, I see the following:
=====================
PARSING IN CURSOR #26 len=88 dep=0 uid=28 oct=6 lid=28 tim=2667421262 hv=3259943383 ad='4bbb4ad8'
UPDATE V_QRTZ_TRIGGERS SET JOB_DATA = :1 WHERE TRIGGER_NAME = :2 AND TRIGGER_GROUP = :3
END OF STMT
PARSE #26:c=0,e=54,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=2667421260
BINDS #26:
bind 0: dty=113 mxl=3876(3876) mal=00 scl=00 pre=00 oacflg=03 oacfl2=0 size=3876 offset=0
bfp=0cd99aa4 bln=3876 avl=86 flg=05
value=
Dump of memory from 0x0CD99AA4 to 0x0CD99AFA
*CD99AA0 01005400 00002C01 00000100 [.T...,......]*
*CD99AB0 00000100 EB23EF03 581D0000 571D0000 [......#....X...W]*
*CD99AC0 0F000F00 00000000 0F005920 0E14E12F [........ Y../...]*
*CD99AD0 CDE21ADA 00000000 737E06D9 0400FB09 [..........~s....]*
*CD99AE0 07000F00 800387E6 A17B3F20 0000000E [........ ?{.....]*
*CD99AF0 571D0000 EE56CF00 00001500 [...W..V.....]*
bind 1: dty=1 mxl=128(45) mal=00 scl=00 pre=00 oacflg=03 oacfl2=10 size=256 offset=0
bfp=0cd99984 bln=128 avl=15 flg=05
value="EC-MHM Retrieve"
bind 2: dty=1 mxl=128(96) mal=00 scl=00 pre=00 oacflg=03 oacfl2=10 size=0 offset=128
bfp=0cd99a04 bln=128 avl=32 flg=01
value="2BBDE87AF15D4B5E867AB6482D7D58C8"
BINDS #9:
bind 0: dty=1 mxl=32(18) mal=00 scl=00 pre=00 oacflg=03 oacfl2=1 size=192 offset=0
bfp=0c2de90c bln=32 avl=18 flg=05
value="EC_SCHEDULE_PIN_TO"
bind 1: dty=1 mxl=128(15) mal=00 scl=00 pre=00 oacflg=13 oacfl2=1 size=0 offset=32
bfp=0c2de92c bln=128 avl=15 flg=01
value="EC-MHM Retrieve"
bind 2: dty=1 mxl=32(32) mal=00 scl=00 pre=00 oacflg=13 oacfl2=1 size=0 offset=160
bfp=0c2de9ac bln=32 avl=32 flg=01
value="2BBDE87AF15D4B5E867AB6482D7D58C8"
EXEC #9:c=15625,e=1060,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,tim=2667424863
FETCH #9:c=0,e=95,p=0,cr=4,cu=0,mis=0,r=1,dep=1,og=1,tim=2667425091
FETCH #9:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=0,tim=2667425236
Is this normal and is it caused by size of Bind Variable?
Kind regards,
TRONdIt's normal and and happens due to bind variable datatype. In your case this is blob, (there are a couple of other datatypes - timestamp among other) which will be represented that way in the trace file.
Best regards
Maxim -
hi all
i have a master detail detail page
a b c
a as form
b as table
c as table
in c i have LOV with a bind variable which tack value from 'a' , and there is no relation between 'a' an 'c'.
i tried to use groovy to get value form view 'a' like this
adf.object.viewa.variablex
but i always got this error
oracle.jbo.expr.JISyntaxError: Variable SecSystemVO not recognized
any idea ?!?!?!?thanx its working good and lOV get data but when i select row from LOV
oracle.jbo.expr.JISyntaxError: Variable viewobject not recognized
Edited by: Mohammed Abdel Aziz on May 8, 2011 4:07 AM -
Using arrays as type for bind variable
Hi all,
I have this stored procedures that takes an array of strings as an argument:
CREATE OR REPLACE PACKAGE mypackage AS
TYPE StringArray IS VARRAY(100) OF VARCHAR2(16);
PROCEDURE doSomething(v_strings IN StringArray);
END;
My java code looks something like:
String[] strings = ...;
CallableStatement cs = connection.prepareCall("CALL mypackage.doSomething(?)");
cs.setObject(1, strings, java.sql.Types.ARRAY);
calling the setObject method throws a SQLException: invalid column type.
I have tried to change the call to:
cs.setArray(1, new SqlStringArray(strings))
where SqlStringArray is a wrapper around String[] that implements the java.sql.Array interface. This however throws a ClassCastException in oracle.jdbc.driver.OraclePreparedStatement. The latter is assuming it is receiving a class that implements yet another interface I guess.
I also tried:
cs.setObject(1, strings, java.sql.Types.VARCHAR);
but that also throws a SqlException: invalid conversion requested
Does anybody know how to bind String[] into a PreparedStatement?
Any help is appreciated.
Rudi.Made some progress. I am getting the OracleConnection from the WrappedConnection. This is a temporary solution for me so I would appreciate a final solution from anybody.
I am now constructing a oracle.sql.ARRAY with an appropriate oracle.sql.ArrayDescriptor. I have found out that the type must be defined on a global level rather than in the scope of the package. Would be good if an Oracle expert could confirm that but I am happy to live with that.
The IN parameter is correctly bound using the ARRAY instance but I am getting the following error when actually executing the statement:
ORA-06512: Reference to uninitialized collection: at "BLUETEST_MYPACKAGE", line 57
Now I have found quite some problem descriptions with that ORA error but all are dealing with OUT parameters that were not correctly initialized, i.e. the array constructor had not been called. In my case however, the array is initialized at by the java code and then bount to the sql statement. You would expect that the jdbc driver takes care of correctly initializing the PL/SQL collection wouldn't you.
Does anybody know if I need to do anything extra?
Many thanks,
Rudi. -
Is it possible to set bind variable for picklist?? for messageChoice
we are trying to develop one new page in local JDeveloper.
we have requirement for passing a bind variable to a picklist. is it possible?
Item Type : messageChoice
Query:
SELECT DISTINCT TO_CHAR (effective_date, 'YYYY') TYPE
FROM pay_assignment_actions a, pay_payroll_actions b
WHERE a.payroll_action_id = b.payroll_action_id
AND assignment_id =
(SELECT assignment_id
FROM per_assignments_x
WHERE person_id = :person_id AND primary_flag = 'Y'
AND assignment_type = 'E')
AND a.action_status = 'C'
AND b.payroll_action_id IN (SELECT payroll_action_id
FROM pay_payroll_actions_v
WHERE action_type IN ('P'))
AND b.payroll_action_id IN (SELECT payroll_action_id
FROM xxilo_pre_payments)
ORDER BY 1 DESC
processRequest() code:
PayslipAMImpl am=(PayslipAMImpl)pageContext.getApplicationModule(webBean);
YearPicklistVOImpl yvo=(YearPicklistVOImpl)am.getYearPicklistVO1();
Number t = new Number(pageContext.getEmployeeId());
yvo.setWhereClauseParams(null);
yvo.setWhereClauseParam(0,t);
for this query & code we are getting
ERROR:
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
if we hardcoded person_id in query to some value then we are getting results without any error.user603084 ,
In the query you have specifies bind variable as :person_id , but in your VO execution code you are setting value for bind variable :1
yvo.setWhereClauseParam(0,t);
You need to change the bind variable in query , like :1
and then execute the query of VO, as you have done. Also do executeQuery, after setting bind variables.
--Mukul -
How to pass a value to a bind variable in a query report in oracle apex
Hi Guys,
I have requirement to send weekly reports via email to some users. The users should receive their own records in the report. The user details is stored in a table. What I am planning to do is to create a report query in oracle apex to generate the report and then run a function/procedure via a scheduler to email the report to respective users. Now my query is ............. is it possible to pass a value (user name) to the report query to pull records of only that user? I know we can have bind variables in the report query but I have no idea how to pass a value for bind variables from a function/procedure.
Can anyone help me on this issue or suggest a better approach?
Thanks,
SanYou need to use dynamic sql
But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
This forum is specifically for SQL Server
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Hi All,
I have one application(Java) in which the front end sends a list of values to backend(Oracle). The issue is i dont know how many number of parameters(values) would be there, it depends all on front end. But i want these values in my backend processing and want to use them as bind variables, so that i can build dynamic sqls and make dynamic calls.
Is there any way that i can declare all the values what i get from front end as bind variables so that they would be available for that user session and the backend can directly refer them as a normal variable, without referring to any other object.
Thanks in advance.Dear,
Thanks for your answer, but the problem here is how to declare those variables ? if i declare them in a store procedure they would be local to that procedure and wont be available as bind variables.No.
When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of yourcode and uses bind variables behind the scene.
So, if you declare your variables inside a stored procedure, they will be automatically considered as bind variables. You don't have to care about. This is how PL/SQL (static SQL) works.
The only situation where you have to look carefully to the use of bind variable within PL/SQL is when you use Dynamic sql into stored procedures or functions (this is in fact another reason to avoid using dynamic SQL).
However, you need take care of the application which is calling your stored procedure. This calling application should call your stored procedure using input parameters as bind variables.
Otherwise, the library cache of your shared pool will be full of calls to your stored procedure.
Put it simply,
(a) do what you want inside your PL/SQL strored procedure (static SQL and not Dynamic SQL)
(b) call your stored procedure using bind variables
Hope this helps
Mohamed Houri -
LOV(af:selectOneChoice) with bind variable in af:table
Hi All,
I have a table where a column is defined as dropdown(af:selectOneChoice). The query for selectOneChoice has a bind variable which needs to be set as a value from the base view Object corresponding row.
Suppose a table Employee
EmpId EmpName EmpType Authorization
101 John Temp No
The above table is created as af:table and 'Authorization' is implemented as dropdown(af:selectOneChoice) . The selectOneChoice has a query(AuthorizationLovVVO) with bind variable . For each row of af:table(EmployeeVO) , af:selectOneChoice query(AuthorizationLovVVO) requires
the corresponding row(EmployeeVO) 'EmpType' to be set as value of bind variable.
Can you please suggest how can we achieve this functionality.
Edited by: 907302 on Oct 17, 2012 7:22 AM
Edited by: 907302 on Oct 17, 2012 7:22 AMI have checked the following post where it has been suggested to access the the current row value as groovy expression.
groovy for bind variable
Suppose my AM name is 'TestAM' , i have tried the below expressions for value of bind variable but it does not work :
1) adf.object.TestAM.findViewObject('EmployeeVO1').currentRow.EmpType
2) adf.object.TestAMDataControl.findViewObject('EmployeeVO1').currentRow.EmpType
None of the above expressions work and i get the error while running the page as 'Variable NotesAM is not recognized.' / 'Variable NotesAMDataControl is not recognized.' .
Can you please suggest if we can achieve the functionality using this approach . Also let me know if i am missing something in the above expression.
Maybe you are looking for
-
ITunes 6.0.2 and iPod 5G problem
Hi, My mac freezes at random moments when my iPod (5G 60Gb) is connected and iTunes (6.0.2) is running. At least, I THINK that's causing the freezes, since I have been able to work perfectly since I ejected the iPod 2 hours ago (it is still connected
-
Reading all the channels for a FP-AI-100 through an Advise.vi but I need to read the Max & Min from channels 0 & 1. How is this done? Thanks
-
Hi, I am trying to develop a simple applet where a user can click on the screen to add jbuttons at the location of the mouse click. I have written an overly complex set of code that tries to achieve this goal, and in the end I have come close. My app
-
Xserve G4 Dual 1.3GHz PCI Options?
I just picked up a Dual 1.3GHz G4 Xserve. I was wondering what my PCI options are. I was looking for what exact video cards work. So far I have only came up with the ATI8500 I believe. Is there any SATA cards that work to add external storage? Any in
-
Using temporary tables with a ref. cursor
I want to use a temporary table to populate certain data and then return a ref cursor fetching data from the temporary table. 1. Will this approach work ? 2. Do I need to drop the temporary table ? Can I drop the table as a last statement in the stor