CALL PROCEDURE IN SQL STATEMENT

Why we cant call a procedure inside SQL statement?

Hitesh Nirkhey wrote:
Hi Karthick_Arp
as you said
The procedure that is used inside a function cannot contain DDL or DML statements or COMMIT/ROLLBACK.
Said that it does not make much sence to use a procedure within a function.IT make sense if we DECLARE FUNCTION AS PRAGMA AUTONOMUS_TRANSACTION
then we can execute DDL or DML statements or COMMIT/ROLLBACK in that function.
Regards
HiteshBut why would you do that?

Similar Messages

  • JDBC - Pl/SQL-Procedure or SQL-Statement???

    Hi,
    we have got the following problem:
    Our program is entirely written in Java. It has to communicate with an ORACLE 8i database (Version 8.1.7). The big question is whether to call pl/sql-procedures which include the sql-statement (select/ insert/update) or to write the sql-statements in the Java-code directly.
    We messure the time in our test-database. The procedure took twice the time of the direct statement, althoug the sql-statement had to be parsed each time.
    What is the better way: pl/sql-procedure or sql-statements? On which conditions depend the choose?
    (For your information: our statements aren't difficult. In our testdatabase aren't much datasources.)
    Here is a snippet of our code:
    1. PL/SQL-Prozedure:
    CallableStatement cs = conn.prepareCall("begin dbrb_test_pkg.test(?,?,?); end;");
    cs.registerOutParameter(1, OracleTypes.CURSOR);
    cs.registerOutParameter(2, OracleTypes.CURSOR);
    cs.registerOutParameter(3, OracleTypes.CURSOR);
    cs.execute();
    ResultSet rs1 = ((OracleCallableStatement)cs).getCursor(1);
    ResultSet rs2 = ((OracleCallableStatement)cs).getCursor(2);
    ResultSet rs3 = ((OracleCallableStatement)cs).getCursor(3);
    2. SQL-Statements directly in Java-Code:
    String statement1b = "SELECT bva_id, bva_datva FROM bva";
    ResultSet rs1b = stmt.executeQuery(statement1b);
    String statement2b = "SELECT brb_id, brb_datein FROM brb";
    ResultSet rs2b = stmt.executeQuery(statement2b);
    String statement3b = "SELECT bper_id, bper_nz1 FROM bper";
    ResultSet rs3b = stmt.executeQuery(statement3b);
    Thanks a lot.
    Claudia and Nicole

    this is a case-to-case basis.
    it's ok to use the Statement/PreparedStatement if you're constructing your SQL or DML (insert/update/delete) statements. like when you're WHERE condition is dynamically created. this can be done also in PL/SQL (CallabeStatement) but passing of data is very tedious for you.
    the PL/SQL is much better to use if all your SQL or DML statements are fixed. besides, this is easier to maintain. when you need to change a statement, you don't need to check the statement in SQL prompt then make the necessary changes in your java codes, then compile the class. when you're using PLSQL, you just need to change and recompile the PL you made. then presto! it's done. as long as you don't change the parameters the PL receives and sends, it should perfectly work with your java code. =)

  • Why can't we call procedure in sql stmt

    Hi,
    Why can't we call procedure in sql stmt?

    Assuming (as Billy mentioned) that the question refers to SELECT statements (also assuming that "stmt" is short for "statement", nice time-saving abbreviation, thanks for that), you cannot use procedures because there is no concept of a procedure in an SQL query, and possibly in declarative languages in general (computer scientists may correct me here).
    How would it work? Everything in a SELECT list has to return something - it's the whole point of a SELECT list. Procedures by definition do not have a RETURN clause (yes you can RETURN to end processing, yes there are OUT parameters, but that is not the same thing). Perhaps you could post an example of the syntax you have in mind.

  • ALDSP 3.0 -- schema owner for stored procedure or SQL Statement

    Using ALDSP, I have a need to create a physical service based on a stored procedure or a SQL statement. I am wondering what will happen when I move to another deployment environment where the schema owner changes. In our QA and Prod environments, we have a different schema owner for all tables in the application (the DBAs believe this prevents unwanted updates to a prod environment). DSP elegantly supports this for normal table- and view-based physical services by mapping schemas through the DSP console after deployment. Will I get the same type of mapping capability for stored procedures and SQL statements? I noticed that I can add a SQL-based function to a physical service...is there a way to pass in the physical table name from that data service to the procedure or SQL statement?
    Thanks,
    Jeff

    Schema name substitution should work for stored procedures just like it does for tables. If it doesn't - report a bug.
    You don't get any help for sql-statement based data services - dsp doesn't parse the sql provided. One thing you could do is use the default schema (following the user of your connection pool), and not specify the schema in your sql-statement.

  • Calling Procedure from SQL Developer

    Could anyone tell me how to call a Procedure from a SQL Worksheet using SQL Developer?
    I can run by right clicking the Procedure in the Connections window, but want to call it using SQL commands.
    I can run it using EXECUTE procedurename in SQL Plus but I get an ORA-00900 - invalid SQL statement if I try this in a SQL Worksheet. If I try CALL procedurename, I get an ORA-06576 - not a valid procedure or function name.
    Am I doing something daft (I've been using Oracle for 3 days)?

    begin
    procedure(params);
    end;

  • Using Procedure in SQL statement

    Dear Sir,
    As you know, I can use any function in SQL statement. For example:
    SELECT systimestamp,
    Function_Name(variable1, variable2,...)
    FROM anytable;
    So the previous function could only retrieve one value -as functions concepts-. Anyhow, Can I, in someway, use Procedure that take multiple in parameters and return multiple out parameters in SQL statement.
    Thank you in advance.

    Sir,
    I got a way in order to use the benefit of procedure in function. It's trough your idea in using TYPE OBJECT as the following:
    ===================================================================
    create or replace type Missed_Txn_type AS OBJECT
    (Txn_Timestamp_obj timestamp,
    Txn_Type_Obj Number(12));
    ===================================================================
    Then I created function and used this type as returned value:
    FUNCTION Get_Shift_Missed_Txn_Obj(F_Date_In     Date,
                        F_Time_In Timestamp,
                        F_Employee_Id     number)
    RETURN Missed_Txn_type;
    The issue is: I want send the variables of the function through SELECT statement which they come from another table like:
    SELECT
    EMP.ID,
    sd.date_value,
    shf.Time_In,
    T.OBJ.Txn_Timestamp_obj,
    T.OBJ.Txn_Type_Obj
    FROM
    EMPLOYEE EMP,
    Stored_Date SD,
    Shifts shf,
    (select Get_Shift_Missed_Txn_Obj(sd.date_value,
    shf.time_in,
    EMP.Id) OBJ from dual) T
    WHERE
    [where clause]
    But the previous statement returned an error shows that it couldn't determine the (EMP.ID, shf.time_in, sd.date_value...)...
    And the same if I use it in the select list!
    So sir, there is any way in order to solve this issue?
    Thank you in advance.

  • Calling procedure PL/SQL from OCCI passing objects

    Hi all!
    I need a sample from a OCCI program that call a stored pl/sql procedure and pass an IN OUT parameter of type object.
    Thanks in advanced!

    I don't remember how after all these years, but I remember that I made a native Informix call in a special way. So it seems logical that you should be able to do the same for Oracle...
    Scott

  • Using store procedure within sql statement?

    I have the following sample tables:
    project id project_name
    ====== ===============
    1          project one
    2          project two
    3           project three
    employee_id     fname          lname
    =========== =============     =====
    100          amy          A
    200          better          B
    300          carrie          C
    project_id     employee_id
    ===========     ===========
    1          200
    2          300
    3          100
    there is a procedure getFullname(empployee_id) in place that combines the fname with lname to full name
    what i need to accomplish is the following.
    project is created by employee
    ==============================
    project one is created by better b
    project two is created by carrie C
    project three is created by amy A
    but the rule is: you have to call the procedure getFullName(employee_id) to accomplish the task above, and don't use the join tables to get the full employee name

    CREATE OR REPLACE FUNCTION YOUR_FUNCTION(i_nEmpId IN NUMBER)
    RETURN VARCHAR2 IS
    BEGIN
      RETURN 'Lastname ' || TO_CHAR(i_nEmpId) || ' Firstname';
    END;
    WITH PROJECTS AS (SELECT 1 PROJECT_id, 'project one' PROJECT_NAME FROM DUAL
                      UNION ALL
                      SELECT 2 PROJECT_id, 'project two' PROJECT_NAME FROM DUAL
                      UNION ALL
                      SELECT 3 PROJECT_id, 'project three' PROJECT_NAME FROM DUAL
      PROJ_TO_EMP AS (SELECT 1 PROJ_ID, 100 EMP_ID FROM DUAL
                      UNION ALL
                      SELECT 2 PROJ_ID, 200 EMP_ID FROM DUAL
                      UNION ALL
                      SELECT 3 PROJ_ID, 300 EMP_ID FROM DUAL
    SELECT PROJECT_ID,
           PROJECT_NAME,
           EMP_ID,
           YOUR_FUNCTION(EMP_ID),
           PROJECT_NAME || ' is created by ' || YOUR_FUNCTION(EMP_ID)
      FROM PROJECTS,
           PROJ_TO_EMP
    WHERE PROJECT_ID=PROJ_ID;

  • Calling a PL/SQL function in the SQL statement

    I have a PL/SQL function which i should call in a SQL statement.
    Let's say the function is func1(parameter1,parameter2),
    it should be called like this :- SELECT func1() FROM mytable ;
    Can any one help me out on this ?
    ---Thanx in advance

    you can call pl/sql functions from pl/sql using
    select fn1('param1','param2') from table;
    if you dont want to pass paramters, you have to specify default
    value while creating function like below
    create function fn1(p1 number default null,p2 varchar2 default
    null) return...
    now you can call using
    select fn1 from table;

  • Call sql statement from JComboBox component

    Hi there,
    I Have created a frame to populate two JComboBoxs, I'm populating the first one from a database using SQL, this datable is showing the category to below every report.
    anybody know how can I select from my first JComboBox a record a call a second SQL statement acutomatic, the idea is populate me second JCombox with data like my first one, remember the first one is a header

    With a JComboBox you have to be careful that you don't run a query when just the cursor is moved up or down the list. If you want the listener to fire just when enter is pressed or the mouse is clicked, then do this:
    //This stops events being fired when the cursor is used on the list
    comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);You should also attach an event listener like this one:
    comboBox.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                            executeSomeQuery(comboBox.getSelectedItem().toString());               }
              });Or something similar to above, have a play around with it and it should work how you want it to.
    Message was edited by:
    JStudent911

  • Executing Procedure in SQL SERVER and Storing the results in Oracle 10g

    Hello,
    I am trying execute SQL SERVER procedure from Oracle 10g and store the results in a oracle table. When I tried executing the procedure i am getting errors.
    I am using Oracle Heteroeneous Services.
    Steps I followed.
    1. Created ODBC DSN on Oracle Server connecting to SQL SERVER database.
    2. Created Listner entry and TNSNAMES entries.
    3. Created Database link and able to select the data from the SQL SERVER tables.
    Here is the code i tried to execute the procedure.
    BEGIN
    "META"."extract"@abc;
    END;
    "META"."extract"@abc;
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00201: identifier 'META.extract@ABC' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    Please help me.
    Thank You,
    Seshadri Thope

    Hi thopevs,
    Can you please tell me the right syntax of calling procedures(on sql server) from oracle?
    I am getting following error:
    SQL> execute "GetdateSys"@oratosql;
    begin "GetdateSys"@oratosql; end;
    ORA-06550: line 2, column 7:
    PLS-00201: identifier 'GetdateSys@ORATOSQL' must be declared
    ORA-06550: line 2, column 7:
    PL/SQL: Statement ignored
    SQL>
    Your help will be highly appreciated.
    Thanks & Regards,
    M.U.N.A

  • Sql statement for network version of JavaDB database

    Hi,
    Could somebody please tell is it a must to have double quote for field name inside the SQL statement for JavaDB
    I am developing the project using netbean 5.5.1 IDE
    integrating netwok version of JavaDB.
    example
    select "field1","field2" from table1
    instead of the simple sql like
    select field1,field2 from table1
    I find that simple select sql query could not work without having the double quotation eclosed for any of the fieldname called by the SQL statement.
    I am not sure is it only unique to netbeans IDE environment , in principle simple plain query should work , this is however not for netbeans IDE, wht is the reason behind?
    Thanks

    The Quotes around the fieldnames are normally only needed if the field is the same as a reserved word, or has a non-standard character in the field. Look at the JavaDB/Derby manual (specifically the one with the SQL reference) to find out what the reserved words and special characters are, then redefine your table.

  • Error when try to call a pl/sql procedure from the .xsql file

    I tried to call a pl/sql procedure like this:
    <?xml version="1.0"?>
    <page connection="omtest5" xmlns:xsql="urn:oracle-xsql">
    <xsql:include-owa>
    sampleowaxml.testone
    </xsql:include-owa>
    </page>
    but I got the following error message:
    <?xml version="1.0" ?>
    - <page>
    - <xsql-error action="xsql:include-owa">
    <statement>declare buf htp.htbuf_arr; param_names owa.vc_arr; param_values owa.vc_arr; rows integer := 32767; outclob CLOB;begin param_names(1) := 'HTTP_COOKIE'; param_values(1) := ''; param_names(2) := 'SERVER_NAME'; param_values(2) := 'mxfang-nt.us.oracle.com'; param_names(3) := 'SERVER_PORT'; param_values(3) := '80'; param_names(4) := 'SCRIPT_NAME'; param_values(4) := '/servlets/oracle.xml.xsql.XSQLServlet'; param_names(5) := 'PATH_INFO'; param_values(5) := '/xsql/test/myproject.xsql'; param_names(6) := 'HTTP_USER_AGENT'; param_values(6) := 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)'; owa.init_cgi_env(6,param_names,param_values); sampleowaxml.testone owa.get_page(buf,rows); dbms_lob.createtemporary(outclob,true,dbms_lob.session); for i in 1..rows loop dbms_lob.writeappend(outclob,length(buf(i)),buf(i)); end loop; ? := outclob; ? := DBMS_LOB.INSTR(outclob,CHR(10)&#0124; &#0124;CHR(10));end;</statement>
    <message>ORA-06550: line 3, column 3: PLS-00103: Encountered the symbol "OWA" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "OWA" to continue.</message>
    </xsql-error>
    - <xsql-error action="xsql:include-owa">
    <message />
    </xsql-error>
    </page>
    This error message is very similiar to the message that Shanthir posted on Jan, 21. I did run the dbmslob.sql, but it doesn't help. Anybody has ideas how to solve it?
    I used the PL/SQL web toolkit provided by OAS4.0.8.1. I believe oracle web agent is replaced by this toolkit.
    Thanks,
    Min
    null

    Hi,
    Glad that somebody else too got this problem. Well, as I had mentioned in my previous posting too, I think there are some procedures in the package, dbms_lob, like the writeappend, createtemporary etc.. which is not found in my dbms_lob.sql file, I am using 8.0.5, but I found these procedures in the 8i, I think it is becos of that.
    By the way if anybody got this solution and got any workaround, please help me too.
    I am still waiting for the solution to that.
    Shanthi

  • SQLEXEC not able to filter extract on sql statement or function call.

    hi all,
    i'm trying to do some basic extract filtering using a stored function and am not having much success.
    i started off using a procedure call but have been unsuccessful getting that working, i've simplified
    it to use a sql statement calling a function for a value to filter on, but cannot even get that to work.
    i've read through the documentation and i cannot figure out what is going wrong.
    any help would be much appreciated.
    thx,
    daniel
    function code is very simple, just trying to get something working.
    FUNCTION f_lookup_offer_id(v_offer_id IN offer.offer_id%TYPE)
    RETURN company.name%TYPE IS
    lv_company_name company.name%TYPE;
    BEGIN
    SELECT c.name
    INTO lv_company_name
    FROM orders a, offer b, company c
    WHERE a.offer_id = b.offer_id
    AND b.company_id = c.company_id
    AND a.order_id = v_order_id;
    RETURN lv_company_name;
    END f_lookup_offer_id ;
    Oracle GoldenGate Command Interpreter for Oracle
    Version 11.1.1.0.0 Build 078
    Solaris, sparc, 64bit (optimized), Oracle 10 on Jul 28 2010 13:26:39
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    EXTRACT EATUOP1
    INCLUDE ./dirprm/GGS_LOGIN.inc
    EXTTRAIL ./dirdat/up
    DISCARDFILE ./dirout/eatuop1.dsc, append , MEGABYTES 50
    DISCARDROLLOVER ON SUNDAY AT 06:00
    -- Database and DDL Options
    -- Added to avoid errors when setting unused columns
    DBOPTIONS ALLOWUNUSEDCOLUMN
    -- Get full row for deletes
    NOCOMPRESSDELETES
    -- Get updates before
    GETUPDATEBEFORES
    -- If commit SCN that is not greater than the highest SCN already processed error
    THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 15000 IOLATENCY 6000
    -- Retains original timestamp. Currently using GMT
    NOTCPSOURCETIMER
    --TABLE DEFS
    TABLE master.OFFER,
    SQLEXEC ( ID ck_offer,
    QUERY " select master.f_lookup_offer_id(:off_id) is_company from dual ",
    PARAMS (off_id = offer_id),
    BEFOREFILTER),
    FILTER (@GETVAL (ck_offer.is_company = "Google, Inc."));
    does not give any errors, but also does not capture any data, it's filtering everything out and trail files are empty, minus a header.
    thoughts or help?
    2012-04-04 22:17:36 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, eatuop1.prm: EXTRACT EATUOP1 started.
    2012-04-04 22:17:36 INFO OGG-01055 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery initialization completed for target file ./dirdat/up000022, at RBA 978.
    2012-04-04 22:17:36 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Output file ./dirdat/up is using format RELEASE 10.4/11.1.
    2012-04-04 22:17:36 INFO OGG-01026 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Rolling over remote file ./dirdat/up000022.
    2012-04-04 22:17:36 INFO OGG-01053 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for target file ./dirdat/up000023, at RBA 978.
    2012-04-04 22:17:36 INFO OGG-01057 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for all targets.
    2012-04-04 22:17:36 INFO OGG-01517 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Position of first record processed Sequence 13469, RBA 21894160, SCN 1789.722275534, Apr 4, 2012 10:12:40 PM.
    -rw-rw-rw- 1 svc_ggs 502 978 Apr 4 22:17 up000023

    got it working, this seems to be about as simple as i could formulate it. thanks for pointing me in the right direction.
    TABLE GGS_TEST_EXT, &
    SQLEXEC ( ID co_count, &
    QUERY " select f_lookup_company_name(:P1) x from dual ", &
    PARAMS ( P1 = company_id), BEFOREFILTER), &
    FILTER ( @GETVAL (co_count.x = 0) );
    then i have a function that returns 1 or 0, depending on the company id passed in.
    thx,
    daniel

  • How to include 3 sql statements in a single procedure

    I have 3 SQL statements to create 3 tables:
    Table1:To get all the data from an ORIGIN table that have an expiration_dates between 02/01/2006 and 04/30/2006. This has all the customer data (customer_id, company, etc…)
    Table 2:Secondly I am getting all the customer_ids for February into another table called table2
    Table 3: Thirdly I am joining table 1 and table 2 on customer_id to get all the entries for the February customers those expire in February, March and April.
    Now I want to include all these in a procedure. Can I put all these together in 1 procedure so that I can run all these at once and have the results?
    Please throw some light on this.
    Thanks,
    Ac

    I hope this code will help you a little bit
    [email protected]> create table orgin(customer_id int, company varchar2(20), expiration_date date)
    2 /
    Table created.
    Elapsed: 00:00:01.06
    [email protected]> create table table2 (customer_id int, expiration_date date)
    2 /
    Table created.
    Elapsed: 00:00:00.01
    [email protected]> create table customers_table(customer_id int, cust_date date)
    2 /
    Table created.
    Elapsed: 00:00:00.01
    [email protected]> create table table3(customer_id int)
    2 /
    Table created.
    Elapsed: 00:00:00.01
    [email protected]> create table table1(customer_id int, company varchar2(20), expiration_date date)
    2 /
    Table created.
    create or replace procedure customers is
    begin
    -- table1
    insert into table1 select customer_id, company, expiration_date
    from orgin
    where expiration_date between to_date('01-02-2006','dd-mm-yyyy')
    and to_date('30-04-2006','dd-mm-yyyy');
    -- table2
    insert into table2 select customer_id, cust_date from customers_table
    where cust_date between to_date('01-02-2006','dd-mm-yyyy')
    and to_date('28-02-2006','dd-mm-yyyy');
    -- table3
    insert into table3 select a.customer_id from table1 a, table2 b
    where a.customer_id = b.customer_id;
    end;
    Best Regards
    Krystian Zieja / mob

