Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Location
    hyderabad
    Posts
    6

    Unanswered: orcle d2k select statement

    I want to Write in d2k forms the way we write the sql statements in sQLPLUS

    Def x:='SAL'
    select sum(&x) from emp;

    Same thing I tried in D2k forms in the following Manner

    1. I took a parameter. called fields with Value assigned to to it as 'SAL'
    2. I Wrote a Post query in my block as
    select sum(arameter.fileds) into :block.sal from scott.emp;

    I am getting error FRM-40735 WITH ORA-1722

    Kindly help in solving this

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: orcle d2k select statement

    Originally posted by gln_gln_48
    I want to Write in d2k forms the way we write the sql statements in sQLPLUS

    Def x:='SAL'
    select sum(&x) from emp;

    Same thing I tried in D2k forms in the following Manner

    1. I took a parameter. called fields with Value assigned to to it as 'SAL'
    2. I Wrote a Post query in my block as
    select sum(:parameter.fileds) into :block.sal from scott.emp;

    I am getting error FRM-40735 WITH ORA-1722

    Kindly help in solving this
    You'll need to use Dynamic SQL, either using EXECUTE IMMEDIATE or the DBMS_SQL package - see the PL/SQL User Guide for more details.
    You will build the select statement in a string variable like:

    v_sql := 'SELECT SUM('||:parameter.field||') FROM emp';

    Then if using EXECUTE IMMEDIATE:

    EXECUTE IMMEDIATE v_sql INTO :block.sal;

    If your version of Forms doesn't support EXECUTE IMMEDIATE, then you will have to use the DBMS_SQL package.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •