Using IN in a direct SQL statement.

Peter,
I tried a couple of things to no avail. The simplest
one is like this:
myType.SetValue('\'CI\',\'NG\',\'MS\'');
It works if I do
myType.SetValue('\'CI\'');
Same is valid if myType is declared as a String.
Hi,
What does the string in myType look like? You should
be careful with ' and \ as they are used by Forte. I
suggest you post a sample of the myType's value.
Regards,
Peter Sham.--- Rumen Georgiev <[email protected]> wrote:
Hi folks,
I have a problem when executing direct SELECT
statement against Oracle 7.4, something like that:
SQL SELECT ..... INTO .... FROM ..... WHERE .....
AND
TYPE IN :myType ON SESSION .......
myType is TextData containing a list of possible
values separated by commas. myType is set at run
time.
When executed through SQL*Plus the result is O.K..
When executed through Forte it doesn't return
anything. It seems that eigther Forte or Oracle
disregards the commas and treats myType as it will
with =,>,<. What makes me think so is that when
myType
holds single value it works. It fails as soon as I
concatenate one more value from the list. Same
happens
when using cursor. I didn't try it with DBSession
methods but I assume the result will be the same. I
can't use EXECUTE EMMEDIATE because I expect result
set(INTO). So far the only way I can think of is a
WHILE loop for every single value from the list.
Any ideas,comments or workarounds?
Thank's in advance.
Rumen__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

The primary key is only necessary for the Form (for managing updates). Maybe you can create an Interactive Report. There you can set that a row is uniquely defined by rowid.
Or define a primary key constraint on your view...
HTH
Roel

