form of bad bind variable error in oracle 10g
I have a created a table in oracle database 10gcreate table myimage (image_id number, nom_image BLOB);
I want to insert an image and recover an image through programming (don't want to block level) in oracle 10 g shape
without using java Bean (and finely working in the two windows XP2 and Solaries)
How can I do this please can someone give me the source code to do it because I am new in oracle forms.
I need an immediate replay to this answer why because I urgently need it in my project web ERP
You can use for WEBUTIL do, but
without using java Bean (and finely working in the two windows XP2 and Solaries)
WEBUTIL also contains javabean. I don't know why you have this restriction, I would say that you do not succeed without any java bean.
Tags: Oracle Development
Similar Questions
-
PLS-00049: bad bind variable 'NEW.col1' (col1 exists in the table)
I use Oracle 12 c. And a bad bind variable error in this statement.
create or replace
check_tax_number relaxation
INSERT BEFORE THE "C ##MYUSER". "customer" FOR EACH ROW
BEGIN
'0' IF new.taxpayer <>THEN
: new.taxnumber: = "123456789"; -error here...
END IF;
END;
I don't know which exists taxnumber customer in the table column.
Here's desc 'C ##MYUSER '. "" customer ".
Name of Type Null
--------------------------- -------- -------------
taxpayer NOT NULL NUMBER (1)
taxnumber NOT NULL NVARCHAR2 (10)
Other passes...
Thanks for help.
Based on the declaration of the customer table you posted columns are created in lowercase. Therefore, you must use the names of column between quotation marks:
create or replace
check_tax_number relaxation
INSERT BEFORE THE "C ##MYUSER". "customer" FOR EACH ROW
BEGIN
IF : new. " taxpayer""" <> '0' THEN
: new. " " "taxnumber""": = "123456789"; -error here...
END IF;
END;
SY.
-
TRIGGER ERROR: bad bind variable
Hello
I just start with oracle and I try to do the same thing as auto_increment in mysql by creating this sequence and the trigger but the trigger, I get the following error:
error:
-----
This is the code for the relaxation, table and sequence:PLS-00049: bad bind variable 'TAKEOVER_USERS.TAKEOVER_UID'
triggering factor:
---------
Table:CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1" BEFORE insert on "TAKEOVER_USERS" for each row begin select TAKEOVER_UID.nextval into :takeover_users.TAKEOVER_UID from dual; end;
------
sequence:CREATE TABLE "TAKEOVER_USERS" ( "TAKEOVER_UID" NUMBER NOT NULL ENABLE, "TAKEOVER_FBID" VARCHAR2(20) NOT NULL ENABLE, "takeover_accepted_terms" NUMBER(1,1) NOT NULL ENABLE, "takeover_lastName" VARCHAR2(30), "takeover_firstName" VARCHAR2(30), "takeover_country" VARCHAR2(40), "takeover_session" VARCHAR2(50) NOT NULL ENABLE, "takeover_created" TIMESTAMP (6) NOT NULL ENABLE, CONSTRAINT "takeover_users_PK" PRIMARY KEY ("TAKEOVER_UID") ENABLE )
-----------
Any idea what I need to change to make it work?CREATE SEQUENCE "TAKEOVER_UID" MINVALUE 1 MAXVALUE 99999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE
Thank you!
ChristineIf your DB is 11g, you can try this
CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1" BEFORE insert on "TAKEOVER_USERS" for each row begin :NEW.TAKEOVER_UID:=TAKEOVER_UID.nextval; end;
If 10g or more...
CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1" BEFORE insert on "TAKEOVER_USERS" for each ROW BEGIN SELECT TAKEOVER_UID.NEXTVAL INTO :NEW.TAKEOVER_UID FROM dual; end;
Kind regards
Prazy -
Error (19,19): PLS-00049: bad bind variable 'P_WHERE '.
Hello world
Making my first attempt to bind variables. What I've read it really improves performance.
The code below works fine until I try to do TEST1_PROC. P_WHERE a bind variable with the ':' prefixed, such as: P_WHERE.
Suggestions?
Thanks in advance for your help,
Lou
create or replace
PROCEDURE TEST2_PROC
AS
my_refcur SYS_REFCURSOR;
my_id ci_summrpt_report_codes.id% TYPE;
my_descr ci_summrpt_report_codes.descr% TYPE;
my_where VARCHAR2 (10): = '1.4'.
BEGIN
TEST1_PROC (my_refcur, my_where);
DBMS_OUTPUT. PUT_LINE ('ID DESCR');
DBMS_OUTPUT. PUT_LINE ('-');
LOOP
EXTRACTION INTO my_id, my_descr my_refcur;
OUTPUT
WHEN my_refcur % NOTFOUND;
DBMS_OUTPUT. Put_line(my_id ||) CHR (9) | my_descr);
END LOOP;
CLOSE My_refcur;
END TEST2_PROC;
CREATE OR REPLACE
PROCEDURE TEST1_PROC
(
p_refcur ON SYS_REFCURSOR,
p_where IN VARCHAR2)
IS
v_id NUMBER (2);
v_descr VARCHAR2 (25);
v_select VARCHAR2 (200);
BEGIN
v_select: ='SELECT * FROM
(SELECT 1 AS 'ID', 'ONE' AS 'DESCR' OF THE DOUBLE
UNION ALL
SELECT 2, 'TWO' OF THE DOUBLE
UNION ALL
SELECT 3, "THREE" DOUBLE
UNION ALL
SELECT OPTION 4, "FOUR" DOUBLE)
WHERE ID IN (' |: p_where |) ')';
DBMS_OUTPUT. Put_line (v_select);
P_refcur OPEN FOR v_select;
END TEST1_PROC;You do not specify bind variables by a colon ': ' prefix in PL/SQL.
The stored procedure generates a query using the string concatenation. If you remove your name from the variable of the colon you still don't use bind variables.
If you want to use bind variables you should consider the following:
1. use the DBMS_SQL package.
2. use EXECUTE IMMEDIATE with the USING clause.
3. use OPEN TOwith the USING clause. Each has different advantages/disadvantages.
If looks as if you want to pass in a dynamic list. If you are using bind variables, it will effectively address the entire list as a value surrounded by single quotes. If you really want a dynamic IN the list, you need to investigate another method.
Tom Kyte contains information about the lists into dynamic here: [how to make a variable in the list? | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:210612357425]
-
PLS-00049: bad bind variable in the database trigger
Hi all
If the POSTAL code table has no matching records, the trigger must create a new record for the given value of the zipper before you add a new record to the STUDENT table
SQL > CREATE TABLE student
(
zip VARCHAR2 (5).
student_id NUMBER,
created_by VARCHAR2 (10),
CREATED_DATE DATE,
Modified_By VARCHAR2 (10),
MODIFIED_DATE DATE
);
SQL > CREATE TABLE zip code
(
zip VARCHAR2 (5).
zip_ID NUMBER,
created_by VARCHAR2 (10),
CREATED_DATE DATE,
Modified_By VARCHAR2 (10),
MODIFIED_DATE DATE
);
SQL > CREATE VIEW student_v
AS
SELECT *.
OF the student;
Created view.
SQL > CREATE OR replace TRIGGER student_ins
instead of INSERT ON student_v
FOR EACH LINE
DECLARE
v_zip VARCHAR2 (5);
BEGIN
BEGIN
SELECT zip
IN v_zip
ZIP CODE
WHERE zip =: NEW.zip;
EXCEPTION
WHEN no_data_found THEN
INSERT INTO postal code
(zip,
zip_ID,
created_by,
CREATED_DATE,
Modified_By,
MODIFIED_DATE)
VALUES (: NEW.zip,)
: NEW.zip_id-> not commented
USER,
SYSDATE,
USER,
SYSDATE);
END;
INSERT INTO student
(zip,
student_id,
created_by,
CREATED_DATE,
Modified_By,
MODIFIED_DATE)
VALUES (: NEW.zip,)
: NEW.student_id,.
USER,
SYSDATE,
USER,
SYSDATE);
end;
Decline: Trigger created with compilation errors.
SQL > show error
Errors for STUDENT_INS TRIGGER:
LINE/COL ERROR
-------- -------------------------------------------
19/21 PLS-00049: bad connection variable ' NEW. ZIP_ID'
SQL > ed
CREATE or replace TRIGGER student_ins
instead of INSERT ON student_v
FOR EACH LINE
DECLARE
v_zip VARCHAR2 (5);
BEGIN
BEGIN
SELECT zip
IN v_zip
ZIP CODE
WHERE zip =: NEW.zip;
EXCEPTION
WHEN no_data_found THEN
INSERT INTO postal code
(zip,
zip_ID,
created_by,
CREATED_DATE,
Modified_By,
MODIFIED_DATE)
VALUES (: NEW.zip,)
-: NEW.zip_id, -> replace commented with NULL
NULL,
USER,
SYSDATE,
USER,
SYSDATE);
END;
INSERT INTO student
(zip,
student_id,
created_by,
CREATED_DATE,
Modified_By,
MODIFIED_DATE)
VALUES (: NEW.zip,)
: NEW.student_id,.
USER,
SYSDATE,
USER,
SYSDATE);
end;
SQL > /.
SQL > insert into student_v (zip) values('111');
1 line of creation.
SQL > select * from student_v
2.
ZIP STUDENT_ID CREATED_BY CREATED_D MODIFIED_B MODIFIED_
----- ---------- ---------- --------- ---------- ---------
111 APPS APPS APRIL 3, 14 3 APRIL 14
SQL > select * from student
2.
ZIP STUDENT_ID CREATED_BY CREATED_D MODIFIED_B MODIFIED_
----- ---------- ---------- --------- ---------- ---------
111 APPS APPS APRIL 3, 14 3 APRIL 14
SQL > select * from zip code
2.
ZIP ZIP_ID CREATED_D MODIFIED_B MODIFIED_ CREATED_BY
----- ---------- ---------- --------- ---------- ---------
111 APPS APPS APRIL 3, 14 3 APRIL 14
You wrote trigger on the table of the student. So in the trigger, only the columns of this table must be offered for example: NEW.zip.
Since zip_id is not part of this table, the: NEW.zip_id must always generate the error.
insert into student_v (zip) values('111');
In the above statement, you can only provide the value for the column zip but not zip_id. Therefore, the: NEW.zip_id is not available in the trigger. Must extract this value in the sequence after it is created.
for example
create the test of the order;
INSERT INTO postal code
(zip,
zip_ID,
created_by,
CREATED_DATE,
Modified_By,
MODIFIED_DATE)
VALUES (: NEW.zip,)
test.nextval,
NULL,
USER,
SYSDATE,
USER,
SYSDATE);
-
Hi guys
I need to spend some "student: 1234567" as below mentioned values function... but after having passed this value I get the error message
SP2-0552: Bind variable "1234567" not declared.
Please help me what I am doing wrong.
--------------------------------------------------------------------------------------------------------------
create or replace function func_get_employee (emp_id in varchar2)
return varchar2
as
return_value varchar2 (100);
Start
return_value: = emp_id;
for indx to 0... 20
loop
If (substr (emp_id, 1, 8) = ' :') student then)
return_value: = substr(emp_id,9)
elsif (substr (emp_id, 1, 6) =' location:') then
return_value: = substr(emp_id,7);
elsif (substr (emp_id, 1, 10) ='honorary:') then
return_value: = substr(emp_id,11);
on the other
return_value: = emp_id;
end if;
end loop;
return return_value;
end;
/I have found no problems with your code outside a missing semi colon on line 10
create or replace function func_get_employee(emp_id in varchar2) return varchar2 as return_value varchar2(100); begin return_value := emp_id; for indx in 0 .. 20 loop if (substr(emp_id,1,8) = 'student:') then return_value := substr(emp_id,9); elsif (substr(emp_id,1,6)='staff:') then return_value := substr(emp_id,7); elsif (substr(emp_id,1,10)='honorary:') then return_value := substr(emp_id,11); else return_value := emp_id; end if; end loop; return return_value; end; PRAZY@11gR1> / Function created. Elapsed: 00:00:00.04 PRAZY@11gR1> select func_get_employee('student:1234567') from dual; FUNC_GET_EMPLOYEE('STUDENT:1234567') ---------------------------------------------------------------------- 1234567 Elapsed: 00:00:00.00
Kind regards
Prazy -
Multiple selection with binding variable error
Hello world
I tried to put in place an array of adf multiple selection with another table, by following the tutorial (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/75-multi-parent-row-detail-views-328078.pdf), page 3.
I created all things and first of all I had an exception error, which I fixed, but now, whenever I try to select multiple lines, it won't update the table of the adf.
In this example, I choose a service line and it shows the emplooyes, but every time I try to choose another line by ctrl clicking on it, the employees table be updated.
Since I tryied to follow the tutorial, I'll put the code for the bean, I created for this purpose (it's a little different than the code given by the tutorial, but only because I had to get rid of the exception error)
I use jdeveloper Studio Edition Version 12.1.2.0.0.
Here is my code for the bean.java:
Select listen port defined for the departments table. The selected line keys are read in the reference table.
For each line, the Department ID value is read and added to a string buffer that generates a comma-delimited
List of the departmentIds. In the end, this string is passed as an argument to the link of action ExecuteWithParams
{} public void onDepartmentTableSelect (SelectionEvent selectionEvent)
variable to hold the string containing the selected set value line departmentId
StringBuffer departmentIds = new StringBuffer();
Go to the main table to read selected line keys
RicheTableau rt = selectionEvent.getSource ((richeTableau));
RKS RowKeySet = rt.getSelectedRowKeys ();
Iterator selectedRowsIterator = rks.iterator ();
memorize the current line to place it back in the end key
CurrentRowKey () rt.getRowKey = (list);
for each selected master line, determine the departmentId
int size = 0;
{while (selectedRowsIterator.hasNext ())}
size ++;
The rowKey () selectedRowsIterator.next = (list);
each value is terminated by a comma
If (departmentIds.length () > 0) {}
departmentIds.append(",");
}
take the current line
rt.setRowKey (rowKey);
JUCtrlHierNodeBinding wrappedRow = rt.getRowData ((JUCtrlHierNodeBinding));
Line rw = wrappedRow.getRow ();
/*
Number departmentId = (number) rw.getAttribute ("DepartmentId");
*/
int departmentIdInt = rw.getAttribute ("DepartmentId") (Integer);
oracle.jbo.domain.Number departmentId = new oracle.jbo.domain.Number (departmentIdInt);
departmentIds.append (departmentId.stringValue ());
}
back the foreign currency on the line
rt.setRowKey (currentRowKey);
Run the query on the detail table
BindingContext bctx = BindingContext.getCurrent ();
BindingContainer links = bctx.getCurrentBindingsEntry ();
OperationBinding executeWithParams = bindings.getOperationBinding("ExecuteWithParams");
executeWithParams.getParamsMap () .put ("departmentIds", departmentIds.toString ());
executeWithParams.execute ();
refresh the detail table
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance ();
adfFacesContext.addPartialTarget (employeeTable);
}
}
If someone has an idea of why it isn't updated table, please answer. Any idea can help.
Thanks in advance.
Greetings,
Frederico Barracha.
Finally, I found the problem...
The problem was that I had to remove a line in the properties of my table, the property services: selectedrowkeys, because he only spent the last selected row.
Yet, I apreciate the help and I had to replace a code in the bean.java, in reason of the exception error and you had to do. Maybe I did a configuration in the wrong way and he would not.
Thanks for the help.
Kind regards
Frederico.
-
bad when packet error linking oracle
Need help! Please give me your hand.
Error java.sql.SQLRecoverableException: Io Exception: bad packet type occurs when I run the application. Here are the details:
I worked under Red Hat Enterprise linux 5, Jdk1.6.0_10, Oracle 10.2.0.1. I had downloaded ojdbc6.jar, put in _/usr/java/jdk1.6.0_10/lib/_ and changed my/etc/profile:
JAVA_HOME=/usr/java/JDK1.6.0_10
PATH = $JAVA_HOME/bin: $PATH
CLASSPATH=.:$JAVA_HOME/lib/DT.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/ojdbc6.jar
Export JAVA_HOME
export PATH
Export CLASSPATH
Part of my java application:
import java.awt.*. *;
java.awt.event import. *;
Javax.swing import. *;
import java.sql. *;
Import oracle.jdbc.driver. *;
try {}
Class.forName ("oracle.jdbc.driver.OracleDriver");
Conn = Java.Sql.DriverManager.GetConnection ("JDBC:Oracle:Thin:@localhost.localdomain:1158:ORCL","System","zhonghuafy");
/ * other code - I've already annotated * /.
JOptionPane.showMessageDialog (null, "conn Succeed!", "Welcome", JOptionPane.INFORMATION_MESSAGE);
}
catch (Exception e) {}
JOptionPane.showMessageDialog (null, "Database Link Error! \n"+e,"error",JOptionPane.ERROR_MESSAGE);
}
But when I run it, it seems to me that something was wrong:
[oracle@localhost ~] $ javac testoracle.java
[oracle@localhost ~] $ java testoracle
errorjava.sql.SQLRecoverableException: Io Exception: invalid packet type
I don't know what the problem is. Please do me a favor!
Thank you!Hello
Are you sure you are using the port number correct (1158)?
The default port for the listener's 1521
Concerning
Peter -
Bad connection variable? I'm doing a host variable.
Okay, so I said a global variable:
VARIABLE g_total NUMBER
and I want to use this variable to store the results of a stored procedure (I reduced my code to focus on the problem area):
CREATE OR REPLACE PROCEDURE my_procedure
(p_price IN m_movies.price%TYPE
p_quantity IN m_cart.quantity%TYPE)
IS
BEGIN
: g_total: = p_price * p_quantity;
DBMS_OUTPUT. Put_line ("the order total is: ' |: g_total");
END;
/
After all this, I get an error "bad bind variable g_total ' for the two lines I use it inside the procedure. What the heck is a variable binding? I use a host variable. (I think). If this has nothing to do with the fact that I can only give a very generic NUMBER data type to the host variable? Help, please!It's not the way it will work. You cannot create choice with lie (as you saw).
You had rather code like this:SQL> VARIABLE g_total NUMBER SQL> create or replace procedure my_procedure (p_price in number, p_quantity in integer, g_total out number) is begin g_total := p_price * p_quantity; end my_procedure; / Procedure created. SQL> exec my_procedure(50,3, :g_total) PL/SQL procedure successfully completed. SQL> print g_total g_total ---------- 150
-
Bind variables are not getting used
Hi all
Do not use bind variable on my Oracle 11g server. That's why same query duplicate in the aqlarea view. Please tell em how to overcome this problem.
SELECT * FROM message_data WHERE (organizationid = '1') AND (entityid = '105055933') AND (unit = 'employment') AND (status! = '1') ORDER BY id ASC
Thank youWhat is the value of your cursor_sharing parameter?
If that is CORRECT they will share the SQL area only when their texts match exactly.
You need to put STRENGTH to similar statements to share SQL or SIMILAR.Take a look at: http://docs.oracle.com/cd/B19306_01/server.102/b14211/memory.htm#sthref496
-
Using Bind Variable in a SELECT statement
Hello
I am trying to build my SQL query running using bind variables and in Oracle® Fusion Middleware Fusion developer Guide for Oracle Application Development Framework 11 g Release 1 (11.1.1) it is said that ' after you define bind variables, the next step is to reference them in the SQL statement. While SQL syntax allows you to bind variables to appear in the SELECT list and in the WHERE clause, you'll generally use them in this context, as part of your WHERE clause. ».
However, when I try to use bind variables in my SELECT list because I had set a type to the string of the variable variable is inserted with quotes each side for example SELECT TestTable FROM 'Service '. Is it possible to use bind variables to insert a value in my list of selection without the quotes around it?
Thanks in advance,
TomHi Robinst,
I think you want to set up column name of the table that is not possible using bind variables. With the help of the bind variables you can send a value to the SQL. The String value is therefore always with inverted commas.
Kind regards
Branislav
-
I recently upgraded from Oracle Forms/Reports 10 g and 11g. Oracle 10g reports saving as PDF is easily converted into a word document, however, Oracle 11 g converts not as 10 g. What is the difference and how to make the report of 11g saved in a PDF file be able to convert a Microsoft Word document itself.
Thank you
Steven
Hello
There is a "known issue" with the PDF file in 11g:
ALERT: Indicates problems PDF in 11.1.2.1.0 group of fixes for Non-Linux (Doc ID 1522543.1) platforms
Maybe the problem comes from this 'problem '...
"Patch Set Exception" exists for this problem.
Kind regards
-
When I go from ODP.NET to the ODP.NET managed some of my questions begins to throw errors missing bind variable.
I reproduced with a simple example that uses a variable called liaison: unitName
It's the example SQL:
SELECT
: unitName
Of
DOUBLE
Now, if I add a comment at the beginning of the SQL like this:
-Text with: unitName
SELECT
: unitName
Of
DOUBLE
It works, but if I have a variable binding in a comment that is located on a number of the 'same' line, I get ORA-01006:
This causes the error:
-First line comment
-Text with: unitName
SELECT
: unitName
Of
DOUBLE
Kind regards
-Tommy
I was able to reproduce this problem. I filed Bug 19433348 on your behalf.
The circumstances in which the bug occurs are fairly easy to get around.
(1) remove the colon in the second commented line.
(2) add a space between the '\n' and ' - '.
If you are one of those things, you won't encounter the bug behavior.
-
INSTEAD, error PLS-00049: bad connection variable
I try to use a PLACE for me to enter data in a table of bridge. Thanks in advance
I get the following error:
Error on line 4: PLS 00049: bad connection variable ' NEW. MEMBER_ID'
2 INSTEAD OF THE INSERT OR UPDATE OR DELETE
3 ON VI_Member_Talent_VW making REFERENCE AGAIN AS NINE OLD and OLD
4. FOR EACH LINE
5. START TO
6. IF THE INSERTION
Here is the code:
CREATE OR REPLACE TRIGGER VI_INSERT_UPDATE_MT
INSTEAD OF INSERT OR UPDATE OR DELETE
ON VI_Member_Talent_VW REFERENCING NEW AS NEW as OLD OLD
FOR EACH LINE
BEGIN
IF THE INSERTION
THEN
INSERT INTO VI_Member_Talent (Member_ID, Talent_ID) VALUES (: NEW.) Member_ID,: NEW. Talent_ID);
END IF;
IF THE UPDATE
THEN
UPDATE VI_Member_Talent SET Member_ID =: NEW. Member_ID, Talent_ID =: NEW. Talent_ID
WHERE ROWID =: OLD.ID;
END IF;
IF THE REMOVAL
THEN
DELETE FROM VI_Member_Talent WHERE ROWID =: OLD.ID;
END IF;
END;
Edited by: user13003575 may 2, 2010 08:53user13003575 wrote:
It's the viewCREATE OR REPLACE FORCE VIEW "VI_MEMBER_TALENT_VW" ("ID", "Member_ID", "Talent_ID") AS SELECT rowid id, Member_ID, Talent_ID FROM VI_Member_Talent /
and there is the problem.
The view was created with quotes around column names, so that they are case-sensitive. You need to either modify your trigger double quote column names, or rebuild the view without the quotes. Personally, I'd go with changing the display.
John
-
Estimate of poor cardinality using Bind Variables
Hi I'm using the 11.2.0.4.0 Oracle version. I have a query that is underway for the plan of the poor execution by the estimate of poor cardinality for two tables (I've extracted and published this part only) as I mentioned below, the individual conditions for which the estimate goes bad and moving entire query execution path.
These are for two tables and currently we use BIND variable for them in our code, and I notice, its best estimate gives with literals. I need to know how to handle this scenario that I need this query to execute for all types of volumes. Is there something I can do without changing the code, as it works well for most of the execution? In the current scenario of the main query that uses those below tables providing a plan (index + nested loop) that works very well for small volume, but running for 10 hr + for large volume as ideally its going to the same regime.
And Yes, most time that this request will be hit for small volume, but killing some appearance of large volume presents the performance of the queries.
Here are the values of the variable binding.B1 VARIABLE VARCHAR2 (32);
B2 VARIABLE VARCHAR2 (32);
B3 VARIABLE NUMBER;
B4 VARIABLE VARCHAR2 (32);
B7 VARIABLE VARCHAR2 (32);
B5 VARIABLE NUMBER;
B6 VARIABLE NUMBER;EXEC: B1: = 'NONE ';
EXEC: B2: = NULL;
EXEC: B3: = 0;
EXEC: B4: = NULL;
EXEC: B7: = NULL;
EXEC: B5: = 0;
EXEC: B6: = 0;---- For TABLE1------- -- Published Actual VS Etimated cardinality -- With bind values select * from TABLE1 SF WHERE ( (SF.C1_IDCODE = :B4) OR (NVL (:B4, 'NONE') = 'NONE')) AND ( (SF.C2_ID = :B3) OR (NVL (:B3, 0) = 0)); Plan hash value: 2590266031 ----------------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | ----------------------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | 28835 |00:00:00.08 | 2748 | 46 | | | | |* 1 | TABLE ACCESS STORAGE FULL| TABLE1 | 1 | 11 | 28835 |00:00:00.08 | 2748 | 46 | 1025K| 1025K| | ----------------------------------------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - storage((("SF"."C1_IDCODE"=:B4 OR NVL(:B4,'NONE')='NONE') AND ("SF"."C2_ID"=:B3 OR NVL(:B3,0)=0))) filter((("SF"."C1_IDCODE"=:B4 OR NVL(:B4,'NONE')='NONE') AND ("SF"."C2_ID"=:B3 OR NVL(:B3,0)=0))) -- With literals select * from TABLE1 SF WHERE ( (SF.C1_IDCODE = null) OR (NVL (null, 'NONE') = 'NONE')) AND ( (SF.C2_ID = 0) OR (NVL (0, 0) = 0)); Plan hash value: 2590266031 -------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | -------------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | 28835 |00:00:00.03 | 2748 | | | | | 1 | TABLE ACCESS STORAGE FULL| TABLE1 | 1 | 28835 | 28835 |00:00:00.03 | 2748 | 1025K| 1025K| | -------------------------------------------------------------------------------------------------------------------------------------- --------For TABLE2 ----------------------- -- Published Autotrace plan, as it was taking long time for completion, and actual cardinality is 45M, but its estimating 49 With bind value--- --withbind value select * from TABLE2 MTF WHERE ( (MTF.C6_CODE = TRIM (:B2)) OR (NVL (:B2, 'NONE') = 'NONE')) AND ( (MTF.C3_CODE = :B1) OR (NVL (:B1, 'NONE') = 'NONE')) AND ( (MTF.C4_CODE = :B7) OR (:B7 IS NULL)) AND ( (MTF.C5_AMT <= :B6) OR (NVL (:B6, 0) = 0)) AND ( (MTF.C5_AMT >= :B5) OR (NVL (:B5, 0) = 0)); Execution Plan ---------------------------------------------------------- Plan hash value: 1536592532 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ----------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 49 | 10437 | 358K (1)| 01:11:43 | | | | 1 | PARTITION RANGE ALL | | 49 | 10437 | 358K (1)| 01:11:43 | 1 | 2 | |* 2 | TABLE ACCESS STORAGE FULL| TABLE2 | 49 | 10437 | 358K (1)| 01:11:43 | 1 | 2 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage(("MTF"."C4_CODE"=:B7 OR :B7 IS NULL) AND ("MTF"."C3_CODE"=:B1 OR NVL(:B1,'NONE')='NONE') AND ("MTF"."C5_AMT"<=TO_NUMBER(:B6) OR NVL(:B6,0)=0) AND ("MTF"."C5_AMT">=TO_NUMBER(:B5) OR NVL(:B5,0)=0) AND ("MTF"."C6_CODE"=TRIM(:B2) OR NVL(:B2,'NONE')='NONE')) filter(("MTF"."C4_CODE"=:B7 OR :B7 IS NULL) AND ("MTF"."C3_CODE"=:B1 OR NVL(:B1,'NONE')='NONE') AND ("MTF"."C5_AMT"<=TO_NUMBER(:B6) OR NVL(:B6,0)=0) AND ("MTF"."C5_AMT">=TO_NUMBER(:B5) OR NVL(:B5,0)=0) AND ("MTF"."C6_CODE"=TRIM(:B2) OR NVL(:B2,'NONE')='NONE')) -- with literal select * from TABLE2 MTF WHERE ( (MTF.C6_CODE = TRIM (null)) OR (NVL (null, 'NONE') = 'NONE')) AND ( (MTF.C3_CODE = 'NONE') OR (NVL ('NONE', 'NONE') = 'NONE')) AND ( (MTF.C4_CODE = null) OR (null IS NULL)) AND ( (MTF.C5_AMT <= 0) OR (NVL (0, 0) = 0)) AND ( (MTF.C5_AMT >= 0) OR (NVL (0, 0) = 0)); Execution Plan ---------------------------------------------------------- Plan hash value: 1536592532 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ----------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 45M| 9151M| 358K (1)| 01:11:41 | | | | 1 | PARTITION RANGE ALL | | 45M| 9151M| 358K (1)| 01:11:41 | 1 | 2 | | 2 | TABLE ACCESS STORAGE FULL| TABLE2 | 45M| 9151M| 358K (1)| 01:11:41 | 1 | 2 | ----------------------------------------------------------------------------------------------------------- select column_name,num_nulls,num_distinct,density from dba_tab_col_statistics where table_name='TABLE2' and column_name in ('C3_CODE','C4_CODE','C5_AMT','C6_CODE'); C3_CODE 0 65 0.0153846153846154 C4_CODE 0 2 0.5 C5_AMT 0 21544 4.64166357222429E-5 C6_CODE 1889955 71 0.0140845070422535
933257 wrote:
((SF. C1_IDCODE =: B4) OR (NVL (: B4, 'NONE') = 'NONE'))
In fact for literals, I did not find any section of the predicate after running the sql code with activation "set autotrace traceonly explain."
The main problem is with another large query whose cardinality is underestimated due to the presence of these table (table1, table2) with the above mentioned clause, and the query is for the analysis of index + nested with values of Bind loops and take 10 hr +, whereas with literals, its completion in ~ 8minutes with FTS + Hash Join.
Your real problem is that you try to have just a single SQL query handle all POSSIBLE thanks to the use of embedded FILTERS ' either / or ' filters in the WHERE clause. You want only a select this OPTION to run whatever filters have been selected at run time by the user or the application using it. And it would never work. You really need to SELECT different queries for different combinations of filter conditions.
Why? Think for a minute. How Oracle works internally? A SQL SELECT query gets analyzed and an execution plan is produced which is stored in the library cache and gets REUSED on all subsequent executions of this query - except in certain cases where there may exist several plans run through several cursors of the child. So with only SELECT a query you only AN execution plan in the library cache, to be used by all THE executions of this query, regardless of the value of your run-time binding variables.
Lets put another way - each library cache execution plan is associated with a SQL statement. If you want a DIFFERENT execution plan then you need run a DIFFERENT SQL statement. That's how you get a different execution plan - by running a different SQL statement. Running the SAME SQL query generally you will get the SAME execution plan every time.
In addition, because of the "either / or" filters that you use you will end up generally with a full Table Scan on each of the referenced tables. Why? Given that the optimizer must produce an implementation plan that manages all possible contingencies for all values of possible bind variables in the SELECT. If the optimizer should choose to use any index based on one of these "either / or" filters then it would only help performance when real value was provided, but it would be really bad if a NULL value was supplied. If the optimizer ends up ignoring the index because they are not always optimal for all possible input values and instead chose a plan that is "good enough" for all input values possible. That means that it will use a scanning Table full.
I hope you can see that it is precisely what is happening for you with your query. You select this OPTION to manage the different combinations of filter, which leads to the execution plan only one, which leads to scans full Table on the referenced tables in these ' either / or ' filters.
The solution? Build queries SELECT DIFFERENT when input values are NULL. How you do that? Read this article to ask Tom that tells you:
http://www.Oracle.com/technetwork/issue-archive/2009/09-Jul/o49asktom-090487.html
To sum up - when you have real value for a bind variable 'bind_var1' add the following filter to your CHOICE:
AND column_name1 =: bind_var1
When the binding variable is NULL, add the filter according to your CHOICE:
AND (1 = 1 OR: bind_var1 IS NULL)
Now, you'll have 2 queries SELECT must be performed, which have exactly the same number of variables in the same order bind, which is important. When you then run one of these variations, Oracle can analyze and optimize each one SEPARATELY, with a single execution by the SELECT query plan.
When you provide a real value, the filter is a normal 'column = value' that the optimizer can use all indexes on this column, because NULL values are not referenced.
When there is no real value, the optimizer will analyze the '1 = 1 GOLD' and realize that "1 = 1" is set to TRUE and GOLD, it is quite TRUE regardless because the binding variable is null or not. This means that the optimizer will actually REMOVE this filter, because it filters nothing because it is always TRUE. You will end up with an operating plan based on the other filters in the query, which is what you want because you have no filter on this column.
What is it - producing distinct SELECT queries to determine if you have a real value to filter or not you end up with DIFFERENT execution plans for each of them, and each of them is OPTIMAL for this particular set of filters. Now you get good performance for each variation of the performance of the SELECTION, rather than sometimes good and sometimes very bad when using SELECT only one. It is impossible to try to get multiple shots of execution 'optimal' out of a SELECT query. That's why you get mediocre performance under different bound the values of the variables.
John Brady
Maybe you are looking for
-
HelloI have a problem with the function of the identity button as it is also described here: https://support.mozilla.org/en-US/kb/how-do-i-tell-if-my-connection-is-secure?as=u & utm_source = inproduct What led to this article is a situation in which
-
HP ENVY 4512: cannot print on 2 faces - HP ENVY 4512
I want to print 2-sided documents directly from the printer. I changed the settings on my laptop to HP to 2-sided But the printer will not print one side Is it possible to print the 2 sides of the printer itself?
-
Startup Repair loop - cannot start Windows
Hello I have problems with repair system continuously in a loop and it is not letting me open my computer.Once he arrives, he works to try to find a problem and then can't find the problem. It is said "If you have recently attached a device to this c
-
my windows Defender does not illuminate when I click on
my windows Defender does not illuminate
-
Connect to the personal server
I have a server that I want my application to connect and check for a given file. Are there documents or links to guide me in the right direction? Thank you.