Bind variables limit and overhead in single query
HI,
I've got query with 348 bind variables used in a way like :
select * from table
where
col1 = :1 and col2 = :2
AND apl_id in (:3, :4 ... , :348)
is there any overhead related to such high bv number ?
The session with that query is using about 160MB of PGA (mostly UGA about 150MB).
Is that somehow related ?
I'm on 9.2.0.8 EE , AIX .
Regards
G
You can use an array instead of bind variables, it will give you flexibility and scalabilty,
Example
Note : replace sys.ODCIVarchar2List with desc sys.dbms_debug_vc2coll for 9i
Select emp.* from emp,
table (sys.ODCIVarchar2List ('SCOTT','ALLEN','KING','KINGDOM'))
where column_value=ename
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7839 KING PRESIDENT 17-NOV-81 5000 10
desc sys.ODCIVarchar2List
sys.ODCIVarchar2List VARRAY(32767) OF VARCHAR2(4000)
on 9.2.0.8 USE
desc sys.dbms_debug_vc2coll
sys.dbms_debug_vc2coll TABLE OF VARCHAR2(1000)HTH
SS
Similar Messages
-
Maximum Size of bind variables/model names in a SPARQL query
I was wondering what the maximum field size is for a bind variable (?'' being used in the subject or object within a triple) in a SPARQL query using the Jena Adapter for Oracle? The reason for this is that I keep getting Oracle exception (ORA-00972: identifier is too long) when executing queries.
The other question dealt with the max size of the model names? Is there anyway to increase this length by extending certain classes within the Jena Adapter for Oracle?
Thanks,
RahulHi,
For model names, because we use model names together with some suffixes to create namespace tables, application tables, and indexes, the length
has to be shorter than 30 bytes - 11 bytes = 19 bytes.
Note that 30 bytes limit is imposed by Oracle database. You cannot create a table with a name longer than 30 bytes.
11 bytes is the maximum suffix length imposed by Jena Adapter. We are considering to reduce it to 4 for the next Jena Adapter release.
For variable names, because we translate SPARQL to SQL queries (and variable name to column alias), there is the same 30 bytes limit.
Note that there are suffixes for variable names as well. For example, $RDFVID, $RDFLTYP, ... These suffixes are used internally.
Some simple tests for illustration purpose.
SQL> create table a23456789012345678901234567890(i int);
Table created.
SQL> create table a234567890123456789012345678901(i int);
create table a234567890123456789012345678901(i int)
ERROR at line 1:
ORA-00972: identifier is too long
-- Assume table X has a column I
SQL> select i as "v23456789012345678901234567890" from x;
no rows selected
SQL> select i as "v234567890123456789012345678901" from x;
select i as "v234567890123456789012345678901" from x
ERROR at line 1:
ORA-00972: identifier is too long
Hope it helps,
Zhe Wu -
Setting a bind variable in a Shared Component Report Query
I have defined a Shared Component Report Query in APEX using a bind variable similar to below
Select name, id , ....
from asset
where id = :id
I have also created a Report Region that displays a table where one of the columns contains a value I would like to be a link column that can launch the Report Query and pass its value to the bind parameter :id in the report query. This in turn would generate a pdf report for the details associated with that column. I am having problems setting the :id bind parameter. How do I do this?
Can anyone help?
ThanksThe bind values are set from session state. So if try something like this:
Select name, id , ....
from asset
where id = :P1_ID
With P1_ID being a page item, for which you set the session state / value before generating the PDF file. So assuming you already have a page with a report and a page item, and that page item is already used in your report, then you could just create a button to download the PDF, make sure the button is a submit button, and create a branch pointing to the report query URL (or in 3.1 use the create button wizard, to do this declaratively.)
Regards,
Marc -
ORA-01006:bind variable does not exist for the QUERY
Dear All,
Please help on below query :
DECLARE
P_ROTATION_NO GCH_VSL_REGN.ROTATION_NO%TYPE :=21;
P_VESL_NO GCH_VSL_MASTER.VESL_NO%TYPE := NULL;
P_VESL_NAME GCH_VSL_MASTER.VESL_NAME%TYPE:= NULL;
P_FROM_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
P_TO_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
P_FROM_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
P_TO_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
P_CLOSE_TYPE GCH_VSL_CLOSE_DTLS.CLOSE_TYPE%TYPE:= NULL;
P_RESULT_LIST SYS_REFCURSOR;
P_TOTAL_LENGTH NUMBER;
P_ERROR_MESSAGE VARCHAR2(1000);
lv_sql1 VARCHAR2(5000);
lv_sql2 VARCHAR2(5000);
lv_whereClause VARCHAR2(5000);
pv_text VARCHAR2(1000);
BEGIN
pv_text := NULL;
lv_whereClause := ' WHERE GVM.VESL_MASTER_NUM = GVR.VESL_MASTER_NUM
AND GVR.ROTATION_NO = GVCH.ROTATION_NO
AND GVCH.CLOSE_HDR_ID = GVCD.CLOSE_HDR_ID(+)
AND (:P_ROTATION_NO IS NULL OR
(:P_ROTATION_NO IS NOT NULL AND
GVR.ROTATION_NO LIKE % :P_ROTATION_NO %))
AND GVM.IS_VALID = 1';
lv_sql1 := 'SELECT COUNT(gvr.rotation_no)
FROM gch_vsl_close_hdr gvch,
gch_vsl_master gvm,
gch_vsl_regn gvr,
gch_vsl_close_dtls gvcd'||lv_whereClause;
dbms_output.put_line (lv_sql1);
EXECUTE IMMEDIATE lv_sql1 INTO :P_TOTAL_LENGTH
USING P_ROTATION_NO;
END;
I am getting below error when running the above query
ORA-01006: bind variable does not existwhy (date datatype assumed for variables with names containing DATE)
PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
P_RESULT_LIST OUT SYS_REFCURSOR,
P_TOTAL_LENGTH OUT NUMBER,
P_ERROR_MESSAGE OUT VARCHAR2
) AS
lv_sql1 VARCHAR2(4000);
lv_sql2 VARCHAR2(4000);
lv_whereClause VARCHAR2(4000);
BEGIN
-- pv_text := NULL;
lv_whereClause := ' WHERE gvm.vesl_master_num = gvr.vesl_master_num '||
' AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO '||
' AND (:P_ROTATION_NO IS NULL '||
' OR (:P_ROTATION_NO IS NOT NULL '||
' AND gvch.rotation_no LIKE ''%'' || :P_ROTATION_NO || ''%'' ' ||
' ) '||
' ) '||
' AND (:P_CM_REGN_NO IS NULL '||
' OR (:P_CM_REGN_NO IS NOT NULL '||
' AND gvr.cm_regn_no LIKE ''%'' || :P_CM_REGN_NO || ''%'' '||
' ) '||
' ) '||
' AND (:P_VESL_NAME IS NULL '||
' OR (:P_VESL_NAME IS NOT NULL '||
' AND gvm.vesl_name LIKE ''%'' || :P_VESL_NAME || ''%'' '||
' ) '||
' ) '||
' AND (:P_VESL_NO IS NULL '||
' OR (:P_VESL_NO IS NOT NULL '||
' AND GVM.vesl_no LIKE ''%'' || :P_VESL_NO || ''%'' '||
' ) '||
' ) '||
' AND (:P_FINAL_CLOSE_STA IS NULL '||
' OR (:P_FINAL_CLOSE_STA IS NOT NULL '||
' AND gvch.imp_close_sta LIKE ''%'' || :P_FINAL_CLOSE_STA || ''%'' '||
' ) '||
' ) '||
' AND (:P_FROM_REG_DATE IS NULL '||
' OR (:P_FROM_REG_DATE IS NOT NULL '||
' AND gvch.created_date >= :P_FROM_REG_DATE '||
' ) '||
' ) '||
' AND (:P_TO_REG_DATE IS NULL '||
' OR (:P_TO_REG_DATE IS NOT NULL '||
' AND gvch.created_date <= :P_TO_REG_DATE '||
' ) '||
' ) '||
' AND (:P_FROM_ARRIVAL_DATE IS NULL '||
' OR (:P_FROM_ARRIVAL_DATE IS NOT NULL '||
' AND gvch.arrival_date >= :P_P_FROM_ARRIVAL_DATE '||
' ) '||
' ) '||
' AND (:P_TO_ARRIVAL_DATE IS NULL '||
' OR (:P_TO_ARRIVAL_DATE IS NOT NULL '||
' AND gvch.arrival_date <= :P_TO_ARRIVAL_DATE '||
' ) '||
' ) '||
' AND gvm.is_valid = 10 ';
lv_sql1 := 'SELECT COUNT(gvr.rotation_no) '||
' FROM xvz gvch, '||
' zxsc gvm, '||
' dsae gvr, '||
' vvsd gvcd '|| lv_whereClause;
lv_sql2 := ' SELECT gvch.close_hdr_id, '||
' gvch.rotation_no, '||
' gvr.cm_regn_no, '||
' gvm.vesl_no, '||
' gvm.vesl_name, '||
' gvch.final_close_sta, '||
' gvr.arrival_date, '||
' gvch.close_date, '||
' gvr.created_date '||
' FROM xvz gvch, '||
' zxsc gvm, '||
' dsze gvr '|| lv_whereClause || 'ORDER BY gvch.rotation_no';
EXECUTE IMMEDIATE lv_sql1 INTO P_TOTAL_LENGTH
USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
P_VESL_NO,P_VESL_NO,P_VESL_NO,
P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
OPEN P_RESULT_LIST
FOR lv_sql2 USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
P_VESL_NO,P_VESL_NO,P_VESL_NO,
P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
END;instead of (the where clauses should be equivalent)
PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
P_RESULT_LIST OUT SYS_REFCURSOR,
P_TOTAL_LENGTH OUT NUMBER,
P_ERROR_MESSAGE OUT VARCHAR2
) AS
lv_sql1 VARCHAR2(4000);
lv_sql2 VARCHAR2(4000);
lv_whereClause VARCHAR2(4000);
BEGIN
SELECT COUNT(gvr.rotation_no)
INTO P_TOTAL_LENGTH
FROM xvz gvch,
zxsc gvm,
dsae gvr,
vvsd gvcd
WHERE gvm.vesl_master_num = gvr.vesl_master_num
AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
AND (P_ROTATION_NO IS NULL
OR (P_ROTATION_NO IS NOT NULL
AND gvch.rotation_no LIKE '%' || P_ROTATION_NO || '%'
AND (P_CM_REGN_NO IS NULL
OR (P_CM_REGN_NO IS NOT NULL
AND gvr.cm_regn_no LIKE '%' || P_CM_REGN_NO || '%'
AND (P_VESL_NAME IS NULL
OR (P_VESL_NAME IS NOT NULL
AND gvm.vesl_name LIKE '%' || P_VESL_NAME || '%'
AND (P_VESL_NO IS NULL
OR (P_VESL_NO IS NOT NULL
AND GVM.vesl_no LIKE '%' || P_VESL_NO || '%'
AND (P_FINAL_CLOSE_STA IS NULL
OR (P_FINAL_CLOSE_STA IS NOT NULL
AND gvch.imp_close_sta LIKE '%' || P_FINAL_CLOSE_STA || '%'
AND (P_FROM_REG_DATE IS NULL
OR (P_FROM_REG_DATE IS NOT NULL
AND gvch.created_date >= P_FROM_REG_DATE
AND (P_TO_REG_DATE IS NULL
OR (P_TO_REG_DATE IS NOT NULL
AND gvch.created_date <= P_TO_REG_DATE
AND (P_FROM_ARRIVAL_DATE IS NULL
OR (P_FROM_ARRIVAL_DATE IS NOT NULL
AND gvch.arrival_date >= P_P_FROM_ARRIVAL_DATE
AND (P_TO_ARRIVAL_DATE IS NULL
OR (P_TO_ARRIVAL_DATE IS NOT NULL
AND gvch.arrival_date <= P_TO_ARRIVAL_DATE
AND gvm.is_valid = 10;
OPEN P_RESULT_LIST
FOR SELECT gvch.close_hdr_id,
gvch.rotation_no,
gvr.cm_regn_no,
gvm.vesl_no,
gvm.vesl_name,
gvch.final_close_sta,
gvr.arrival_date,
gvch.close_date,
gvr.created_date
FROM xvz gvch,
zxsc gvm,
dsze gvr
WHERE gvm.vesl_master_num = gvr.vesl_master_num
AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
AND gvch.rotation_no LIKE '%' || nvl(P_ROTATION_NO,gvch.rotation_no) || '%'
AND gvr.cm_regn_no LIKE '%' || nvl(P_CM_REGN_NO,gvr.cm_regn_no) || '%'
AND gvm.vesl_name LIKE '%' || nvl(P_VESL_NAME,gvm.vesl_name) || '%'
AND gvm.vesl_no LIKE '%' || nvl(P_VESL_NO,gvm.vesl_no) || '%'
AND gvch.imp_close_sta LIKE '%' || nvl(P_FINAL_CLOSE_STA,gvch.imp_close_sta) || '%'
AND gvch.created_date BETWEEN nvl(P_FROM_REG_DATE,gvch.created_date) AND nvl(P_TO_REG_DATE,gvch.created_date)
AND gvch.arrival_date BETWEEN nvl(P_FROM_ARRIVAL_DATE,gvch.arrival_date) AND nvl(P_TO_ARRIVAL_DATE,gvch.arrival_date)
AND gvm.is_valid = 10;
ORDER BY gvch.rotation_no;
END;Regards
Etbin
Edited by: Etbin on 8.4.2012 14:37
In order not to waste your time in the future:
Don't execute dynamic SQL until it works !!!
Write out what you managed to put together using dbms_output.
Paste that into the SQL window of your client tool (SQL Developer ...)
Convert parameters to bind variables (replace p_ with :p_)
Try to run it.
If errors are thrown correct them, adjust the procedure/function set up to write your dynamic SQL accordingly
Repeat the cycle until no errors are thrown
Comment out the dbms_output. ... line
Uncomment the execute immediate ... line -
ADF BC / Why bind variables are mandatory in the sql query
I got this error during view object excecution in the component browser :
(oracle.jbo.SQLStmtException) JBO-27122: Erreur SQL lors de la préparation d'une instruction. Instruction : SELECT * FROM (Select distinct(socialgroup.socialgroup_i) from socialgroup, socialgroupmember, lodgingallocation, lodge
where socialgroup.socialgroup_i = socialgroupmember.socialgroup_i and socialgroupmember.t_socialgrouprole_i = t_rolegroup_ipar.fgetflextypologyclassitem_i(t_rolegroup_ipar.fisbeneficiary) and socialgroupmember.datefrom <= :DateTo and nvl(socialgroupmember.dateto, :DateFrom) >= :DateFrom and socialgroupmember.requester_i = lodgingallocation.requester_i and lodgingallocation.datefrom <= :DateTo and nvl(lodgingAllocation.DateTo, :DateFrom) >= :DateFrom and lodgingallocation.lodge_i = lodge.lodge_i) QRSLT ORDER BY "SOCIALGROUP_I"
----- LEVEL 1: DETAIL 0-----
(java.sql.SQLException) Tentative de définition d'un nom de paramètre qui ne se trouve pas dans le SQL: T_SICategory_I
The bind variables T_SICategory_I is not yet use in the sql query but will be used later so i defined it for the view object.
Is it a reason that the run time check this ? It would be more convenient to set the bind variables early when defining the view object and add them later during the development iteration.Design-time defined named bind variables can be marked as required, or not.
This is decided by the use in the where clause or in view criteria. In my case the bind variable was not used in where clause neither in view criteria and that causes the error.
May be i would be nice to add a check box (a flag) that enable or disable the bind variables for this checking so we will be able to let it defined even we removed some part of the query corresponding to the corresponding restriction or we defined it earlier for a part of the query that is not yet defined.
In my current case i fully defined the bind variables but would refine my query later ... in that cause i would have to remove this bind variable and loose all the definitions to run this view object.
sorry for my english ... -
Number of Bind variables passed AND Ref Cursor
hi all
well i have an interesting problem
i need to construct a query for a refcursor besade on conditions....
as:
input params: in_lname and in_fname
sql_stmt := 'Select first_name, ' || 'last_name, ' ||
'from table1';
IF in_lname is not null then
-- we are selecting guests by Lastname, Lastname & Firstname,
-- Lastname & Firstname & Zip, or Lastname & Zip
sql_stmt := sql_stmt || 'where gc_last_name = :1 ';
IF in_fname is not null then
sql_stmt := sql_stmt || ' and gc_first_name = :2 ';
END IF;
END IF;
open fm_lom_cv for sql_stmt using in_lname, in_fname;
Now here the in_lname is required BUT in_fname can be NULL
hence we dont excute or create the sql with sql_stmt || ' and gc_first_name = :2 ';
so :2 will not be used
hence it gives error IF in_fname is null ie ORA-01006: bind variable does not exist
Please suggest how to handle it....
thanksmay you have to set a some variable to check
not perfect but somthing like this
declare
ct number:=1;
sql_stmt varchar2(150);
BEGIN
sql_stmt := 'Select first_name, ' || 'last_name, ' ||
'from table1';
IF in_lname is not null then
-- we are selecting guests by Lastname, Lastname & Firstname,
-- Lastname & Firstname & Zip, or Lastname & Zip
sql_stmt := sql_stmt || 'where gc_last_name = :1 ';
ct:=1;
IF in_fname is not null then
sql_stmt := sql_stmt || ' and gc_first_name = :2 ';
ct:=2;
END IF;
END IF;
case when ct=1 then
Open fm_lom_cv for sql_stmt using in_lname;
when ct=2 then
Open fm_lom_cv for sql_stmt using in_lname,in_fname;
end case;
-
Bind Variables with AND in String causing Issues in XML & Report Outputs
Hi all,
I'm creating a BI Publisher report (10.1.3.2) and am experiencing an issue with the interprutation of Bind Variables in the Data Template.
Here is an example of some of the Data template
<dataTemplate name="BudgetDataBU" description="BudgetDataBU" dataSourceRef="DLXN">
<parameters>
<parameter name="p_Year" dataType="Integer" include_in_output="true"/>
<parameter name="p_Measure" dataType="character" include_in_output="true"/>
<parameter name="p_Currency" dataType="character" include_in_output="true"/>
<parameter name="p_Version" dataType="character" include_in_output="true"/>
</parameters>
<dataQuery>
<sqlStatement name="BusUnits">
<![CDATA[SELECT DISTINCT CC.BUSINESS_UNIT as BUSINESS_UNIT
FROM DLXN_FACT_DATA_DET FD,
DLXN.COST_CENTRE CC
WHERE FD.COST_CENTRE = CC.COST_CENTRE
AND FD.CAL_YEAR = :p_Year
AND FD.Currency = :p_Currency
AND FD.Measure = :p_Measure
AND FD.Version = :p_Version
AND CC.DLXN_VIEW = 'Delexian' ]]>
</sqlStatement>
<sqlStatement name="Details">
<![CDATA[SELECT DLXN_FACT_DATA_DET.VERSION,
DLXN_FACT_DATA_DET.CURRENCY,
DLXN_FACT_DATA_DET.CAL_YEAR as CAL_YEAR,
SUM(nvl(DLXN_FACT_DATA_DET.JAN_AMT,0)) as JAN_AMT,
</sqlStatement>
</dataQuery>The problem is with the :p_Measure Bind Variable but it could just as easily be any of the other character parameters.
The particular string value that is causing a problem is "Travel and Expenditure". I believe it is due to the "AND" in the string but this string value cannot be changed in the database to say "Travel & Expenditure".
I have thought about using a REPLACE function in the SELECT statement but see this as an ugly solution.
Any input greatly appreciated.
Kind Regards,
Gary.We remove this restriction ,fix included in BI Publisher July 2009 update for 10.1.3.4.x. The patch number is 8704846.
-
Hibernate - limit and offset in select query
Hi All
is there any way to use limit and offset features of mysql in hibernate queries?
For exmple I have 100 rows in my results. I want to display the results page by page. How can I select rows starting from a particular index (for example from 10 to 20 instead of starting at the first record). The 'setMaxRows()' function can limit the number of results, but how can I specify the offset ? Thanks in advance.
regards
booleeYou could specify the offset with
query.setFirstResult(offsett);
The drawback is (at least with DB2) that the whole query will be executed anyway, however you save space on the Java side. -
ORA-01006 Using Bind Variables In A Dynamic SQL Contains Query
I have the following dynamic SQL query :-
declare
TYPE typ_sql IS REF CURSOR;
ltyp_sql typ_sql;
lv_sql VARCHAR2(100);
begin
lv_sql := 'SELECT arx_id FROM arx WHERE CONTAINS ';
lv_sql := lv_sql || (arx_full,''(:b1) WITHIN ui'') > 0';
open ltyp_sql FOR v_sql USING ln_id;
fetch ......
close ......
end;
When the code tries to open the cursor it gives the above error. I presume it is the way Oracle is expanding the bind variable but I cannot find anything in the docs to say why this is happening or whether you can do this or not using bind variables ( CONTAINS query ). Any help would be appreciated, thanks,
Stuart.lv_sql || '(arx_full, :b1 || '' within ui'') > 0';
-
ORA 01745 (invalid host/bind variable name) and CURSOR_SHARING
For the past couple of weeks, a user has had an issue with an application in the production environment only. I've had the vendor looking at it but they were limited since it could not be reproduced in our DEV environment. I finally had some time to look into it myself and I found the problem SQL statement. The issue boils down to this, "SELECT 'N' INDICATOR FROM DUAL;" returns an ORA-01745 error. If I rename "INDICATOR" to "INDICATO" or if I add an "AS" before the alias, the query works fine. However, it would require the vendor to change the code in the application which is not likely (not for free at least). However, I also found if I change the CURSOR_SHARING from SIMILAR to EXACT, then it works. This was the reason for the difference between DEV & PRD. PRD is set to SIMILAR while DEV is set to EXACT. The prospect of setting PRD to EXACT to appealing as I'm afraid it may affect performance in other areas. But, in the end, that may be the only solution. However, I was hoping there might be some other parameter that I am not aware of that may also fix this issue. I am running 10.2.0.4. Any help would be appreciated.
I'm not sure.
To what extent can you reproduce the problem? Can you isolate it to the db only via sql*plus? Or does this other software need to be involved?
You may to do some end-to-end tracing including client/driver side.
If you raise with Oracle Support, you may find out more.
I take it that the software doesn't really issue this statement:
SELECT 'N' INDICATOR FROM DUAL;" and it's part of a bigger statement? -
Combine select and update into single statement,without bind-variable
I have a problem, that I think is not possible to solve the way I want to, but I just wanted to check before leaving the idea...
I am looking for a way to combine the select and the update statement into one single statement. This is what I wan't to achive: select some data, and update the data selected before returning them.
On this site http://www.psoug.org/reference/update.html I see that the following are possible:
var bnd1 NUMBER
var bnd2 VARCHAR2(30)
var bnd3 NUMBER
UPDATE employees
SET job_id ='SA_MAN', salary = salary + 1000,
department_id = 140
WHERE last_name = 'Jones'
RETURNING salary*0.25, last_name, department_id
INTO :bnd1, :bnd2, :bnd3;
I need to have this as a single statement, and cannot use bind-variables. So I was hoping that something like this could be possible:
UPDATE customer c
SET c.HAS_CREDIT ='1'
WHERE c.HAS_CREDIT = '0'
RETURNING c.CUSTOMER_NO, c.FIRSTNAME, c.LASTNAME
where c.HAS_CREDIT = '1'
But this doesn't compile, complaining of missing into (ORA-00925: missing INTO keyword). And even though I would like this to be possible because this would solve my current problem, I think it would be very confusing. For instance; would the where clause of the returning part be operating after the update or before?
Any comments or suggestions on how to get it work in a single statement, or should I just leave this path straight away?Hi,
RETURNING only works with bind variables, see
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm#sthref3006
The real problem is that the form of RETURNING clause with bind variables is only valid for single row update or insert statements.
To update (or insert) multiple rows and return the data, you will need to use
RETURNING BULK COLLECT INTO clause. See
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2236
Cheers,
Colin -
Af:query with bind variables and Saved Search
I have a VO and view criteria(VC).
VC has a criteria item ObsoleteDate with range specified as bindVariables "dateFrm" and "dateTo" I dragged & dropped the named criteria as af:Query with table. Table toolbar has 2 buttons in which I set & clear the bind variables. Data is fetched as per as expected based on the VC & bind variables.
The problem is,
If I save my search with bind variables set and swap between the saved searches , all works fine. But the moment I clear bind variables & swap between searches.. "dateFrm" is populated and "dateTo" is null and I get an Exception oracle.jbo.AttrValException: JBO-27035: Attribute Obsolete Date: is required.
Why is this happening?? Saved search is supposed to save the VC with all the bind values set while saving and clearing bind variables shouldn't affect the saved search, right?? Or I have understood it wrong?
I am using JDeveloper 11.1.2.3.0
ThanksTry
like ? || '%' -
Dynamic sql and bind variables
Hi,
I have a stored procedure which filters a table on 5 five columns. The filters come from the input parameters,
and these 5 parameters can come in any combination, I mean some of them may be null and some of them may not be null.
So I constructed the where filter of the query with IF blocks like the following:
dynamic_query := 'select * from TESTTABLE where 1= 1';
IF (P1 is not null) THEN
dynamic_query := dynamic_query || ' AND column1 = :1';
END IF;
IF (P2 is not null) THEN
dynamic_query := dynamic_query || ' AND column2 = :2';
END IF;
IF (P3 is not null) THEN
dynamic_query := dynamic_query || ' AND column3 = :3';
END IF;
IF (P4 is not null) THEN
dynamic_query := dynamic_query || ' AND column4 = :4';
END IF;
IF (P5 is not null) THEN
dynamic_query := dynamic_query || ' AND column5 = :5';
END IF;
OPEN CUR_OUT FOR dynamic_query USING P1, P2, P3, P4, P5;
The problem is how can I construct the USING and bind parameters, I cannot use "USING P1, P2, P3, P4, P5" because some of bind variables
may not be in dynamic query if the input parameters are null. Is there a way to overcome this problem without writing all the 2 ^ 5 combinations?
Any help is greatly appreciated.here it is in the Tomer Cohen way:
IF (P1 is not null) THEN
dynamic_query := dynamic_query || ' AND column1 = :1';
ELSE
dynamic_query := dynamic_query || ' AND :1 IS NULL';
END IF;
IF (P2 is not null) THEN
dynamic_query := dynamic_query || ' AND column2 = :2';
ELSE
dynamic_query := dynamic_query || ' AND :2 IS NULL';
END IF;
IF (P3 is not null) THEN
dynamic_query := dynamic_query || ' AND column3 = :3';
ELSE
dynamic_query := dynamic_query || ' AND :3 IS NULL';
END IF;
IF (P4 is not null) THEN
dynamic_query := dynamic_query || ' AND column4 = :4';
ELSE
dynamic_query := dynamic_query || ' AND :4 IS NULL';
END IF;
IF (P5 is not null) THEN
dynamic_query := dynamic_query || ' AND column5 = :5';
ELSE
dynamic_query := dynamic_query || ' AND -1 = :5';
END IF;
OPEN CUR_OUT FOR dynamic_query USING P1, P2, P3, P4, P5;Amiel Davis -
Report Query with Bind variables working very slowly
Hi everyone,
I'm having a hard time with one of my Reports.
Basically the query looks like this:
Select *
from x,y,z
where x.lang_id = :P1_LANG
and y.name = :P1_LANG;
I have a textfield and a Select List on my Page which have to have a value before the report is shown.
Now to the problem, when I input a value into these Application Items the Report takes ages (3-5 min). But when I replace the Bind variables (:P1_LANG and :P1_LANG) with the actual values it takes mere seconds.
Anyone got an idea why this might be?
I'm at my wits end -.-
Edited by: DocD on Oct 27, 2009 3:01 AMHi
This could be for a number of reasons and unfortunately there is no quick answer...
When you run a query for the first time, the execution plan is worked out by the Cost Based Optimiser (I'm assuming you're using 10g or above here). This is referred to as a hard parse. Next time the same SQL text is used then the execution plan may still be in the shared pool - in this case the same execution plan is used rather than being calculated again.
The great thing about using bind variables is that even with different inputs, the SQL text is the same so the execution plan can be shared for different inputs. One downside is that if the first time the query is executed using bind variables, out of the ordinary values are input, bind variable peeking can lead to a sub optimal execution plan being calculated for the query and then shared in other situations (where more 'normal' values are input).
However, it could be down to a host of other things too. So your first check is to make sure that you have executed both queries a number of times. If you are still getting the same performance issues then plan post the full query, table creation scripts and execution plan for both querys.
Cheers
Ben -
Report query with bind variable
Trying to create a report query for xsl-fo print. For output format I pick "derive from item" then pick the item name from the list, on the next screen, I paste the query with the bind variable. on the next step test query, I always get "data not found" regardless what value I type in. This is the same query that I ran under sql commands without any issues.
Does anyone run into the same issue as I have when attempted to create a query with bind var ? There is no problem creating a query without bind varibles. . thanks.
MunsharHi, please did you get any solution to this issue? I am having similar challenge right now.
select EMP.DEPTNO as DEPTNO,
DEPT.DNAME as DNAME,
EMP.EMPNO as EMPNO,
EMP.ENAME as ENAME,
EMP.JOB as JOB,
EMP.MGR as MGR,
EMP.HIREDATE as HIREDATE,
EMP.SAL as SAL
from SCOTT.DEPT DEPT,
SCOTT.EMP EMP
where EMP.DEPTNO=DEPT.DEPTNO
and DEPT.DNAME =upper(:dname)
This run perfectly in sql developer, toad, and even inside publisher if I login directly to publisher to create report.
Generating this same query in shared component query builder and testing it returns no data found. If I remove the last line, it works. but with the last line, it return no data found. It seems no one has been able to provide solution to this issue
Maybe you are looking for
-
Addition of a field in PO view
Hi, We have a requirement from the client that in the PO view, when you click on Location details, there should be an additional field for `Street 2`. Can anybody help in telling me how this can be done?
-
'Authorization for replace' sy002
SAP System gives me this error in debbuging mode. I suppose it is something related to authorization when modifying the content of variables (which is what I was doing). What would be the problem ? Thanks in advance.
-
I marked up and PDF created by printing from Mapquest into my Adobe Acrobat 9 Pro. I added some text using Typewriter tool, and some boxes and arrows as well. They are only visible when opened in Acrobat. When I save and send them, all of the text
-
Invoice still not paid as of 6/24/08?"
We are still having problems getting invoices paid. In the FBL1N screen of SAP invoice B22818 for example the document date was 6/1/08. The posting date was 6/2/08. However, for some reason there is another date of 6/12/08 for the entry. What I n
-
Audio is out of sync - Bitrates?
Hi all, I've been having some problems lately with some Mini DV tapes importing into FCE. When I put it into FCE, the audio lags behind the video a second or two, making it virtually impossible to work with. I think I might have isolated the problem,