Maybe you are looking for

  • Using a Comparable Class with Treeset, creating counter in comparable clas

    http://rafb.net/paste/results/jibQzk63.html - comparable http://rafb.net/paste/results/Noahue63.html - loading http://rafb.net/paste/results/re1Swn60.html - contents of .txt file * sorry the paste is weird lol. Trying to List word count in alphabetic

  • Upgrade ERECRUIT to EHP in NW 7.0

    Hi, We have NW 7.0 with ERECRUIT add-on 603 and we want to upgrade to ERECRUIT 604 SP4 : Q1 : Does EHP1 for NW 7.0 required by ERECRUIT 604 ? Q2 : If the answer of Q1 is yes then we will user SAPEhpi to install EHP1 but how we can upgrade the  ERECRU

  • How do i send a gift card to more than one person

    HOW DO I SEND MORE THAN ONE GIFT CARD AT A TIME PLZ HELP IM DYING

  • Configuration Management of Portlets: How do you do it?

    Hi: What is the best way for a group of developers to keep "portlet" code under CM? Portlets can be so many thing, from so many sources, etc. Is an entire structure, including WSDL, source (JSPs, Stored Procedure code, XML transformations, etc.) all

  • Trashing prefs on OS 10.7

    On my new OS, I cannot find a com.apple.finalcutpro.plist. Nor can I find Final Cut Pro obj cache in Preferences. This is the first time i've had to trash prefs on this new iMac and the files aren't  even in the preferences folder . Deadline looming