Similar Messages

  • Using Toplink to generate UPDATE sql statements?

    I have a need to generate a UPDATE sql statement.
    This statement will run at startup and will not effect the cache, as no objects will be loaded prior to this command running.
    I realize that I can execute arbitrary SQL using Session, however, I have the additional requirement that this UPDATE is compatible with the DB it is running on.
    So, I want to use TopLink to generate an UPDATE statment perhaps using the query framework. Is this possible? Is there any way to use TopLink's ability to create SQL before passing this into a Session for execution?

    In the current versions your only option is to provide the UPDATE SQL directly using the executeCall(new SQLCall("UPDATE ...")).
    In 10.1.3 there exists an UpdateAllQuery intended to do such batch update calls. It will additionally invalidate any cached objects if they were to exist.
    Doug

  • Can i use commit in between pl sql statements

    Hi,
    I have written program unit , in that I used insert statements and after that I used commit command.
    But in runtime it's getting oracle error unable to insert . because I used some non database items and database items
    so that it's coming error.
    But my question is , Can i use commit after executing some statements in program unit procedure.
    Thanks in advance.

    FORMS_DDL restrictions
    The statement you pass to FORMS_DDL may not contain bind variable references in the string, but the
    values of bind variables can be concatenated into the string before passing the result to FORMS_DDL.
    For example, this statement is not valid:
    Forms_DDL ('Begin Update_Employee (:emp.empno); End;');
    However, this statement is valid, and would have the desired effect:
    Forms_DDL ('Begin Update_Employee ('||TO_CHAR(:emp.empno)
    ||');End;');
    However, you could also call a stored procedure directly, using Oracle8's shared SQL area over
    multiple executions with different values for emp.empno:
    Update_Employee (:emp.empno);
    SQL statements and PL/SQL blocks executed using FORMS_DDL cannot return results to Form
    Builder directly.
    In addition, some DDL operations cannot be performed using FORMS_DDL, such as dropping a table
    or database link, if Form Builder is holding a cursor open against the object being operated upon.
    Sarah

  • How do I use a variable within a sql statement

    I am trying to use a local variable within an open SQL step but I keep getting an error.
    My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " +  locals.CurrentSerialNo
    If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
    "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " +  " 'ABC001' " 
    Can someone tell me how to correctly format the statement to use a variable?

    Hi,
    Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
    When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
    Thanks again,
    Stuart
    Attachments:
    Database Test Sequence.seq ‏10 KB
    TestStand error.JPG ‏37 KB

  • How to use presentaion variable in the SQL statement

    Is there any special syntax to use a presentation variable in the SQL Statement?
    I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
    If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
    And this works fine but when i convert this to SQL, it returns
    "Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
    And this does not work.It is not being set to the value in the prompt.
    I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. Thanks

    Try this: '@{Fscl_Qtr_Var}'

  • IScript problem - Cannot use an input in a sql statement

    I get the input from an input box and it is correct
    &param = %Request.GetParameter("Dept");
    I try to use it in a sql statement lke this and nothing displays even though it its entered correctly and the value exists in the table
    Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = '&param'");
    If I leave out the single quotes around and do it like this &param then it errors out
    Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = &param");
    I need help structuring this correctly
    Thanks,
    Allen Cunningham

    Hi,
    CreateSQL does not execute the sql statement, it just creates an SQL object, which you have to execute.
    Something like this:
    &param = %Request.GetParameter("Dept");
    Local SQL &usersCursor = CreateSQL("SELECT EMPLID, BIRTHDATE, NAME FROM PS_EMPLOYEES WHERE DEPTNAME_ABBRV = :1", &param);
    While usersCursor.Fetch(&Emplid, &Birthdate, &Name)
    /* do processing*/
    End-While;

  • Using 'NOT IN' Within a SQL Statement

    Does anyone know why the following SQL statement does not return any values? The problem is with the SELECT statement within the 'NOT IN' clause. When explicitly typing in the part_ids returned from the select statement, everything works as expected.
    Thanks for any help.
    SELECT Distinct Part_Id, Trans_Date
         FROM Invctrl
         WHERE Trans_Type = 0
         AND Trans_Date BETWEEN To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
         AND To_Date( '31-Jan-2007 23:59:59', 'dd-mon-yyyy hh24:mi:ss' )               
         AND Part_Id NOT IN (SELECT part_Id From InvCtrl WHERE Trans_Date < To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss'))

    'NOT IN' should be avoided where ever we can.
    Change your query to 'IN' clause as below and it should work.
    SELECT DISTINCT part_id, trans_date
               FROM invctrl
              WHERE trans_type = 0
                AND trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
                                                'dd-mon-yyyy hh24:mi:ss'
                                   AND TO_DATE ('31-Jan-2007 23:59:59',
                                                'dd-mon-yyyy hh24:mi:ss'
                AND part_id IN (
                       SELECT part_id
                         FROM invctrl
                        WHERE trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
                                                          'dd-mon-yyyy hh24:mi:ss'
                                             AND TO_DATE ('31-Jan-2007 23:59:59',
                                                          'dd-mon-yyyy hh24:mi:ss'
                       MINUS
                       SELECT part_id
                         FROM invctrl
                        WHERE trans_date <
                                 TO_DATE ('1-Mar-2006 00:00:00',
                                          'dd-mon-yyyy hh24:mi:ss'
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to write named query if we want to use IN syntax in our sql statement?

    I cannot find a suitable category about named query, so please move to appropriate place if there is any.
    When we write named query, below statement is fine.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field1 = :input1");             q2.setParameter("input1", "value1");
    Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");             q2.setParameter("input1", "3633, 3644");
    Can anyone suggest? Thanks.

    roamer wrote:
    Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");
    q2.setParameter("input1", "3633, 3644");
    Can anyone suggest?The above is in your code right? Not in some configuration file?
    Then you do it the same way as with regular jdbc/sql.
    1. You start with a collection of values - call it collection A.
    1. Create a for loop that dynamically creates the string using 'bind' variables (whatever you want to call the 'colon' entity in the above).
    2. Call the createQuery method using the string that was created
    3. Create a second loop that iterates over A and populates with setParameter.
    Pseudo code
            Object[] A = ...
            String sql = "SELECT o FROM Table1 as o WHERE field2 IN (";
            for (int i=1; i <= A.length; i++)
                  if (i == 1)
                     sql += ":input" + i;
                 else
                     sql += ",:input" + i;
            sql += ")";
            Query q2 = em.createQuery(sql);
            for (int i=1; i <= A.length; i++
                  q2.setParameter("input" + i, A[i-1]);
                  }By the way there is a jdbc forum.

  • How to query using CGI path for 'IN' sql statement

    Some problems that requires help:
    I have a report that requires a query which has 'IN' statement in SQL query. For example: SELECT EMP_ADDRESS1 FROM EMPLOYEE WHERE EMP_NO IN (:EMP_NO).
    I am going to query the result of this query using CGI. My peoblem starts here - I can't be passing a list of parameter for ':EMP_NO' because the path does not accept escape characters. I can't be put a query path below:
    <HTML>http://172.188.2.7/dev60cgi/rwcgi60.exe?server=9iAS&mode=default&destype=localfile&desformat=\\pri_wnt\generic&report=gcgd1.rdf&userid=comm/comm@employee<B>&emp_no='A','B','C'<B></HTML>
    What I am doing is that I will have a front end written in JAVA and display a listing of Employee available in the company. The user will be able to choose whatever employee on the front end. Then, I will call the CGI path to display the result to the user.
    Pls help. Kindly email personally([email protected]) or reply here.
    Thank you

    You'll need to escape your single quotes using %XX where XX is the hex code corresponding to the special character you want to use. I'm not sure what the escape code is for quotes. I know that if you wanted to have a space, this:
    ....../rwcgi60.exe?key+P_city='San Francisco'+....
    would need to look like:
    .../rwcgi60.exe?key+p_city=San%20Francisco+...
    You'll need to find out what the number for quote is. HOpe that helps a bit.
    Toby

  • How do I use bind variables for the SQL statements having IN clause

    SELECT id, name FROM t
    WHERE id in (10,20,30)
    As the IN list will have 'n' number of values, I am not able to specify fixed number of bind
    variables like
    SELECT id, name FROM t
    WHERE id in (?,?,?....)

    452051 wrote:
    I am not able to specify fixed number of bind variablesYou could use collection:
    SQL> create or replace force
      2    type NumList
      3      as
      4        table of number
      5  /
    SQL> select ename from emp where deptno member of NumList(10)
      2  /
    ENAME
    CLARK
    KING
    MILLER
    SQL> select ename from emp where deptno member of NumList(10,20,30)
      2  /
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> This way you have one bind variable - collection.
    SY.

  • How to write a java function for use in where clause in SQL statement

    Hi,
    Does anyone know a good tutorial on how to write and include a Java class/function into Oracle.
    I'd like to write mathematical function to use in my queries, but the resources available in PL/SQL are very limited.
    Many thanx

    Pim,
    I see you got an answer in the PL/SQL forum.
    But in case you haven't seen it, perhaps this Web page will help:
    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • Using the "IN" expression in SQL statement

    Hi,
    I have an array with multiple values stored in it. I would like to use these values in the filter expression of another query using the "IN" clause (data is coming from a sql dataabse). Is there a way to achieve this, I did not see an option in the std query template for using the "IN" expression.
    Thanks.

    Or, to save Params, pass in a comma separated list of match values:
    select * from mytable where mycolumn in ([Param.1])
    And if you are getting the comma separated list from say an iBrowser, here are two quick utilities to build a comma separated list of the iBrowser values or iBrowser Datalink values:
    // returns comma separated list of DATALINK values from iBrowser.
    // if none selected, returns list of all values
    function getCSLDatalinkValues(myApplet) {
         var selValues = "";
         var selCount = myApplet.getBrowserObject().getSelectedItemCount();
         if(selCount) {
              for(var i=1; i<= selCount; i++) {
                   selValues += myApplet.getBrowserObject().getSelectedDatalinkValueAt(i) + "','";
         } else {
              for(var i=1; i<= myApplet.getBrowserObject().getItemCount(); i++) {
                   selValues+= myApplet.getBrowserObject().getDatalinkValueAt(i) + "','";
         // remove trailing ","
         selValues = selValues.substring(0,selValues.length-2);
         // insert begin "'"
         selValues = "'" + selValues;
         return selValues;     
    // returns comma separated list of values from iBrowser.
    // if none selected, returns list of all values
    function getCSLValues(myApplet) {
         var selValues = "";
         var selCount = myApplet.getBrowserObject().getSelectedItemCount();
         if(selCount) {
              for(var i=1; i<= selCount; i++) {
                   selValues += myApplet.getBrowserObject().getSelectedItemAt(i) + ",";
         } else {
              for(var i=1; i<= myApplet.getBrowserObject().getItemCount(); i++) {
                   selValues += myApplet.getBrowserObject().getItemAt(i) + ",";
         // remove trailing ","
         selValues = selValues.substring(0,selValues.length-1);
         return selValues;     

  • Re: (forte-users) Using IN in a direct SQLstatement.

    Hi,
    What does the string in myType look like? You should
    be careful with ' and \ as they are used by Forte. I
    suggest you post a sample of the myType's value.
    Regards,
    Peter Sham.
    --- Rumen Georgiev <[email protected]> wrote:
    Hi folks,
    I have a problem when executing direct SELECT
    statement against Oracle 7.4, something like that:
    SQL SELECT ..... INTO .... FROM ..... WHERE .....
    AND
    TYPE IN :myType ON SESSION .......
    myType is TextData containing a list of possible
    values separated by commas. myType is set at run
    time.
    When executed through SQL*Plus the result is O.K..
    When executed through Forte it doesn't return
    anything. It seems that eigther Forte or Oracle
    disregards the commas and treats myType as it will
    with =,>,<. What makes me think so is that when
    myType
    holds single value it works. It fails as soon as I
    concatenate one more value from the list. Same
    happens
    when using cursor. I didn't try it with DBSession
    methods but I assume the result will be the same. I
    can't use EXECUTE EMMEDIATE because I expect result
    set(INTO). So far the only way I can think of is a
    WHILE loop for every single value from the list.
    Any ideas,comments or workarounds?
    Thank's in advance.
    Rumen
    For the archives, go to:
    http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To
    unsubscribe, send in a new
    email the word: 'Unsubscribe' to:
    [email protected]
    =====

    rumen, peter,
    Database placeholder substitution is only available for atomic value,
    ie. myType can only be CI, or NG, or MS.
    There are many ways to workaround this limitation, such as defining
    your select statement to contain the IN clause before doing the DBprepare.
    hope this helps,
    linh ...
    -----Original Message-----
    From: Peter Sham [mailto:[email protected]]
    Sent: Tuesday, October 12, 1999 5:57 PM
    To: Rumen Georgiev; [email protected]
    Subject: Re: (forte-users) Using IN in a direct SQL statement.
    Hi,
    Maybe try this:
    myType.setValue('(\'CI\',\'NG\',\'MS\')');
    Regards,
    Peter Sham.
    --- Rumen Georgiev <[email protected]> wrote:
    Peter,
    I tried a couple of things to no avail. The simplest
    one is like this:
    myType.SetValue('\'CI\',\'NG\',\'MS\'');
    It works if I do
    myType.SetValue('\'CI\'');
    Same is valid if myType is declared as a String.
    Hi,
    What does the string in myType look like? Youshould
    be careful with ' and \ as they are used by Forte. I
    suggest you post a sample of the myType's value.
    Regards,
    Peter Sham.
    --- Rumen Georgiev <[email protected]> wrote:
    Hi folks,
    I have a problem when executing direct SELECT
    statement against Oracle 7.4, something like that:
    SQL SELECT ..... INTO .... FROM ..... WHERE .....
    AND
    TYPE IN :myType ON SESSION .......
    myType is TextData containing a list of possible
    values separated by commas. myType is set at run
    time.
    When executed through SQL*Plus the result is O.K..
    When executed through Forte it doesn't return
    anything. It seems that eigther Forte or Oracle
    disregards the commas and treats myType as it will
    with =,>,<. What makes me think so is that when
    myType
    holds single value it works. It fails as soon as I
    concatenate one more value from the list. Same
    happens
    when using cursor. I didn't try it with DBSession
    methods but I assume the result will be the same.I
    can't use EXECUTE EMMEDIATE because I expectresult
    set(INTO). So far the only way I can think of is a
    WHILE loop for every single value from the list.
    Any ideas,comments or workarounds?
    Thank's in advance.
    Rumen__________________________________________________
    For the archives, go to:
    http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To
    unsubscribe, send in a new
    email the word: 'Unsubscribe' to:
    [email protected]
    =====
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe,
    send in a new
    email the word: 'Unsubscribe' to: [email protected]

  • USING MULTIPLE SELECT VARIABLE IN A SQL STATEMENT

    In HTMLDB, the value of the parameter of a multiple select box is colon delimited(ie P6_Name = Smith:Jones:Burke). Is there an easy way to use this parameter in a SQL statement?
    Example
    Select *
    from names
    where
    Name=P6_Name
    Select *
    from names
    where
    Name IN ('Smith','Jones','Burke')
    Thank you

    Thank you for your response! I'm an idiot. It didn't make sense to me because your talking about a <i>multi-select</i> variable and I was thinking about a <i>select-list</i> variable. My problem is that I need to assign a list of values to one select list item.
    <br>
    For example:
    <br>
    SELECT * FROM EMPLOYEE
    WHERE EMPLOYEE_TYPE IN ( :SELECT_LIST_RETURN_VALUE );
    <br><br>
    With the select list as
    <br><br>
    Display value = All Types, Some Types, One Specific Type<br>
    Return Value = (Type1, type2, type3), (type1, type2), (type3)
    <br><br>
    I've just started in all of this so I'd imagine that I'm probably going about it wrong.

  • Assigning values to 2 fields using sql statement

    db11g , apex 4.0 and firefox 24 ,
    hi all ,
    i am trying to follow this tutorial to assign values to 2 items on a page using sql statement ,
    and i am using the same sql statement the tutorial uses
    select d.loc location, count(e.empno) num_employees from dept d, emp e where d.deptno = e.deptno(+) and d.deptno = :P3_DEPTNO group by d.loc -- btw , what does the "+" sign mean?
    after the e.deptno in the where condition .
    but i am facing this error
    1 error has occurred
    Wrong number of columns selected in the SQL query. See Help of attribute for details.
    and it does not work with two columns in the select statement under any conditions , i tried to remove the group function and the group clause ,
    it does not work unless i use only one column in the select statement ??
    thanks

    Pars
    And how exactly is this rewrite of the sql statement resolving the OP's issue.
    You are still using more than 1 column which will still result in the error message:
    Wrong number of columns selected in the SQL query.
    As mentioned in my earlier post APEX 4.0 (the version the OP is using) does not handle a sql statement with multiple columns for the dynamic action Set Value.
    Which means the fastest  and simplest solution is splitting up the dynamic action in multiple Set Value actions.
    Using this plugin or upgrade to a newer apex version would also be a possibility.
    Nicolette

Maybe you are looking for