Query on Co-ordination Operation -Go_Record

I've a Master database block and it is having only one record.For the Master Block,Details block was created with the Co-ordination Property-Defered:NO and Automatic Query:NO.
After using POST command,I'm using GO_BLOCK and GO_RECORD on master block in Key-Commit Trigger, at the time :system.form_status was in QUERY and Detail Block status was QUERY.
Question:
When i issue GO_RECORD on master block,ON-CLEAR-DETAILS trigger was getting fired and which inturn clears the detail block.
My Understanding:
Co-ordination Event should occur only when the event makes a different master record as the current record, in the Master Block.In my case I've only one master record so the GO_RECORD on master block to the same record should not cause Co-ordination Event to occur.
Can any one help?
Edited by: user13806434 on Jan 20, 2011 3:27 AM
Edited by: user13806434 on Jan 20, 2011 4:59 AM

Hi,
Thanks.
But..,
This scenario was different. In Key-Commit trigger, I’m capturing the :System.Cursor_Record and :System.Cursor_Block to a variable inorder to store the current cursor placement at the time of commit and after doing all the validation on other blocks, I’m asking the system to go back to the same block using the value of the variable which has the initial cursor block and record value.
When user keeps the cursor at the master block and does the commit, value of the variable will be the master block. So the GO_RECORD of master block clears the value in the detail blocks. If the cursor is on other than the master block, System does not clear the detail block.
Here we can’t restrict user from placing the cursor and also GO_RECORD is used in *‘n’* number of places in the key-commit trigger based on many situation.
My Questions:
1)Will the GO_RECORD on master block will fire the Co-Ordination Event even if the master block has only one record?
Also I’ve confirmed that the master block is having only one record by checking: SYSTEM.Last_Record value after the GO_RECORD statement.
2)As I said: I'm Using the GO_RECORD of master block after the POST command, the Form Status and the Block Status of Master & Details
block will be QUERY
As the Block status was in Query, System does not re-query the record after the block is cleared.
Below code is System generated code in CLEAR_ALL_MASTER_DETAILS
currel := Get_Block_Property(trigblk, FIRST_MASTER_RELATION);
WHILE currel IS NOT NULL LOOP
curdtl := Get_Relation_Property(currel, DETAIL_NAME);
IF Get_Block_Property(curdtl, STATUS) <> 'NEW' THEN
Go_Block(curdtl);
Check_Package_Failure;
Clear_Block(NO_VALIDATE);
IF :System.Block_Status <> 'NEW' THEN
RAISE Form_Trigger_Failure;
END IF;
END IF;
currel := Get_Relation_Property(currel, NEXT_MASTER_RELATION);
END LOOP;
As the Clear_Block(NO_VALIDATE); clears the detail block and the Block status is in Query so RAISE Form_Trigger_Failure is called.As the result the detail block was not populated after the clear block statement.
Can u clarify me on this?.
Edited by: user13806434 on Jan 20, 2011 5:02 AM
Edited by: user13806434 on Jan 20, 2011 5:11 AM

