Dbms_Sql in forms 9i

We are migrating forms from forms6i to 9i
In forms 6i they are using the below
code.
l_cursor := dbms_sql.open_cursor;
dbms_sql.parse(l_cursor, l_stmt,2);
l_result := dbms_sql.execute(l_cursor);
dbms_sql.close_cursor(l_cursor);
In forms9i this is giving a compilation error.
I created a procedure in the database with this code
and calling the procedure in my forms9i, it is not giving compilation error, but at runtime it is giving this error
Error ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SYS_SQL line 826
ORACE-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "scott.sample" line 6
please suggest what to use instead of dbms_sql to solve this problem

DBMS_SQL is a server-side package, and DBMS_SQL.Native is a package variable. Server-side package variables cannot be accessed from forms. You can substitute the number 1 for the variable, though.
However, Oracle does not support using dbms_sql from Forms, anyway. You can use Exec_SQL, which is a Forms-side package, and it is almost the same as DBMS_SQL.
However, if you are just issuing some DDL, Forms_DDL will work fine. It is only when you want to retrieve data from the server that you need to use Exec_SQL.

Similar Messages

  • How to execute dynamic sql in forms 6i?

    Cursor_Handle     Integer     := DBMS_SQL.OPEN_CURSOR;
         Out_Put          Integer;
    BEGIN
         DBMS_SQL.PARSE(Cursor_Handle, Sql_Stmt , dbms_sql.v7);
         Out_Put := DBMS_SQL.EXECUTE(Cursor_Handle);
         DBMS_SQL.CLOSE_CURSOR(Cursor_Handle);
    return true;
    END;
    this is the procedure i have used. it works fine in server side but not in client side. pls help me to solve this problem.
    Advance tanx

    The reason your process won't compile is that you are using a package variable, dbms_sql.v7. (Why aren't you using dbms_sql.native?) If you change that variable to a value of 1 it will probably work.
    However, Francois is correct -- In Forms, you should be using the Exec_SQL package. It is built for Forms; Oracle does not support using DBMS_SQL from Forms. In fact, if you use Forms Builder 10g connected to Oracle 9i and try to compile, the compiler fails with internal errors. They say it works again if you connect to Oracle 10.
    Exec_SQL is identical to DBMS_SQL, except for exception handling. You have to make an additional call to catch the error if an exception occurs: Exec_SQL.Last_Error_Code

  • How To Do???  Text1: SQL Query..... Text2: Query Result

    Hi All!!!!!!!!!!
    My user required a form where he could write sql command and he requires
    return data on same form in a text field i.e.
    Select empno, ename
    From emp
    where deptno= 10
    Output:
    EMPNO ENAME
    1001 XYZ
    1002 ABC
    SOME ONE HAVE ANY IDEA HOW TO DO.....
    Message was edited by:
    rashad980
    Message was edited by:
    rashad980

    You will need to use Exec_SQL, NOT DBMS_SQL, since Oracle does not support using DBMS_SQL from Forms.  If you were to do this from scratch, it would take you weeks... No, change that to months!
    <p>There is a form called Tadpole, and the fmb is available.  The author is a sharp fellow named Gary Myers.  You can enter a select statement in one area, and the results are displayed like a spreadsheet below.
    <p>Here is the link:<br>    Tadpole: Form for Ad-Hoc SQL
    <p>If the above link requires a login, here is the full sequence of links.  I thought you could get in there as a guest.  If not, then somewhere it should allow you to sign up and then log in.<br>Start with this:  www.quest-pipelines.com<br>
    Click on the Oracle picture.<br>
    Click on PL/SQL Discussion Forum<br>
    Scroll down and click on Oracle Tools - Forms, Reports, Etc.<br>
    Scroll down and click on Tadpole: Form for Ad-Hoc SQL.  Date on the topic is 08/02/05 (02 Aug 2005)

  • Problem using DBMS_SQL in a form

    hi,
    I am trying to write a procedure which get an input string containing a SQL statement (a SELECT), executes it, fetches the rows and writes them into a Excel sheet. I found this article http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm describing how to use DBMS_SQL package. My goal is to parse my query and store result in an array (using DEFINE_ARRAY).
    I put theese two lines
    (declare c number;)
    c := dbms_sql.open_cursor;
    dbms_sql.parse(c,p_query,dbms_sql.native); (p_query is my input string containing SQL)
    But when I compile my program unit I get an error looking like that: "implementation restriction: DBMS_SQL.NATIVE: unable to access a remote package variable or cursor".
    Where is the error? should I set something to access the package, or is it not possible to use it inside a form?

    W1zard is correct. Switch to Exec_SQL. Oracle does not support Forms using DBMS_SQL.
    Now... please explain why you are not using a dynamic record group. It is SOOO much easier!
    And if you want to look at some code using both methods, Exec_SQL and dynamic record group, you can download my "Quick Access" dynamic utility form, here:   Oracle Forms Utilities

  • Dynamic IF statement in PL/SQL on-insert trigger in Forms 6.0

    I would like to build a dynamic IF statement for the on-insert trigger in a form... Users are restricted to which "projects" they are allowed to enter into the database. These restrictions are based on a security table. The same restrictions are used to build the dynamic where clause that limits which previously inserted records the users can see when they are in the form. Since the restrictions are identical, I want to use the same logic that I use to build a where clause to build a dynamic If statement instead... If the statement is true, the user can insert the record. If its false, they can't.
    I'm trying to this as follows:
    declare
    big_if varchar2(10000) :=' ';
    begin
    if :global.admin='YES'
    then
    insert_record;
    else
    declare
    cursor cur1 is
    select paren1, field, comparison_operator, value, paren2, and_or
    from rcdb.user_project_assign2
    where user_id = user;
    c1_rec cur1%ROWTYPE;
    begin
    for c1_rec in cur1 loop
    big_if:= big_if &#0124; &#0124; c1_rec.paren1 &#0124; &#0124; ':tbl_main_data.' &#0124; &#0124;c1_rec.field &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    end loop;
    end;
    if big_if
    then
    insert_record;
    else message('You are not allowed to insert this record');
    end if;
    end if;
    end;
    The problem is in the line
    IF big_if
    big_if is the variable that holds the text to my if statement (hense dynamic If statement) but I can't get the code to allow me to use that variable.
    Can anyone do this?
    null

    That code was great, but forms isn't allowing me to use the dbms_sql so I have to make a procedure out of forms and call it from the form. Both my form code and the procedure are compiling, but I"m still getting an error when the result is coming back to the form...
    the code in the form is:
    declare
    big_if varchar2(10000) :=' ';
    result varchar2(5) :=' ';
    check_state varchar2(2):=:tbl_main_data.state_abr;
    check_region varchar2(3):=:tbl_main_data.region_abr;
    check_program varchar2(25):=:tbl_main_data.program;
    begin
    if :global.admin='YES'
    then
    insert_record;
    else
    declare
    cursor cur1 is
    select paren1, field, comparison_operator, value, paren2, and_or
    from rcdb.user_project_assign2
    where user_id = user;
    c1_rec cur1%ROWTYPE;
    begin
    for c1_rec in cur1 loop
    big_if:= big_if &#0124; &#0124; c1_rec.paren1;
    if c1_rec.field = 'state_abr' then
    big_if:=big_if &#0124; &#0124; 'check_state' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    elsif c1_rec.field = 'region_abr' then
    big_if:=big_if &#0124; &#0124; 'check_region' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    elsif c1_rec.field = 'program' then
    big_if:=big_if &#0124; &#0124; 'check_program' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    end if;
    end loop;
    end;
    message(big_if); pause;
    message(check_state); pause;
    message(check_region); pause;
    message(check_program); pause;
    rcdb.check_if(big_if,result,check_state,check_region,check_program);
    message('resulte = &#0124; &#0124;result&#0124; &#0124;');
    if result = 'TRUE' then insert_record;
    else
    message ('you cant enter');
    end if;
    end if;
    end;
    AND THE CODE IN THE PROCEDURE IS....
    create or replace procedure check_if (
    big_if in varchar2,
    result out varchar2,
    check_state in varchar2,
    check_region in varchar2,
    check_program in varchar2
    IS
    v_indx binary_integer := 0;
    v_sql_syntax varchar2(32767);
    root_cursor number;
    ignore integer;
    your_if_statement VARCHAR2(32767);
    v_check VARCHAR2(5);
    BEGIN
    your_if_statement := ' if '&#0124; &#0124;big_if&#0124; &#0124;' then :v_check := ''TRUE''; end if;';
    v_sql_syntax := 'begin '&#0124; &#0124;your_if_statement&#0124; &#0124;' end;';
    root_cursor := dbms_sql.open_cursor;
    v_sql_syntax := replace(replace(REPLACE(v_sql_syntax,chr(10),' '),chr(13),' '),chr(9),' ');
    dbms_sql.parse(root_cursor,v_sql_syntax,dbms_sql.v7);
    dbms_sql.bind_variable( root_cursor, ':v_check',v_check,5);
    ignore := dbms_sql.execute(root_cursor);
    dbms_sql.variable_value(root_cursor, ':v_check', v_check);
    if v_check = 'TRUE' then result:='TRUE';
    else
    result:='FALSE';
    end if;
    dbms_sql.close_cursor(root_cursor);
    END check_if;
    DO YOU KNOW WHATS WRONG?

  • UTL_FOPEN is not working in 10g forms.

    Hi...
    I am using following code to open a file in write mode in forms 10g.
    mfile_id := SYS.UTL_FILE.FOPEN('PERFDATA','text.txt','w');
    ( PERFDTA is a directory object.)
    When i run form this gives the error, ORA-04067.
    But same code works in pl/sql.
    Can any one help me regarding this.
    Thanks in advance,
    Kumar

    uhm...why using utl_file?!? Is there any special circumstance why u have to use this? This package is for use in stored procedures only...You don't even use dbms_sql instead of exec_sql in forms either, huh?
    * Files which are on the database server and should be read by pl/sql packages => utl_file
    * Files which are on the Middle Tier and should be read by Forms => text_io (syntax is similar to utl_file)
    * Files which are on the client => webutil...
    if you want to read files which are on the database server in forms, you can just put the logical part into a pl/sql package on the database and use this...???
    regards
    Christian

  • Please help me for peculiar error in Dbms_sql.

    Hi im using form 6i
    Send query and display output that is my work
    sqltext = 'Select a.vendcode,vendname,ap_documentno,ap_documentdate,b.grinno,sum(nvl(landed_cost,0))+sum(nvl(net_rate,0))+sum(nvl(c.cessamount,0))+sum(nvl(vatamount,0)) apGrinval
    from billmain a,Billitem b,grinitem c,vendmast d
    where a.unitid = :Unit_id
    and ap_documentdate between :From_dt and :To_dt
    and a.unitid = b.unitid
    and a.documentno = b.documentno
    and substr(ap_documentno,1,1) <> substr(b.grinno,1,1)
    and b.unitid = c.unitid
    and b.grinno = c.grinno
    and a.vendcode = d.vendcode
    and b.partnumber = c.partnumber
    group by a.vendcode,ap_documentno,ap_documentdate,b.grinno,vendname';
    and i have procedure
    PROCEDURE Display_Records(BlockName Varchar2,Sqltext Varchar2) IS
    c integer := dbms_sql.open_cursor;
    cnt integer;
    desctab dbms_sql.desc_tab;
    colval varchar(4000);
    stat integer;
    pitem varchar2(100);
    BEGIN
    dbms_sql.parse(c,sqltext,1);
    Go_Block('Param');
    next_item;
    Loop
    Exit When Upper(Get_item_property(:System.Current_Item,Prompt_Text)) like 'PARAMETER%';      
    If Substr(:System.Current_value,-5,1) in ('/','.','-') Then
         dbms_sql.bind_variable(c,RTrim(Get_item_property(:System.Current_Item,Prompt_Text)),To_date(:System.Current_Value,'dd/mm/yyyy'));      
    Else
         dbms_sql.bind_variable(c,RTrim(Get_item_property(:System.Current_Item,Prompt_Text)),Rtrim(:System.Current_Value));
         End If;
         next_item;
    End Loop;
    dbms_sql.describe_columns(c,cnt,desctab);
    Go_Block('Data');
    First_Record;
    For i in 1..cnt Loop
         dbms_sql.define_column(c,i,colval,4000);
    End Loop;
    stat:=dbms_sql.execute(c);
    While (dbms_sql.Fetch_rows(c)>0) Loop
         pitem := Get_block_property(:System.Current_block,First_item);
    For i in 1..cnt Loop
         dbms_sql.column_value(c,i,colval);
         If colval = '0' Then
              colval := null;
         End If;
         copy(colval,pitem);
         Next_Item;
         Pitem := :System.Current_Item;
    End Loop;
    Next_Record;
    pause;
    End Loop;
    Delete_Record;
    END;
    all th queries r working perfectly but the above query. why i dont know, even the same query without the bold area
    its working but result working so I want to include bold creteria.
    Nothing error displayed, it is hanging on the area while (dbms_sql.Fetch_rows(c)>0)
    but with the same query when i tried in isql*plus it display 70 rows, but here it is hanging.
    Please help me what is the error.
    kanish

    Who told dbms_sql only for database. I had send lot of queries using this coding that is working perfectly except which i post.
    Yes, I solved it myself just i changed
    rtrim(b.partnumber) = rtrim(c.partnumber)
    Thank to all
    kanish
    Edited by: Kanish on May 1, 2009 11:03 PM

  • Problem using Option Buttons in a form

    Hello,<o:p></o:p>
    I created a form in Word using a table for defining the layout. Inside of some cells I inserted some Rich Text Content Control and in some others Option Buttons (ActiveX Control). Everything
    was working correctly.<o:p></o:p>
    The problem appears when I restrict the formatting and editing. I select the option "Allow only this type of editing in the document" and then choose "Filling in forms",
    finally click on "Yes Start Enforcing Protection". <o:p></o:p>
    Now if I want to fill in the form, at the beginning I'm able to click on the Cells with the Rich Text Content Control and type in some text, but as soon as I click on any of the Option Buttons
    all the Rich Text Content Controls get blocked, and I am not able to modify the text anymore. <o:p></o:p>
    The only way to make it work again is to jump to the next cells using the Tab key instead of using the mouse. If I go to the "Restrict Editing" and "Stop Protection", then
    everything works correctly.
    If I delete the Option Buttons the problem is solved as well, it doesn't matter if the from is protected or not.<o:p></o:p>
    How can I solve this issue? I'm using Windows 7 and Office 2013.<o:p></o:p>
    Thanks in advance.<o:p></o:p>

    W1zard is correct. Switch to Exec_SQL. Oracle does not support Forms using DBMS_SQL.
    Now... please explain why you are not using a dynamic record group. It is SOOO much easier!
    And if you want to look at some code using both methods, Exec_SQL and dynamic record group, you can download my "Quick Access" dynamic utility form, here:   Oracle Forms Utilities

  • Multiple connection in one form, is it possible?

    Im trying to access two different database (P.O.7 and the other is an ODBC Compliant) in one form.
    First thing i did was to run the wizard on each block using different login (1 for my PO7 and also the other) and it was successful, but when I try to execute the form, it just cant recognized the other block! since im only connected to other datasource....
    Any suggestion on what should i do with this....

    Check out the EXEC_SQL command under help in Forms
    The EXEC_SQL package allows you to access multiple Oracle database servers on several different connections at the same time. Connections can also be made to ODBC data sources via the Open Client Adapter (OCA), which is supplied with Developer. To access non-Oracle data sources, you must install OCA and an appropriate ODBC driver.
    The EXEC_SQL package contains procedures and functions you can use to execute dynamic SQL within PL/SQL procedures. Like the DBMS_SQL package, the SQL statements are stored in character strings that are only passed to or built by your source program at runtime. You can issue any data manipulation language (DML) or data definition language (DDL) statement using the EXEC_SQL package.

  • How to use a form to insert in differents schemas?

    Hi!
    I have three differents schemas, one per company (schema a, b, c) and I have a table of articles in each schema. This table must be the same in all the schemas. I have one form in the schema 'a'.
    How can I make an insert in the three schemas with this form? I'm using Oracle 9iR2 and Forms 6i.
    The table has 50 fields, I made it using DBMS_SQL but the code it's long and very ugly.
    Is there another way to do it? How could I get the insert sentence that generated the form?
    Thanks for your help.
    Regards

    Hi,
    you can use CTAS method or you can export & import the tables..
    create table b.table1 as select * from a.table1;
    create table c.table1 as select * from a.table1;
    you can export import whole schema or schema objects also
    expdp system/***** dumpfile=tables.dmp logfile=tab.log directory=data_pump_dir schemas=a
    and then
    impdp system/**** dumpfile=tables.dmp logfile=imp.log directory=data_pump_dir remap_schemas=(a:b)
    or you can individually import the tables also..

  • Plz help me...to display in  matrix  form

    Hi sir..
    i want to get this report in matrix form...plz i don't have any idea about matrix form...
    Right now iam getting like Below format::
    emp_name cat_name     type_name      theme_name                levels_skilllevel
    rubin      FE MODELLING SKILLS      A2-Assembly - connectors      N
    rubin      FE MODELLING      SKILLS           A2-Assembly - welding                N
    rubin      FE MODELLING      SKILLS           A2-Batch meshing                I
    rubin      FE MODELLING      SKILLS           A2-CFD meshing                     None
    rubin      FE MODELLING      SKILLS           A2-I order Hex meshing                None
    rubin      FE MODELLING      SKILLS           A2-I order Tet meshing                None
    rubin      FE MODELLING      SKILLS           A2-II order Hex meshing           None
    rubin      FE MODELLING      SKILLS           A2-II order Tet meshing           None
    rubin      FE MODELLING      SKILLS           A2-Macros                     None     
    rubin      FE MODELLING      SKILLS           A2-Mid-plane shell meshing           None
    rubin      FE MODELLING      SKILLS           A2-Moldflow meshing                None
    rubin      FE MODELLING      SKILLS           A2-Morphing                     B
    rubin      FE MODELLING      SKILLS           SKILL2                          None
    rubin      POST PROCESSING AUTO[SUB]SYS      AUTO-36                N
    rubin      POST PROCESSING AUTO[SUB]SYS      AUTO-6                     B
    rubin      POST PROCESSING AUTO[SUB]SYS      AUTO3                     I
    rubin      POST PROCESSING AUTO[SUB]SYS      TERMINAL                P
    freddy      FE MODELLING      SKILLS           A2-Assembly - welding                B
    freddy      FE MODELLING      SKILLS           A2-Batch meshing                P
    freddy      FE MODELLING      SKILLS           A2-Macros                     P
    freddy      FE MODELLING      SKILLS           A2-Morphing                     I
    freddy      THERMAL      SKILLS           SKILL-15                          None
    freddy      THERMAL      SKILLS           SKILL-41                          B
    freddy      THERMAL      SKILLS           SKILL-42                          I
    freddy      THERMAL      SKILLS           SKILL-45                          P
    freddy      THERMAL      SKILLS           SKILL-47                          N
    freddy      THERMAL      SKILLS           SKILL-57                          None
    -->     .....check the below one...
    -->Example:see emp_name rubin->cat_name     -> type_name ->theme_name->levels_skilllevel is 'N'
         see emp_name freddy->cat_name-> type_name ->theme_name->levels_skilllevel is 'B'
    cat_name     type_name           theme_name                rubin      freddy
    FE MODELLING      SKILLS      A2-Assembly - connectors      N     B     
    I have written the below query To get it as Above::
    SELECT ae.emp_name, am.cat_name, am.type_name, am.theme_name, am.levels_skilllevel
    FROM alt_employee ae, (
    SELECT *
    FROM alt_category ac, alt_type at, alt_theme atm, alt_levels al, alt_employee ae
    WHERE ac.cat_id
    IN (
    SELECT cat_id
    FROM alt_category
    ) AND ac.cat_id = atm.theme_catid
    AND atm.theme_typeid = at.type_id
    AND atm.theme_id = al.levels_theme_id
    AND al.levels_skilllevel
    IN ('B', 'N', 'I', 'P', 'None')
    GROUP BY cat_name, type_name, theme_name, levels_skilllevel
    )am
    WHERE ae.emp_id = am.levels_employee_id
    Regards
    Narendra

    My solution was a pivot function.
    Using that function will give you something like:
    SQL> select * from table( pivot(
      2  'select cat.cat_name
      3       , type.type_name
      4       , theme.theme_name
      5       , emp.emp_name
      6       , levels.levels_skilllevel
      7  from alt_theme theme
      8     , alt_category cat
      9     , alt_type type
    10     , alt_levels levels
    11     , alt_employee emp
    12  where cat.cat_id (+) = theme.theme_catid
    13  and   type.type_id = theme.theme_typeid
    14  and   levels.levels_theme_id = theme.theme_id
    15  and   emp.emp_id = levels.levels_employee_id
    16  '
    17   ) );
    CAT_NAME TYPE_NAME       THEME_NAME                freddy    ruby
    FE       MODELLING       A2-Assembly - welding     B         B
    FE       MODELLING       A2-Assembly - connectors            N
             THERMAL SKILLS  SKILL-41                  B         I
             THERMAL SKILLS  SKILL-42                  N         P
    SQL> Anton
    create or replace type PivotImpl as object
      ret_type anytype,      -- The return type of the table function
      stmt varchar2(32767),
      cur integer,
      static function ODCITableDescribe( rtype out anytype, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number,
      static function ODCITablePrepare( sctx out PivotImpl, ti in sys.ODCITabFuncInfo, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number,
      static function ODCITableStart( sctx in out PivotImpl, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number,
      member function ODCITableFetch( self in out PivotImpl, nrows in number, outset out anydataset )
      return number,
      member function ODCITableClose( self in PivotImpl )
      return number
    create or replace type body PivotImpl
    as
      static function ODCITableDescribe( rtype out anytype, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number
      is
        atyp anytype;
        cur integer;
        numcols number;
        desc_tab dbms_sql.desc_tab2;
        rc sys_refcursor;
        t_c2 varchar2(32767);
      begin
        cur := dbms_sql.open_cursor;
        dbms_sql.parse( cur, p_stmt, dbms_sql.native );
        dbms_sql.describe_columns2( cur, numcols, desc_tab );
        dbms_sql.close_cursor( cur );
        anytype.begincreate( dbms_types.typecode_object, atyp );
        for i in 1 .. numcols - 2
        loop
          atyp.addattr( desc_tab( i ).col_name
                      , case desc_tab( i ).col_type
                          when 1   then dbms_types.typecode_varchar2
                          when 2   then dbms_types.typecode_number
                          when 9   then dbms_types.typecode_varchar2
                          when 11  then dbms_types.typecode_varchar2  -- show rowid as varchar2
                          when 12  then dbms_types.typecode_date
                          when 208 then dbms_types.typecode_urowid
                          when 96  then dbms_types.typecode_char
                          when 180 then dbms_types.typecode_timestamp
                          when 181 then dbms_types.typecode_timestamp_tz
                          when 231 then dbms_types.typecode_timestamp_ltz
                          when 182 then dbms_types.typecode_interval_ym
                          when 183 then dbms_types.typecode_interval_ds
                        end
                      , desc_tab( i ).col_precision
                      , desc_tab( i ).col_scale
                      , case desc_tab( i ).col_type
                          when 11 then 18  -- for rowid col_max_len = 16, and 18 characters are shown
                          else desc_tab( i ).col_max_len
                        end
                      , desc_tab( i ).col_charsetid
                      , desc_tab( i ).col_charsetform
        end loop;
        open rc for 'select distinct ' || desc_tab( numcols - 1 ).col_name || '
                              from( ' || p_stmt || ' )
                              order by 1';
        loop
          fetch rc into t_c2;
          exit when rc%notfound;
          atyp.addattr( t_c2
                      , case desc_tab( numcols ).col_type
                          when 1   then dbms_types.typecode_varchar2
                          when 2   then dbms_types.typecode_number
                          when 9   then dbms_types.typecode_varchar2
                          when 11  then dbms_types.typecode_varchar2  -- show rowid as varchar2
                          when 12  then dbms_types.typecode_date
                          when 208 then dbms_types.typecode_urowid
                          when 96  then dbms_types.typecode_char
                          when 180 then dbms_types.typecode_timestamp
                          when 181 then dbms_types.typecode_timestamp_tz
                          when 231 then dbms_types.typecode_timestamp_ltz
                          when 182 then dbms_types.typecode_interval_ym
                          when 183 then dbms_types.typecode_interval_ds
                        end
                      , desc_tab( numcols ).col_precision
                      , desc_tab( numcols ).col_scale
                      , case desc_tab( numcols ).col_type
                          when 11 then 18  -- for rowid col_max_len = 16, and 18 characters are shown
                          else desc_tab( numcols ).col_max_len
                        end
                      , desc_tab( numcols ).col_charsetid
                      , desc_tab( numcols ).col_charsetform
        end loop;
        close rc;
        atyp.endcreate;
        anytype.begincreate( dbms_types.typecode_table, rtype );
        rtype.SetInfo( null, null, null, null, null, atyp, dbms_types.typecode_object, 0 );
        rtype.endcreate();
        return odciconst.success;
      exception
        when others then
          return odciconst.error;
      end;
      static function ODCITablePrepare( sctx out PivotImpl, ti in sys.ODCITabFuncInfo, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number
      is
        prec     pls_integer;
        scale    pls_integer;
        len      pls_integer;
        csid     pls_integer;
        csfrm    pls_integer;
        elem_typ anytype;
        aname    varchar2(30);
        tc       pls_integer;
      begin
        tc := ti.RetType.GetAttrElemInfo( 1, prec, scale, len, csid, csfrm, elem_typ, aname );
        sctx := PivotImpl( elem_typ, p_stmt, null );
        return odciconst.success;
      end;
      static function ODCITableStart( sctx in out PivotImpl, p_stmt in varchar2, p_agg in varchar2 := 'max' )
      return number
      is
        cur         integer;
        numcols     number;
        desc_tab    dbms_sql.desc_tab2;
        t_stmt      varchar2(32767);
        t_stmt_end  varchar2(32767);
        type_code   pls_integer;
        prec        pls_integer;
        scale       pls_integer;
        len         pls_integer;
        csid        pls_integer;
        csfrm       pls_integer;
        schema_name varchar2(30);
        type_name   varchar2(30);
        version     varchar2(30);
        attr_count  pls_integer;
        attr_type   anytype;
        attr_name   varchar2(100);
        dummy2      integer;
      begin
        cur := dbms_sql.open_cursor;
        dbms_sql.parse( cur, p_stmt, dbms_sql.native );
        dbms_sql.describe_columns2( cur, numcols, desc_tab );
        dbms_sql.close_cursor( cur );
        for i in 1 .. numcols - 2
        loop
          t_stmt := t_stmt || ', "' || desc_tab( i ).col_name || '"';
        end loop;
        t_stmt := substr( t_stmt, 2 );
        t_stmt_end := t_stmt;
        type_code := sctx.ret_type.getinfo( prec
                                          , scale
                                          , len
                                          , csid
                                          , csfrm
                                          , schema_name
                                          , type_name
                                          , version
                                          , attr_count
        for i in numcols - 1 .. attr_count
        loop
          type_code := sctx.ret_type.getattreleminfo( i
                                                     , prec
                                                     , scale
                                                     , len
                                                     , csid
                                                     , csfrm
                                                     , attr_type
                                                     , attr_name
          t_stmt := t_stmt || ', ' || p_agg || '( decode( ' || desc_tab( numcols - 1 ).col_name || ', ''' || attr_name || ''', ' || desc_tab( numcols ).col_name || ' ) )';
        end loop;
        t_stmt := 'select' || t_stmt || ' from ( ' || sctx.stmt || ' ) group by' || t_stmt_end;
        sctx.cur := dbms_sql.open_cursor;
        dbms_sql.parse( sctx.cur, t_stmt, dbms_sql.native );
        for i in 1 .. attr_count
        loop
          type_code := sctx.ret_type.getattreleminfo( i
                                                    , prec
                                                    , scale
                                                    , len
                                                    , csid
                                                    , csfrm
                                                    , attr_type
                                                    , attr_name
          case type_code
            when dbms_types.typecode_char          then dbms_sql.define_column( sctx.cur, i, 'x', 32767 );
            when dbms_types.typecode_varchar2      then dbms_sql.define_column( sctx.cur, i, 'x', 32767 );
            when dbms_types.typecode_number        then dbms_sql.define_column( sctx.cur, i, cast( null as number ) );
            when dbms_types.typecode_date          then dbms_sql.define_column( sctx.cur, i, cast( null as date ) );
            when dbms_types.typecode_urowid        then dbms_sql.define_column( sctx.cur, i, cast( null as urowid ) );
            when dbms_types.typecode_timestamp     then dbms_sql.define_column( sctx.cur, i, cast( null as timestamp ) );
            when dbms_types.typecode_timestamp_tz  then dbms_sql.define_column( sctx.cur, i, cast( null as timestamp with time zone ) );
            when dbms_types.typecode_timestamp_ltz then dbms_sql.define_column( sctx.cur, i, cast( null as timestamp with local time zone ) );
            when dbms_types.typecode_interval_ym   then dbms_sql.define_column( sctx.cur, i, cast( null as interval year to month ) );
            when dbms_types.typecode_interval_ds   then dbms_sql.define_column( sctx.cur, i, cast( null as interval day to second ) );
          end case;
        end loop;
        dummy2 := dbms_sql.execute( sctx.cur );
        return odciconst.success;
      end;
      member function ODCITableFetch( self in out PivotImpl, nrows in number, outset out anydataset )
      return number
      is
        c1_col_type pls_integer;
        type_code   pls_integer;
        prec        pls_integer;
        scale       pls_integer;
        len         pls_integer;
        csid        pls_integer;
        csfrm       pls_integer;
        schema_name varchar2(30);
        type_name   varchar2(30);
        version     varchar2(30);
        attr_count  pls_integer;
        attr_type   anytype;
        attr_name   varchar2(100);
        v1     varchar2(32767);
        n1     number;
        d1     date;
        ur1    urowid;
        ids1   interval day to second;
        iym1   interval year to month;
        ts1    timestamp;
        tstz1  timestamp with time zone;
        tsltz1 timestamp with local time zone;
      begin
        outset := null;
        if nrows < 1
        then
    -- is this possible???
          return odciconst.success;
        end if;
        if dbms_sql.fetch_rows( self.cur ) = 0
        then
          return odciconst.success;
        end if;
        type_code := self.ret_type.getinfo( prec
                                          , scale
                                          , len
                                          , csid
                                          , csfrm
                                          , schema_name
                                          , type_name
                                          , version
                                          , attr_count
        anydataset.begincreate( dbms_types.typecode_object, self.ret_type, outset );
        outset.addinstance;
        outset.piecewise();
        for i in 1 .. attr_count
        loop
          type_code := self.ret_type.getattreleminfo( i
                                                     , prec
                                                     , scale
                                                     , len
                                                     , csid
                                                     , csfrm
                                                     , attr_type
                                                     , attr_name
            case type_code
              when dbms_types.typecode_char then
                dbms_sql.column_value( self.cur, i, v1 );
                outset.setchar( v1 );
              when dbms_types.typecode_varchar2 then
                dbms_sql.column_value( self.cur, i, v1 );
                outset.setvarchar2( v1 );
              when dbms_types.typecode_number then
                dbms_sql.column_value( self.cur, i, n1 );
                outset.setnumber( n1 );
              when dbms_types.typecode_date then
                dbms_sql.column_value( self.cur, i, d1 );
                outset.setdate( d1 );
              when dbms_types.typecode_urowid then
                dbms_sql.column_value( self.cur, i, ur1 );
                outset.seturowid( ur1 );
              when dbms_types.typecode_interval_ds then
                dbms_sql.column_value( self.cur, i, ids1 );
                outset.setintervalds( ids1 );
              when dbms_types.typecode_interval_ym then
                dbms_sql.column_value( self.cur, i, iym1 );
                outset.setintervalym( iym1 );
              when dbms_types.typecode_timestamp then
                dbms_sql.column_value( self.cur, i, ts1 );
                outset.settimestamp( ts1 );
              when dbms_types.typecode_timestamp_tz then
                dbms_sql.column_value( self.cur, i, tstz1 );
                outset.settimestamptz( tstz1 );
              when dbms_types.typecode_timestamp_ltz then
                dbms_sql.column_value( self.cur, i, tsltz1 );
                outset.settimestampltz( tsltz1 );
            end case;
        end loop;
        outset.endcreate;
        return odciconst.success;
      end;
      member function ODCITableClose( self in PivotImpl )
      return number
      is
        c integer;
        t_id user_objects.object_id%type;
      begin
        c := self.cur;
        dbms_sql.close_cursor( c );
        select object_id
        into t_id
        from user_objects
        where object_name = 'PIVOTIMPL'
        and   object_type = 'TYPE BODY';
    -- invalidating of the type body forces that ODCITableDescribe is executed for every call to the pivot function
    -- and we do need that to make sure that any new columns are picked up (= new values for the pivoting column)
        dbms_utility.invalidate( t_id );
        return odciconst.success;
      end;
    end;
    create or replace
    function pivot( p_stmt in varchar2, p_agg in varchar2 := 'max' )
    return anydataset pipelined using PivotImpl;
    /

  • Problem while passing parameter between forms

    Hi,
    I am tring to call a form from another form using the code
    fnd_function.EXECUTE (function_name => 'TABFORMFUN',
    open_flag => 'Y',
    session_flag => 'Y',
    other_params => 'EMPNO="' ||'paramvalue'||'"');
    in WHEN-MOUSE-CLICK trigger.
    when I deployed it in applications and click the button on the first form
    getting an error message:
    FRM-47023 No such parameter Named G_QUERY_FIND exist in form TABFORM.
    Thanks
    Kittu.

    Hi there
    I have the following questions:
    1. Does the code work in any of you environments?
    2. Does the G_QUERY_FIND exist in the TABFORM form? If it is not there, what happens if you add it?
    3. Can we have a sample of what code is in the fnd_function.EXECUTE procedure? This will help expain the actual method that you are calling the TABFORM form with. i.e are you using call_form/open_form/new_form built-ins or are you constructing a URL. I assume this is a forms/library based package.
    Sorry to be picky Eric, but EXECUTE is not an Oracle reserved word, it is perfectly fine to use it. Oracle use is themselves in various manners e.g. as a function in the dbms_sql package as well as for the EXECUTE IMMIDIATE statement for imbedded dianamic sql. Ref to the following Oracle URL for a list of all reserved words: http://download-east.oracle.com/docs/cd/B14117_01/server.101/b10759/ap_keywd.htm
    Cheers
    Q

  • Error in form ora- 00907

    hi all
    i have work in the oracle form and genrating the dynamic query in the pl/sql block and to accessing in the remote so use the statemet
    dbms_sql.parse(src_cur, str,1);
    st_cur is cursor define
    str is my string pass;
    1 insad of dbms_sql.native bas in the remote data are access
    way is error is give and what is the solutaion.
    help
    thanks;

    Could you list the exact code you are using as the error is:
    ORA-00907: missing right parenthesis
    Cause: A left parenthesis has been entered without a closing right parenthesis, or extra information was contained in the parentheses. All parentheses must be entered in pairs.

  • Using Native Dynamic SQL in Forms

    Can Native Dynamic SQL be used in Forms 5.0 or Forms 6.0? (Database 8.1.6.0.0)
    I have tried the following code (examples below) from the PL/SQL User's Guide and Reference Release 8.1.6 and the Metalinks Note: 62592.1 and the trigger/procedure (in Forms) will not compile. I appreciate any help given.
    Example1:
    (I have a table named temp_jane with a column named companies and a value 'Hello'. When compiling, I receive the error: 'Error 103 at line 8, column 11 Encountered the symbol ''IMMEDIATE" when expecting one of the following :=.(@%; ')
    declare
    str varchar2( 200 );
    val varchar2( 20 );
    ret temp_jane%rowtype;
    begin
    str := 'select company from temp_jane where company = :b1';
    val := 'Hello';
    execute immediate str into ret using val;
    message('Value fetched from table: '&#0124; &#0124;ret.company);
    end;
    Example2:
    (Here is the real issue, I don't know what the select statement, so I need to be able to assign a variable. When compiling, I receive the error: 'Error 103 at line 28, column 21 Encountered the symbol "VSQLSTATEMENT" when expecting one of the following: select ').
    declare
    type ItemsControlCurTyp is ref cursor;
    ItemsCur ItemsControlCurTyp;
    ItemsRec Items%rowtype;
    vSQLStatement varchar2( 5000 );
    vExecuteSQL varchar2( 5000 );
    vNumRows integer;
    vValue varchar2( 2000 );
    vFirstOne varchar2( 1 ) := 'Y';
    vRetval varchar2( 2000 );
    begin
    -- Display the column prompts with the right text.
    set_item_property( 'ITEMS_AVAILABLE.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.AVAILABLE_LABEL );
    set_item_property( 'ITEMS_CHOSEN.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.CHOSEN_LABEL );
    -- Save the original version of CHOSEN_STRING in case the user reverts or cancels.
    :ITEMS_CONTROL.CHOSEN_STRING_ORIG := :ITEMS_CONTROL.CHOSEN_STRING;
    vSQLStatement := :ITEMS_CONTROL.SELECT_STATEMENT;
    vExecuteSQL := vSQLStatement;
    -- Open the cursor
    open ItemsCur for vSQLStatement;

    Hi JTaylor
    You cannot use NDS in Client side (Developer). You have to use DBMS_SQL only.
    Regards
    A K Srinivasan
    Oracle.

  • ORA-1481 using DBMS_SQL.FETCH_ROWS

    Hi all.
    I have a package, called from forms 6, that in one of its functions uses DBMS_SQL package.
    It has a bunch of DBMS_SQL.DEFINE_COLUMN ....
    but fails with ora-1481 in this line (after all the DEFINE_COLUMN)
    <quote>
    traza := '07 ';
    if (DBMS_SQL.FETCH_ROWS(v_cursor)= 0 ) then
    traza := '71';
         exit;
    end if;
    traza := '08';
    .... more code
    <end quote>
    The procedure shows, going to the WHEN OTHERS exception, the error 1481 with '07' as traza (trace). Not '71', not '08'.
    Someone can help? Thank you all in advance.

    It could be caused because in the previous DBS_SQL.DEFINE_COLUMN some of the variables used like
    - "DBMS_SQL.DEFINE_COLUMN (v_cursor, 71, v_cdclave_sust ,1000 );" -> that (w_cdclave_sust) is a varchar2
    - or "DBMS_SQL.DEFINE_COLUMN (v_cursor, 71, v_cdclave_sust_2 );" -> w_cdclave_sust_2 is a number)
    are number?
    Thanks

Maybe you are looking for

  • Send a mail to the agents

    hi my question is send the mail to the assigned agents after the task is go through a condition, and condition fails it also have send mail and true it has send mail to the agents. I have designed the workflow and all other parts are working fine whe

  • How do I sync my photos and text messages from my last iphone (iphone 4) to new iphone?

    Just got the iphone 6. Can someone tell me how to sync my photos, old text messages, and notes from my last phone (iphone 4) to new phone? When I opened Itunes and connected my new phone...it said I can't sync my photos because I needed to update my

  • Improve hierarchical query speed using 'start with' and 'conect by prior'

    Hi The query within the 'explain' runs about a second and I need to imporve it. There are indexes set for both the child_id and the parent_id. The total number of rows for the PRM_COMPONENTS table is 120000. I'm working on 'Oracle Database 10g Releas

  • Hp laptop with flashing taskbar

    i have had new hp laptop g60-535dx and the taskbar randomly flashes for about 15-30 seconds and then stops happened about 2 times in a 1 hour period - has anyone experienced this and was it a hardware issue or windows 7 flaw --- thanks

  • Software developed before being hired litigation

    This is my first post so please bear with me if I'm in the wrong place. I have a question which has more legal aspects associated with than technical. I was asked by my ex employer to develop a demo website for one of their customers. To speed up the