Create Schema via PL/SQL block from textbox

I'm trying create a user based on a text box that the user/dba will enter. Is there not a way to use a bind variable for what is entered into the textbox, here is my pl/sql block:
BEGIN
EXECUTE IMMEDIATE 'create user :SCHEMA identified by :SCHEMA
DEFAULT TABLESPACE USERS
     TEMPORARY TABLESPACE TEMP
     QUOTA 0 ON SYSTEM
     QUOTA UNLIMITED ON USERS
     PROFILE DEFAULT';
end;
Any help is appreciated!

Ok, This work for creating the user now:
BEGIN
EXECUTE IMMEDIATE 'create user &SCHEMA. identified by &SCHEMA_PWD.
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
QUOTA 0 ON SYSTEM
QUOTA UNLIMITED ON USERS
PROFILE DEFAULT';
END;
All I did was change the textbox to just a textbox w/o submit and made the password a submit password and it worked, now I am getting insufficient priviledges when I try to add in:
BEGIN
EXECUTE IMMEDIATE 'create user &SCHEMA. identified by &SCHEMA_PWD.
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
QUOTA 0 ON SYSTEM
QUOTA UNLIMITED ON USERS
PROFILE DEFAULT';
EXECUTE IMMEDIATE 'GRANT CONNECT,RESOURCE TO &SCHEMA.';
EXECUTE IMMEDIATE 'ALTER USER &SCHEMA. DEFAULT ROLE ALL';
END;
I have disabled Authentication and made it DAD..which is the HTMLDB_PUBLIC_USER which has dba role..but still gives me insufficient priviledges. Any help is appreciated!