Similar Messages

  • Query performance - Difference between OPERATOR - Exists and IN

    Hi,
    I Have Two Tables VD,ID .Each table containg one lakh rows.
    CREATE TABLE VD (
    SRNO NUMBER(12) ,
    UNIT Varchar2(2) ,
    CREATE TABLE ID ( SRNO NUMBER(12),
    PID Varchar2(2) ,
    Sid Varchar2(20)
    In my Application i need to display Column(SRNO) from table VD If the Column(SRNO)exists in Table ID
    for the given PID and SID.
    Which query has better performance in below Queries ?
    Select SRNO from VD Where SRNO in( Select SRNO From ID Where PID = :A
    And Sid = :B )
    Select SRNO from VD V Where Exists( Select 'X' From ID Z Where Z.PID = :A
    And Z.Sid = :B
    And Z.SRNO = V.SRNO )
    Version : Oracle 10g
    Thanks ....
    Sathi

    user10732947 wrote:
    pls refer to :-)
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:953229842074
    And which part are you referring to specifically?
    It backs up what Toon already mentioned....
    ops$tkyte@ORA10GR2> SELECT /* EXISTS example */
      2           e.employee_id, e.first_name, e.last_name, e.salary
      3    FROM employees e
      4   WHERE EXISTS (SELECT 1 FROM orders o                  /* Note 1 */
      5                    WHERE e.employee_id = o.sales_rep_id   /* Note 2 */
      6                      AND o.customer_id = 144);
    Execution Plan
    Plan hash value: 551415261
    | Id  | Operation                    | Name      | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT             |           |    67 |  4087 |    49   (3)|
    |   1 |  NESTED LOOPS                |           |    67 |  4087 |    49   (3)|
    |   2 |   SORT UNIQUE                |           |    67 |  1139 |    14   (0)|
    |*  3 |    TABLE ACCESS FULL         | ORDERS    |    67 |  1139 |    14   (0)|
    |   4 |   TABLE ACCESS BY INDEX ROWID| EMPLOYEES |     1 |    44 |     1   (0)|
    |*  5 |    INDEX UNIQUE SCAN         | EMP_PK    |     1 |       |     0   (0)|
    Predicate Information (identified by operation id):
       3 - filter("O"."CUSTOMER_ID"=144)
       5 - access("E"."EMPLOYEE_ID"="O"."SALES_REP_ID")
    ops$tkyte@ORA10GR2>
    ops$tkyte@ORA10GR2> SELECT /* IN example */
      2           e.employee_id, e.first_name, e.last_name, e.salary
      3      FROM employees e
      4     WHERE e.employee_id IN (SELECT o.sales_rep_id         /* Note 4 */
      5                               FROM orders o
      6                              WHERE o.customer_id = 144);
    Execution Plan
    Plan hash value: 551415261
    | Id  | Operation                    | Name      | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT             |           |    67 |  4087 |    49   (3)|
    |   1 |  NESTED LOOPS                |           |    67 |  4087 |    49   (3)|
    |   2 |   SORT UNIQUE                |           |    67 |  1139 |    14   (0)|
    |*  3 |    TABLE ACCESS FULL         | ORDERS    |    67 |  1139 |    14   (0)|
    |   4 |   TABLE ACCESS BY INDEX ROWID| EMPLOYEES |     1 |    44 |     1   (0)|
    |*  5 |    INDEX UNIQUE SCAN         | EMP_PK    |     1 |       |     0   (0)|
    Predicate Information (identified by operation id):
       3 - filter("O"."CUSTOMER_ID"=144)
       5 - access("E"."EMPLOYEE_ID"="O"."SALES_REP_ID")Two identical Execution plans...

  • Xpath query using greater than operator

    I'm trying to evaluate some xml to determine if it matches some criterium.
    MyXmlColumns contains the following kind of data "<Values><Value>data1</Value><Value>data2</Value><Values>"
    When I execute the following query I get zero rows returned when it should match some rows containing this data.
    select * from mydata
    where existsNode(MyXmlColumn, '/Values/Value[. > "data1"]') = 1
    The question is why greter than, lesser than, does not work, and if there is any alternative.
    If I use equals operator, or greater than but using a number it works.
    I know that I can use XmlExists function but I'm using Oracle 9i r2 so it's not an option.
    Thanks in advance for any suggestion.

    but I'm using Oracle 9i r2
    The question is why greter than, lesser than, does not workWorks on 9.2.0.8:
    SQL> select * from v$version where rownum = 1
    BANNER                                                         
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    1 row selected.
    SQL> with mydata as
       select xmltype('<Values><Value>data1</Value><Value>data2</Value></Values>') MyXmlColumn from dual
    select * from mydata t where existsNode(t.MyXmlColumn, '/Values/Value') < 3
    MYXMLCOLUMN                                                              
    <Values>                                                                 
      <Value>data1</Value>                                                   
      <Value>data2</Value>                                                   
    </Values>                                                                
    1 row selected.

  • Query Generator and SUM operation in column

    Hi
    Is it possible to have SUM operation at the end of each numeric column in query result
    Thanks in advance

    You may use Ctrl+Click to get sum results for each column individually.  Or use Union All to copy query and group by one of identical value field to sum all numerical fields.
    Thanks,
    Gordon

  • Alternate query to Remove minus operator

    Hi All,
    The query below does following
    First Query Find all the GL accounts within date range and second query find all GL Elimination Accounts from GL Elimination setup.
    By Using minus i will find out which accounts are not setup in GL Elimination Setup Form. I want your help in finding desired output not using minus?
    What are the other alternatives?
    SELECT
        /*+ ORDERED
        USE_NL(jel jeh jeb cat src)
        INDEX(jel GL_JE_LINES_N1)
        INDEX(jeh GL_JE_HEADERS_U1)
        INDEX(jeb GL_JE_BATCHES_U1)
        INDEX(cat GL_JE_CATEGORIES_TL_U1)
        INDEX(src GL_JE_SOURCES_TL_U1) */
        CC.SEGMENT1
        ||'.'
        ||CC.segment2
        ||'.'
        ||CC.segment3
        ||'.'
        ||cc.segment4
        ||'.'
        || cc.segment5
        ||'.'
        || cc.segment6 Account,
        decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date
      FROM gl_code_combinations cc,
        gl_je_lines jel,
        gl_je_headers jeh,
        gl_je_batches jeb,
        gl_je_categories cat,
        gl_je_sources src
      WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
      AND cc.segment2              IN ('111710','201910')
      AND jel.code_combination_id   = cc.code_combination_id
      AND jel.status
        || ''                = 'P'
      AND (jel.accounted_cr != 0
      OR jel.accounted_dr   != 0)
      AND jeh.je_header_id   = jel.je_header_id
      AND jeh.actual_flag    = 'A'
      AND jeh.currency_code       != 'STAT'
      AND jeb.je_batch_id          = jeh.je_batch_id
      AND jeb.average_journal_flag = 'N'
      AND src.je_source_name       = jeh.je_source
      AND cat.je_category_name     = jeh.je_category
      and jel.effective_date between to_date('01-JAN-2011','DD-MON-RRRR') and to_date('31-MAY-2011','DD-MON-RRRR')
      MINUS
      SELECT (source_segment1
        ||'.'
        ||source_segment2
        ||'.'
        ||source_segment3
        ||'.'
        ||source_segment4
        ||'.'
        ||source_segment5
        ||'.'
        ||source_segment6) def_acnt,
        sysdate
      FROM GL_ELIM_ACCOUNTS_MAP

    Hi
    For performance it is better if you use Not exists as given below
    SELECT
    /*+ ORDERED
    USE_NL(jel jeh jeb cat src)
    INDEX(jel GL_JE_LINES_N1)
    INDEX(jeh GL_JE_HEADERS_U1)
    INDEX(jeb GL_JE_BATCHES_U1)
    INDEX(cat GL_JE_CATEGORIES_TL_U1)
    INDEX(src GL_JE_SOURCES_TL_U1) */
    CC.SEGMENT1
    ||'.'
    ||CC.segment2
    ||'.'
    ||CC.segment3
    ||'.'
    ||cc.segment4
    ||'.'
    || cc.segment5
    ||'.'
    || cc.segment6 Account,
    decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date
    FROM gl_code_combinations cc,
    gl_je_lines jel,
    gl_je_headers jeh,
    gl_je_batches jeb,
    gl_je_categories cat,
    gl_je_sources src
    WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
    AND cc.segment2 IN ('111710','201910')
    AND jel.code_combination_id = cc.code_combination_id
    AND jel.status
    || '' = 'P'
    AND (jel.accounted_cr != 0
    OR jel.accounted_dr != 0)
    AND jeh.je_header_id = jel.je_header_id
    AND jeh.actual_flag = 'A'
    AND jeh.currency_code != 'STAT'
    AND jeb.je_batch_id = jeh.je_batch_id
    AND jeb.average_journal_flag = 'N'
    AND src.je_source_name = jeh.je_source
    AND cat.je_category_name = jeh.je_category
    and jel.effective_date between to_date('01-JAN-2011','DD-MON-RRRR') and to_date('31-MAY-2011','DD-MON-RRRR') AND
    NOT EXISTS (
    SELECT 'x'
    FROM GL_ELIM_ACCOUNTS_MAP
    WHERE CC.SEGMENT1
    ||'.'
    ||CC.segment2
    ||'.'
    ||CC.segment3
    ||'.'
    ||cc.segment4
    ||'.'
    || cc.segment5
    ||'.'
    || cc.segment6 Account != source_segment1
    ||'.'
    ||source_segment2
    ||'.'
    ||source_segment3
    ||'.'
    ||source_segment4
    ||'.'
    ||source_segment5
    ||'.'
    ||source_segment6 )

  • Creating a query for task list operations

    hello all
    I checked the forum for similar questions but could not find any.
    I am trying to create a task list for the following:
    1) specific plant
    2) generic task list
    3) specific group counter
    4) specific operations type (filtered by control keys)
    in the display I also include the dependencies of the operations.
    I also need to link the task list to a specific class and extract the characteristics value from the class, based on the task list (I think this is better with infoset: if so, in a second stage).
    I am using tables
    1)PLKO and PLPO joined by PLNTY and PLNNR
    2) CUOB, joined to PLPO by KNOBJ and CUKB joined to CUOB by KNNUMfor the dependencies
    the results tho, gave me operations that did not exist in the task list so I discovered that there were change masters to the task lists and I added table AENR, outer joined to PLKO by AENNR where I excluded inactive changes.
    I still do not get correct results.
    I do not get all the active change masters related to a task list, I do not manage to get the task list without changes and also the related operations and dependencies are not correct.
    can someone help?

    Hi alisa,
    Onethng was not yet touched upon in the discussion sofar. If you are not getting all the records those should come, then you need to try LEFT OUTER JOIN  between tables by trial. (Trial means LOJ is not accepted on adjacent tables.) I hope you know that the default connection between fields of 2 tables in through INNER JOIN.  You need to right click on this line and select LOJ for making it LOJ. This brings you all the records which are being filtered due to IJ (if any).
    Try this, if you haven't done already.
    KJogeswaraRao

  • GREP query for find/change operation

    Hi everyone,
    In the following line, there's a comma after the first name. This type of formatting is repeated hundreds of times on a number of pages so I need to use a GREP find/change query to remove the comma after the first name and replace it with a space.
    Firstname,Lastname,State
    I wondered if something could tell me what the GREP code would be?
    Appreciate any assistance.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    ..  it's also doing it for the second comma
    That's impossible. You must have entered something else than Scott's code.

  • Add Operating Unit Field in Assets Assignments Window

    Hi everyone, I have a query to add an Operating Unit filed in Assignments window which would be only used for information purposes and have not to do with financial information. I want to make myself clear that;             1) If I add a segment in Location FF, which has already 3 segments; OUC,Department, and Area. Is this location FF data have to do with financial information or if I add a segment then will it impact on financial/ accounting flow.             2) If I use the DFF at Assignments window, then how can I add it, what is the segment name in DFF segments definitions. We have 3 Operating Units;       a. South       b. North       c. Central Please suggest me in this regard

    Sinan,
    Converting to Multiple Organizations architecture is required before R12 upgrade -- Please see (Page 2-5, Step 3: Convert to Multiple Organizations architecture (required)) in the upgrade manual.
    Please also see the (Page 1-19, Multiple Organizations (Multi-Org)) section.
    Oracle E-Business Suite Upgrade Guide Release 11i to 12.1.1 [ID 1082375.1]
    R12: Upgrade Considerations by Product (FINANCIALS) [ID 889733.1]
    FAQ - Multiple Organizations Architechure (Multi-Org) [ID 165042.1]     
    Thanks,
    Hussein

  • Power Pivot Bug: Can't Save Edits to Power Pivot Query without checking Teradata Connection's "Save my password" Option

    Can't edit and re-Save Power Pivot query with Teradata connection (using LDAP security mechanism) unless "Save my password" option was checked.  Without this option I receive this error upon attempt to Save changes made to the query ...
    The following exception occurred while the managed IDbConnection interface was being used: [TeraGSS Security Library] [115022] Exception occurred in TERAGSS layer.  See inner exception for details.;TdgssAuthenticationTokenExchange delegate threw an exception.
     See the inner exception for details.
    ErrorCode: -452984642 Severity: Error Facility: DotNet
    [Teradata Database] [8017] The UserId, Password or Account is invalid..
    A connection could not be made to the data source with the DataSourceID of '6a06124c-496f-4887-bf39-d2582173d499', Name of 'Teradata fsltdprd'.
    An error occurred while processing table 'Query'.
    The current operation was cancelled because another operation in the transaction failed.

    Sorry you're right, the Office category isn't currently accepting bug reports in which case Olaf's suggestion to use the smiley face is the way to go. In Excel please go to File > Options > Trust Centre > 'Trust Centre Settings...' and check
    that the Feeeback Tool is enabled.
    If the option is greyed out like this...
    ... then you should be able to enable it by changing the value of the 'Enabled' registry key from a 0 to a 1 which you will find under: HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Feedback. You will then need to close all Office applications
    and re-launch Excel 2013.
    Once the Feeback Tool has been enabled, you should see the smile face(s) in the top right hand corner of the Excel window and be able to send your feedback.
    Regards,
    Michael
    Please remember to mark a post that answers your question as an answer...If a post doesn't answer your question but you've found it helpful, please remember to vote it as helpful :)
    Website: nimblelearn.com, Blog:
    nimblelearn.com/blog, Twitter:
    @nimblelearn

  • Creating View Objects for complex query

    Hi All,
    I am trying to create a VO for inner query, but i am not able understand what type of bind variable to select.
    PFB the scenario:
    I have 2 tables, say orders, products
    I am supposed to execute the following query:
    Select * from Orders o, Products p where o.order_id = 123 and p.product_id in (111,222,333.....)
    In the VO when I try to create, I need to create 2 bind variables
    1 for order id and other for product id
    the problem i am facing is selecting the type of the bind variable
    I am selecting "Integer" type for order id bind variable but i am able to understand what should be the bind variable type for the product id.
    I tried to use "Array" type, but in the query it is "= : bindvariable" operator instead of "in (: bindvariable)"
    Also, please note that, the number of product_id is not fixed and is dynamic.
    So my question is:
    what should be bind variable type that should be used (for product_id case)?
    Also, please advice if it is the same way to apply the criteria in AMImpl class.
    Thanks in advance.
    Thanks,
    Varun

    Varun,
    this will not work as you can't use bind variables in sql IN queries.
    Jobinesh has bloged a solution
    http://jobinesh.blogspot.com/2010/12/using-oraclejbodomainarray-with.html and http://jobinesh.blogspot.com/2011/07/tips-on-using-oraclejbodomainarray-as.html
    or my 'trick' explained here http://tompeez.wordpress.com/2011/08/21/extending-viewcriteria-to-use-sql-contains-4/ might help to solve this.
    Timo

  • How to use OracleParameter whith the IN Operator of select statement

    Hi,
    I am having problems using the OracleParameter when used in a query with a IN operator.
    Following Example:
    oraCommand.Parameters.Add(":List", strMylist ); //or Array???
    The SQL command:
    SELECT * FROM XXX WHERE XXX.YYY IN (:List);
    What datatype must the value of :List be?
    regards
    Stefan

    Let's use a collection of User Defined Types (UDT's).
    First create a table with 1 million rows:
    create table employees (id number(10) not null primary key, name varchar2(100) );
    insert into employees
    select level l, 'MyName'||to_char(level)
    from dual connect by level <= 1e6;
    1000000 rows created
    commit;
    exec dbms_stats.gather_schema_stats(USER, cascade=>TRUE);No we turn to the C# code:
    Let's select employees with id's 3 and 4.
    Collection type MDSYS.SDO_ELEM_INFO_ARRAY is used because if we use this already predefined Oracle type we don't have to define our own Oracle type. You can fill collection MDSYS.SDO_ELEM_INFO_ARRAY with max 1048576 numbers.
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
        [OracleCustomTypeMappingAttribute("MDSYS.SDO_ELEM_INFO_ARRAY")]
        public class NumberArrayFactory : IOracleArrayTypeFactory
          public Array CreateArray(int numElems)
            return new Decimal[numElems];
          public Array CreateStatusArray(int numElems)
            return null;
        private void Test()
          OracleConnectionStringBuilder b = new OracleConnectionStringBuilder();
          b.UserID = "sna";
          b.Password = "sna";
          b.DataSource = "ora11";
          using (OracleConnection conn = new OracleConnection(b.ToString()))
            conn.Open();
            using (OracleCommand comm = conn.CreateCommand())
              comm.CommandText =
                  @" select  /*+ cardinality(tab 10) */ *  " +
                  @" from employees, table(:1) tab " +
                  @" where employees.id = tab.column_value";
              OracleParameter p = new OracleParameter();
              p.OracleDbType = OracleDbType.Array;
              p.Direction = ParameterDirection.Input;
              p.UdtTypeName = "MDSYS.SDO_ELEM_INFO_ARRAY";
              p.Value = new Decimal[] { 3, 4 };
              comm.Parameters.Add(p);
              int numPersons = 0;
              using (OracleDataReader reader = comm.ExecuteReader())
                while (reader.Read())
                  MessageBox.Show("Name " + reader[1].ToString());
                  numPersons++;
              conn.Close();
        }The index on employees.id isn't used when one omits hint /*+ cardinality(tab 10) */. This index is created by Oracle because id is the primary key column.
    Edited by: wateenmooiedag on Dec 30, 2009 2:45 AM

  • Query related to DataGuard Archicture...

    Hi All,
    I want to implement DataGuard Archicture in my setup, I'hv one query related to different operating system in my setup, I'hv two server one for primary and the other for standby Database with 10g DB R2. In one server having Linux os and the other own has Solaris, so DataGuard will work on different os or both server os should be same? And if I'hv 2 GB then will it be create any prob?
    pl. suggest me.

    A requirement for standby is both databases must be on the same platform and on the same db version, this requirement applies even if you are on a logical or on a physical dataguard database.
    You can verify the Step by Step instructions to create a standby database:
    Step-byStep Instructions for Creating a Logical Standby Database
    Step-by-Step Instructions for Creating a Physical Standby Database
    ~ Madrid

  • Passing multiple values in a parameter through IN operator

    hello everyone,
    i want to know wheather it is possible to pass multiple values to a report parameter and use the parameter in the query with the IN operator.
    I feel this should be possible but dont know the way.
    Pls help

    i have also suffered from this problem. you can solve it by creating a table like
    create table abc
    id number,
    value number;
    then follow the steps.
    1) insert all the values in this table by incrementing id and values
    2) then pass lowest id and larget id to the report
    3) now in report use the select statement like
    SELECT * FROM AAA WHERE ABC IN (SELECT VALUE FROM ABC WHERE ID BETWEEN V_MAX AND V_MIN)
    4) IN THE REPORT'S AFTER TRIGGER, YOU HAVE TO DELETE
    THESE TEMPORARILY CREATED ROWS
    LIKE
    DELETE ABC
    WHERE ID BETWEEN V_MAX AND V_MIN;
    SO THIS WILL SOLVE YOUR PROBLEM.

  • How to use Radio buttons in WAD to select different condition in a query

    Hi Guru,
    I am new to WAD, I want to use radio buttons in selection screen of query for different selections based on selection criteria. I am aware of executing different queries using different radio buttons. but i want to use single queries for different radio button selections.
    I have found some relevant topic to it but not got exact solution. Please guide me.

    Hi Avinash,
    Drag a DropDown webitem into your template. Under DropDown webitem properties, Data Binding -> Fixed List of Options.
    Fixed Option -> Action -> Command via Command Wizard, Command -> Commands for Data Providers -> Data Provider Commands for Filter Values -> SET_SELECTION_STATE_SIMPLE. Data Provider Affected -> choose the main DP Query here. Characteristic -> choose Employee Group characteristic here as present in your DP Query. Sign -> INCLUDING, Operator -> EQUAL_SELECTION, Equals -> MEMBER_NAME, Member Name -> specify the value here i.e. Employee1 etc.
    Repeat above Fixed Option step for Employee2, Employee3 etc. selections. For 'All' option choose Command CLEAR_SELECTION_STATE with Data Provider Affected as the main DP Query & Characteristic as Employee Group.
    --Priya

  • How to use LIKE operator with PreparedStatement

    Hi, I need to execute a query with the LIKE operator, but using a PreparedStatement. Can I do this, and if so what must my SQL look like with the wildcard characters '%' or '_'?
    normal PS example: conn.prepareStatement("select * from mytable where name like ?");
    If I try: conn.prepareStatement("select * from mytable where name like ?%");
    I get: ORA-00911: invalid character
    If I try: conn.prepareStatement("select * from mytable where name like '?%'");
    I get: ORA-01006: bind variable does not exist
    I must use a PreparedStatement, as my variable may contain illegal characters (like '), and using PreparedStatement.setString(1, var) will automatically escape it for me.
    I could also use a normal Statement, but I need to escape my var ... is there a utility that will safely escape a String for an Oracle VARCHAR2??
    Thanks in advance,
    Stu Miller

    Hmm, it seems you are right...
    when my variable contains a '%' symbol, the PreparedStatement will NOT escape it, and thus it is treated like a wildcard. Therefore, I can just do
    pstmt.setString(1, var+"%");
    But, that may return more results than I'm asking for, as when 'var' contains a '%' symbol it is taken as a wildcard too.
    I need each character in my variable to be taken literally, and only add a wildcard at the end. Basically, I need a STARTSWITH operator ;-)
    It seems to me that escaping the sensitive characters in a String (which will differ depending on which operator is used), should be possible. I could write this, but I was hoping Oracle had already done it for me in some utility class.

Maybe you are looking for