Similar Messages

  • How to execute pl/sql block from a file

    hi all,
    can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
    --begin
    --declare
    --end;
    Thanx

    Here is the file
    File is stored in C Drive (Windows Environment)
    declare
    x number;
    begin
    select 1 into x from dual;
    dbms_output.put_line(x);
    end;
    SQL> @c:\t.sql;
    1
    PL/SQL procedure successfully completed.Are you facing any issues?
    Regards,
    Bhushan

  • Creating Report via PL/SQL

    We have an application using HTML DB from which the we need to create reports for which the standard CSV will not work. The report can be created via PL/SQL except that the report needs to be created on the users workstation or a public location and not the server. Since UTL_FILE writes to the server, I am looking for help from the HTML DB and PL/SQL experts on packages/tools that can be used to output reports to local directories.

    not sure of your exact requirements, but consider using utl_file or Oracle Reports to generate your report on the server and then providing your users a "download report" link that lets them pull the file down locally. we talked about using Reports for this at...
    PDF file creation
    ...regards,
    raj

  • How To Create User through Pl SQL Block

    Want to create user from pl sql block using dynamic SQl. Used dbms_sql package . But when I run the block it does not recognises the parameter v7 which is a constant in dbms_sql package. Message displayed is Can not access parameter from package being restricted procedure.
    Is there any method to create user through PL SQl block

    hi ranjit,
    hope this will work
    declare
    uname varchar2(30):=&uname;
    pword varchar2(30):=&pword;
    begin
    execute immediate ('grant connect, resource to '| |uname| |' identified by '| |pword);
    end;
    regards

  • Creating tables in pl/sql block

    I have the following piece of code that I execute in sqlplusw as @c:\process.sql
    On running @c:\process.sql, an input is provided as prompted. There is a
    declare and begin that processes some code. What I am looking for is -- Is there
    a way that I can check the all_tables view for the following 3 tables :
    TABLE1, TABLE2, TABLE3. Only on finding these tables, this
    anonymous sql (that is inside starting from declare ... should execute).
    If these tables are not found, I want to attempt creating the tables. If the attempt
    was successful, then process. If creating tables attempt fails, exit with a dbms_output.put_line message and don't process
    anything....
    Can this be done ? If so, any hints would be great.....
    Thanks
    ACCEPT input_ssn prompt 'Enter SSN :'
    SET feedback off
    SET serveroutput on
    SET echo off
    SET term off
    SET heading off
    SET pagesize 0
    SET linesize 10000
    SET verify off
    undefne sdate input_ssn
    COL sdate new_value sdate
    COL input_ssn new_value input_ssn
    SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') sdate
    FROM DUAL;
    SPOOL C:\SCRUB_DATA_&&sdate._&&input_ssn..TXT
    SELECT 'REPORT GENERATED ON : ' || SYSDATE
    FROM DUAL;
    ALTER TRIGGER TRIG1 DISABLE;
    DECLARE
    BEGIN
    FOR i IN .........
    LOOP
    END LOOP;
    BEGIN
    SELECT ..........
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...........
    FOR i IN .....
    LOOP
    UPDATE ....
    BEGIN
    SELECT ...
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...
    BEGIN
    SELECT ....
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    UPDATE ...
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
         NULL;
    WHEN OTHERS
    THEN
    ecode := SQLCODE;
    emesg := SQLERRM;
    DBMS_OUTPUT.put_line ('Error code is : '||' - '|| ecode);
    DBMS_OUTPUT.put_line ('Error message is :' || ' - ' || emesg);
    END;
    COMMIT ;
    ALTER TRIGGER TRIG1 ENABLE;
    SET term on
    SET HEADING on
    SELECT 'Processing complete for ' || '&&input_ssn'
    FROM DUAL;
    SPOOL off;
    SET verify on
    SET feedback on
    ----------------------------------------------------------

    This is what I am doing :
    ACCEPT input_ssn prompt 'Enter SSN :'
    SET feedback on
    SET serveroutput on
    SET echo on
    SET term on
    SET heading on
    SET pagesize 0
    SET linesize 10000
    SET verify on
    undefne sdate input_ssn
    COL sdate new_value sdate
    COL input_ssn new_value input_ssn
    SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') sdate
    FROM DUAL;
    SPOOL C:\TEMP_DATA_&&sdate._&&input_ssn..TXT
    ALTER TRIGGER TRIG1 DISABLE;
    DECLARE
    v_postal cheque.postal%TYPE;
    v_count NUMBER;
    l_tabexist NUMBER;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('HELLO THERE');
         BEGIN
              DBMS_OUTPUT.PUT_LINE('HI THERE');
              SELECT 1 INTO l_tabexist FROM all_tables
                   WHERE table_name = 'TABLE1_TEMP' AND owner='HARPER';
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
                   EXECUTE IMMEDIATE 'CREATE TABLE TABLE1_TEMP AS SELECT * FROM TABLE1 WHERE 1=2';
                   EXECUTE IMMEDIATE 'ALTER TABLE TABLE1_TEMP ADD(TEMP_STATUS VARCHAR2(1))';
         END;
         BEGIN
                   SELECT 1 INTO l_tabexist FROM all_tables
                        WHERE table_name = 'TABLE2_TEMP' AND owner='HARPER';
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                        EXECUTE IMMEDIATE 'CREATE TABLE TABLE2_TEMP AS SELECT * FROM TABLE2 WHERE 1=2';
                        EXECUTE IMMEDIATE 'ALTER TABLE TABLE2_TEMP ADD(TEMP_STATUS VARCHAR2(1))';
         END;
    BEGIN
    <my code that uses TABLE1_TEMP and TABLE2_TEMP supposed to be created above>
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    DBMS_OUTPUT.put_line ('No Data Found Exception encountered');
    END;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.Put_Line('Something bad happened');
    RAISE;
    END;
    COMMIT ;
    ALTER TRIGGER TRIG1 ENABLE;
    SET term on
    SET HEADING on
    SPOOL off;
    SET verify on
    SET feedback on
    What is happening here is that until ALTER TRIGGER DISABLE, things are fine.
    Then, it tries to process <my code> and cries saying 'Table or view not found'. Finally it enables the trigger back.
    It is not even displaying either the 'HELLO THERE' or 'HI THERE' - which I suppose is the first thing it should have done.
    Thanks

  • Dynamically create javascripts using pl/sql code from page header

    I understand by placing a javascript code in the page header is one of the way adding javascript functionality to your pages.
    But lets say I need (dynamically) bring my javascripts into the page header using my pl/sql package/functions like core_func_jscript_pkg.get_jscript('jf_isnumber');
    1- How can I call my pl/sql package/functions from page header area of Apex?
    If I need to use 20 javascripts functions into a page which I have them stored in database (using them on my other pages) and I don't want to copy or re-write them in Apex, instead I like to have 20 line of calls to my pl/sql package like:
    core_func_jscript_pkg.get_jscript('myFirstJavascript');
    core_func_jscript_pkg.get_jscript('mySecondJavascript');
    core_func_jscript_pkg.get_jscript('myThirdJavascript');
    core_func_jscript_pkg.get_jscript('myFourthJavascript');
    ... and so on.
    2- In past we wrote our web apps using pl/sql example:
    htp.p('<html>');
    htp.p('<head>');
    core_func_jscript_pkg.get_jscript('jf_get_today_date');
    core_func_jscript_pkg.get_jscript('someothe_scripts');
    htp.p('</head>');
    htp.p('</html>');
    I like to do the same thing in Apex, Can I accomplish this in Apex?
    Thanks again
    -iahmadi

    There was a <head> content & dynamic metadata with APEX? that should provide some pointers.

  • How to call SQL script from PL/SQL block

    Hi All,
    I have a pl/sql block from which i need to call a *.sql script file.
    Please tell me that how can i do this?
    Thanks and Regards.

    > Though just for knowledge sake, would you please tell if there is a way
    to call a sql script from a pl/sql block.
    This question stems usually from a confusion about client-server and which is which in Oracle.
    SQL*Plus is a client. PL/SQL is a server side language. SQL is a server side language.
    When entering either one of these two languages in SQL*Plus (or TOAD, SQL-Developer, etc), the content is shipped to an Oracle server process, is parsed there, and is executed there.
    The Oracle server process servicing the client can accept a single SQL statement or PL/SQL block at a time.
    It cannot accept a block of SQL statements delimited with a semicolon. That is a client concept where the client will read each delimited statement and send that, one after the other (in synchronous call mode) to the Oracle server for execution.
    The Oracle server does not have a "script parser". It understands SQL. It understands PL/SQL. And that is what it expects from the client.
    Whether the client supports the SET command, the HOST command, SPOOL command, ability to run scripts, and so... have no bearing on what the server itself is capable of doing. The server does not care what feature set the client has. It is tasked with servicing the client via SQL and PL/SQL.
    It is not tasked to support or emulate client features like running SQL scripts.
    Nor confuse PL/SQL with the very limited command set of SQL*Plus. The two has nothing in common. And just as PL/SQL cannot understand C# or Delphi commands, it cannot understand SQL*Plus commands.

  • Db_link name and synonym in PL/SQL block

    Hi,
    I'm having a problem with synonyms in PL/SQL block.
    Say, I have two schemas A and B.
    In schema A, I create some tables and stored procedures.
    In schema B, I create a db link connecting to schema A. Then I create some synonyms for tables and stored procedures in schema A with the db link. In stored procedures created in schema B, I need to access or reference objects in schema by using synonyms.
    My problem is, if schema A and schema B reside on the same db instance and the instance's global_names is set to true, I will not be able to reference any synonyms in stored procedures created in schema B. The error message is,
    PL/SQL: ORA-00980: synonym translation is no longer valid.
    A simple example:
    In schema A,
    create table mytable (A char(2));
    In schema B,
    create database link <global_name-for-schema-A>@loopback connect to A identified by <A-pwd> using '<net-service-name-for-schema-A>';
    create synonym mytable for mytable@<global_name-for-schema-A>@loopback;
    declare
    a char;
    begin
    select * from mytable;
    end;
    But I have no problem to access the synonym-ed objects in SQL*PLUS.
    Please help.
    Thanks

    I had the similar problem i did a work around like below
    SQL>select max(col1) from tab1;
    MAX(COL1)
    21161910
    SQL>get a
    1 declare
    2 a number;
    3 begin
    4 select max(col1) into a from tab1;
    5 dbms_output.put_line(a);
    6* end;
    SQL>@a
    select max(col1) into a from tab1;
    ERROR at line 4:
    ORA-06550: line 4, column 1:
    PL/SQL: ORA-00980: synonym translation is no longer valid
    ORA-06550: line 4, column 1:
    PL/SQL: SQL Statement ignored
    Created a view on top of the synonym
    SQL>create or replace view tab1_v as select * from tab1@db1;
    View created.
    changed the pl/sql block as below to get it from view instead of synonymn
    declare
    a number;
    begin
    select max(col1) into a from tab1;
    dbms_output.put_line(a);
    end;
    Now it worked
    SQL>@a
    21161910
    PL/SQL procedure successfully completed.

  • Running a anonymous PL/SQL block

    Hi,
    I have created an anonymous PL/SQL block and saved it in a file. And I am now trying to run it from the sql prompt using @.
    But this doesn't seem to be working. I get a wierd number as output and then it hangs.
    This is not the case if I copy paste the anonymous block. In this case I get the correct output.
    Please assist as to whether it is possible to run it using @ as it is important for me to do so..

    Hi,
    You forgot the slash after the anonymous block:
    USER is "YJAM"
    TEST>-- Create anonymous Block
    TEST>BEGIN
      2    NULL;
      3  END;
    4 /
    PL/SQL procedure successfully completed.
    TEST>-- save as script
    TEST>save ab.sql
    Created file ab.sql
    TEST>get ab
      1  BEGIN
      2    NULL;
      3* END;
    TEST>@ab
    PL/SQL procedure successfully completed.
    TEST>ed ab Here, I delete line 4. hence the Block won't run.
    TEST>@ab
      4
      5
      6
      7
      8  . a dot to exit input mode. a slash would run the block
    TEST>Regards,
    Yoann.

  • [Solved] ADF BC - PL/SQL block 6 times faster than CreateRow/InsertRow

    THE ENVIRONMENT:
    - JDeveloper 10.1.2.0.0
    - Oracle 9.2.0.8.0
    THE PROBLEM:
    I found one of my pages in an ADF BC Web Application to be quite slow. After some profiling, I found a significant bottleneck in a loop which inserts approximately 270 rows in a table (only inserts into the table using insertRow). Would there be an improvement if we rewrite the transaction in PL/SQL code? To find out, I came up with the following simple test case:
    1) Table
    create table TES_FSOLICFONDO
    ID_SOLICITUD NUMBER not null,
    A_PAIS VARCHAR2(2),
    C_IDEMPRESA NUMBER,
    A_CODMONEDA VARCHAR2(3),
    C_LOCAL NUMBER,
    D_FECSOLICIT DATE,
    C_IDBILLMONE NUMBER not null,
    M_MONTO NUMBER,
    A_CREADOPOR VARCHAR2(30),
    D_CREACION DATE,
    A_MODIFPOR VARCHAR2(30),
    D_MODIF DATE);
    alter table TES_FSOLICFONDO
    add primary key (ID_SOLICITUD);
    create index IND_TES_FSOLICFONDO_01 on TES_FSOLICFONDO (C_IDBILLMONE, C_LOCAL, D_FECSOLICIT);
    create index IND_TES_FSOLICFONDO_02 on TES_FSOLICFONDO (C_IDEMPRESA, A_CODMONEDA, C_LOCAL, D_FECSOLICIT,C_IDBILLMONE);
    2) Sequence
    create sequence SEQ_TES_FSOLICFONDO
    minvalue 1
    maxvalue 999999999999999999999999999
    start with 1
    increment by 1
    cache 2;
    3) ADF BC
    - Create a Business Components Project with a BC package
    - Create new Entity Object based on the previous table, with standard wizard settings (this will be named TesFsolicfondo)
    - Create new View Object linked to previous Entity Object, with standard wizard settings (this will be named TesFsolicfondoVO).
    - Create an Application Module named AMTESAsignaSuperAvance, and include the previous View Object in the Data Model
    4) The test case
    - Create a test() method in the AMTESAsignaSuperAvanceImpl class as follows:
    public void test() throws Exception
    TesFsolicfondoVOImpl solVO = getTesFsolicfondoVO1();
    TesFsolicfondoVORowImpl r = null;
    for (int i = 0; i < 270; i++)
    r = (TesFsolicfondoVORowImpl) solVO.createRow();
    Sequence seq = new Sequence("SEQ_TES_FSOLICFONDO",this);
    r.setIdSolicitud(new Number(seq.getData().toString()));
    r.setAPais("PE");
    r.setCIdempresa(new Number(637292));
    r.setACodmoneda("USD");
    r.setCLocal(new Number(388));
    r.setDFecsolicit(new Date("2006-04-07"));
    r.setCIdbillmone(new Number(116));
    r.setMMonto(new Number(0));
    r.setACreadopor("10000003480");
    r.setDCreacion(new Date("2006-04-03"));
    solVO.insertRow(r);
    getTransaction().commit();
    - Create a test.jsp page including the following code within a scriptlet:
    AMTESAsignaSuperAvanceImpl am = null;
    try
    am = (AMTESAsignaSuperAvanceImpl) Configuration.createRootApplicationModule("cl.falabella.fpi.tes.bc.AMTESAsignaSuperAvance","AMTESAsignaSuperAvanceLocal");
    am.test();
    catch (Exception e)
    am.getTransaction().rollback();
    finally
    Configuration.releaseRootApplicationModule(am,true);
    - Create an equivalent PL/SQL block as follows:
    BEGIN
    FOR I IN 1..270
    LOOP
    INSERT INTO TES_FSOLICFONDO (ID_SOLICITUD, A_PAIS, C_IDEMPRESA, A_CODMONEDA, C_LOCAL,
    D_FECSOLICIT, C_IDBILLMONE, M_MONTO, A_CREADOPOR, D_CREACION)
    VALUES (SEQ_TES_FSOLICFONDO.NEXTVAL, 'PE', 637292, 'USD', 388, TO_DATE('07-04-2006', 'DD-MM-YYYY'), 116, 0,
    '10000003480', TO_DATE('03-04-2006', 'DD-MM-YYYY'));
    END LOOP;
    COMMIT;
    END;
    THE RESULTS:
    The PL/SQL block was executed on a standard SQL* Plus window, and the test() method within the AM was called from the test.jsp page.
    The PL/SQL block takes 1125 milliseconds in my setup, the test() method within the AM takes 6017 milliseconds, so PL/SQL is about 6 times faster in this test.
    THE QUESTION:
    Is this supposed to be this way? I want to avoid creating a PL/SQL package, I would rather use the ADF BC framework throughout the application. Would someone kindly point out any configuration issues I may have missed that will improve the BC performance?

    Hello Jan,
    Thanks for the tip, good to be born again as a name instead of a number.
    I omitted the code used for timing, but here goes:
    test.jsp:
    java.util.Date d1 = new java.util.Date();
    AMTESAsignaSuperAvanceImpl am = null;
    try
    am = (AMTESAsignaSuperAvanceImpl) Configuration.createRootApplicationModule("cl.falabella.fpi.tes.bc.AMTESAsignaSuperAvance","AMTESAsignaSuperAvanceLocal");
    am.test();
    catch (Exception e)
    am.getTransaction().rollback();
    finally
    Configuration.releaseRootApplicationModule(am,true);
    java.util.Date d2 = new java.util.Date();
    System.out.println("Time (ms) = " + Double.toString(d2.getTime()-d1.getTime()));
    PL/SQL:
    I use a tool called "PL/SQL Developer". It has a "Command Window" with a user interface which is extremely similar to SQL* Plus. After running the PL/SQL code, it reported "PL/SQL procedure successfully completed in 1.125 seconds".
    From the tool documentation:
    The Command Window
    The Command Window allows you to execute SQL scripts in a way that is very much similar to Oracle's SQL*Plus. To create a Command Window press the New button on the toolbar or select the New item in the File menu. A Command Window is created and you can type SQL and SQL*Plus commands like you are used to, without leaving PL/SQL Developer’s IDE.
    Regards
    Rodrigo

  • Create table in PL/SQL proc not working

    Hello,
    Here is a procedure I have tried to create & run in SQL Developer:
    create or replace procedure transpose as
    begin
    create table lines as (select level line from dual connect by level <= 5),
    create table cols as (select level col from dual connect by level <= 5),
    select max(decode(col, 1,
    decode(line, 1, line_id,
    2, description,
    3, statetax,
    4, freight,
    5, weightedAvg))) col1,
    max(decode(col, 2,
    decode(line, 1, line_id,
    2, description,
    3, statetax,
    4, freight,
    5, weightedAvg))) col2,
    max(decode(col, 3,
    decode(line, 1, line_id,
    2, description,
    3, statetax,
    4, freight,
    5, weightedAvg))) col3,
    max(decode(col, 4,
    decode(line, 1, line_id,
    2, description,
    3, statetax,
    4, freight,
    5, weightedAvg))) col4,
    max(decode(col, 5,
    decode(line, 1, line_id,
    2, description,
    3, statetax,
    4, freight,
    5, weightedAvg))) col5
    from lines, cols,
    (select rownum rn, tfe_line_info.* from tfe_line_info)
    where rn = col
    group by line
    order by line;
    end transpose;
    I however get the error:
    Error(3,7): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
    I cannot understand what is wrong with my Create statement at line 3?

    It looks like you have no PL/SQL experience. I suggest reading PL/SQL manual. Yes, single row select requires INTO clause. Multi-rows select requires cursor. But this is least of your problems. Your SPp will not complile even if you fix select. Why? SP creates tables dynamically at run time, so tables do not exist at SP compile time. Therefore select from these yet non-existent tables will not compile. By creating tables via dynamic SQL you forced yourself into querying them via dynamic SQL. Now you are trying to transpose (pivot) table. What Oracle version do you have? Oracle 11g provides PIVOT/UNPIVOT operators. Check them out before writing code.
    SY.

  • PL/SQL block to generate i/o

    Dear all,
    10.2.0.4 on solaris
    I want to generate I/O on a table. how can I create a a PL/SQL block which loops into and inserts/updates/deletes and commits on this table and thereby testing the I/O on the table ?
    Kai

    KaiS wrote:
    I want to generate I/O on a table. how can I create a a PL/SQL block which loops into and inserts/updates/deletes and commits on this table and thereby testing the I/O on the table ?What about the db buffer cache? What about Oracle attempting to optimise I/O performance by reducing physical I/O? What about the file system used and the o/s file system cache that does the exact same thing?
    How do you now "+test+" I/O? What exactly are you testing? The Oracle buffer cache? The o/s file system cache? The speed of the file system? The speed of the disk(s)?
    And if you get a result like "+100 inserts/per second+" - just what does that mean? How are you going to use this number to determine performance for application code, determine potential bottlenecks and so on?
    A journey can only start when you know the route and most importantly, the destination. Else you're just wandering around without a clue.

  • Create schema with all privileges

    hi
    I am creating Schema using following sql commands  with SYSTEM as user
    Create Schema Live2;
    CREATE COLUMN TABLE "Connections" (
    "memberIdFrom" INTEGER NOT NULL,
    "memberIdTo" INTEGER NOT NULL,
    PRIMARY KEY ("memberIdFrom","memberIdTo")
    Then I goto
    Security-->users-->SYSTEM-->object privileges
    there is not schema Live2 there
    When I add LIVE2 then it's privileges are set to CREATE ANY only
    Why this is happening?
    I think by default user should have all privileges.
    If i try to assign privileges then error exception occurs that Granter and Grantee are identical.

    Hi Khalid,
    Ideally when you execute sql 'create schema <schema_name>' then the logged in user is going to default owner of the schema and you should see that under 'object privileges' of that user.
    The user will have 'create any' privileges which means the user has all the privileges on that schema.
    if you want to check who is owner of the schema in the system, please check 'SCHEMAS' under views in SYS.
    Regards,
    Venkat N.

  • Select from Function PIPELINED on PL/SQL Block

    Hi folks,
    I have a PL/SQL Block and I need this block to show me in a grid the rows from a variable table (Type table) that I have declared.
    I don´t want to create Database objects, that's why I haven´t created tableTest like a type object in the database.
    Example:
    Declare
    type tableTest is table of varchar2(500);
    function test(indName IN VARCHAR2) return tableTest PIPELINED as
    begin
    pipe row (indName);
    pipe row ('teste2');
    return
    end;
    begin
    -- HERE I NEED SHOW ROWS RETURNED BY FUNCTION WAS DECLARED;
    -- Select * from TABLE(test('NAME'));
    end;

    You declare a pipelined table function by specifying the PIPELINED keyword. Pipelined functions can be defined at the schema level with CREATE FUNCTION or in a package. The PIPELINED keyword indicates that the function returns rows iteratively. The return type of the pipelined table function must be a supported collection type, such as a nested table or a varray. This collection type can be declared at the schema level or inside a package. Inside the function, you return individual elements of the collection type. The elements of the collection type must be supported SQL datatypes, such as NUMBER and VARCHAR2. PL/SQL datatypes, such as PLS_INTEGER and BOOLEAN, are not supported as collection elements in a pipelined function.
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

Maybe you are looking for

  • Edit bookmarks font size

    Safari 7 had the right size font for the edit bookmarks page, but Safari 8 uses several sizes larger font which throws the list of folder off the bottom of the page and moving individual links is tedious as you have to hold it to the top or bottom if

  • HT2311 itunes 10.6.3 installation error! please help!

    i downloaded itunes 10.6.3 from the apple website. when i run the .dmg file the installer starts and in the end it says "the installer encountered an error that caused the installation to fail.Contact the software manufacturer for assistance". i cant

  • Keyboard connection question

    I just got a yamaha MO8 keyboard, and i was wondering how i could play the sounds from the keyboard on to logic, i know how to use it MIDI, but thats what i am not looking for. If anyone can help me out i would appreciate that very much.....

  • Large Aggregates

    Hello Experts, We have recieved an early watch report from SAP which has highlighted large aggregates for certain infocubes. When I check the aggregates, I noticed that they have high utilization indicated by the +++ in the valuation column. As large

  • My iPod Classic shows link to support

    Hello, I have an iPod Classic 20G. When I turn it on, the apple appears and stays for a few seconds, then it displays an iPod on screen with the link to Apple.com/support/ipod. When I go there, I try to get help with a tech. It asks for my type of iP