How to do a select on the results of a stored procedure?

Hello

I am new to Oracle. I work with SQL Developer.

I'm doing a simple select on the results of a stored procedure call. I don't know how to do it. Here's what I have so far:

declare
type ref_cursor is ref cursor;
results ref_cursor;
Start
MyStoredProcedure (123 results);
Select * from results;
end;
/

but he said to me:

Error from the 1 in the command line:
declare
type ref_cursor is ref cursor;
results ref_cursor;
Start
GET_TAX_TYPE_BY_TAX_ENTITY_KEY (60670100000000, results);
Select * from results;
end;
Error report:
ORA-06550: line 6, column 15:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 6, column 1:
PL/SQL: SQL statement ignored
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error.
* Action:

Obviously, select * results; is not the right way to do it. But what is?

Thanks for any advice forthcoming.

If a SQL cursor is built by a reporting system, a Java application, a c# program, or a PL/SQL call - the database doesn't care, because he doesn't know the difference. A Select SQL cursor created in PL/SQL through the ref cursor interface, won't be faster than the same SQL select in Eclipse. If the SQL source code is the same, the same cursor SQL program will be used by both.

What give you BIRT is the flexibility of the use of code Server (PL/SQL) to create the slider - this code doing business and technical decisions on how to design side than SQL, Select. Which is a good thing because it summarized the data model and the complexity BIRT server technique.

So my choice would be to use the procedural interface and return to the reporting system for the rendering of the ref Cursor.

The question of a slider running via the slider (selection of a cursor), is questionable. Yes, there are a set of specifications that allows to do this kind of thing. But it must be very firmly justified and careful design because it really is an exception. I personally (blame my DBA) would need a justification because it is much more of an exception. I have never seen it put in place in production in more than a decade of DBA'ing, despite the developers try to use such a hack - as it has always been much more powerful and the deployment of alternatives.

The concept for robust and efficient code for Oracle is: Maximise SQL. Minimize the PL/SQL (or Java / c# / etc.).

That means when it comes to database power, write an SQL program to do. Stop thinking of SQL as a language of data recovery a single simplistic statement. Think of it as a programming language. Extremely complex problems can be resolved with a single SQL, which requires easy code 100 + lines of PL/SQL, Java, or c#. Write SQL programs. Not SQL one-liners for a grinding program PL/SQL or Java data.

Why then PL/SQL? It is the best language to manage the creation of SQL, dealing with the process flow, conditional processing, and so on of exception handling. It is less than SQL (such as Java and c#) in the treatment of the data.

Tags: Database

Similar Questions

  • Passing the params in mysql stored procedure

    Makes no mistake, but when I hard code the values in the stored procedure, I get results, I leave as params - if not.
    Something must be a miss with how I said, but I can't understand that:

    Can anyone help? details below:

    : the stored procedure:

    Create procedure keyword_getBySource (in sourceRecordName varchar (20), in sourceRecordId varchar (50))
    Start
    Select
    tblkeyword.*
    Of
    tblkeyword,
    tblrecordlink
    where
    tblrecordlink.sourceRecordName = @sourceRecordName
    and
    tblrecordlink.sourceRecordId = @sourceRecordId
    and
    tblrecordlink.linkRecordName = 'keyword'
    and
    tblkeyword.keywordId = tblrecordlink.linkRecordId
    ;
    end

    : cfm:

    "< cfstoredproc procedure ="keyword_getBySource"datasource =" "username =" "password =" ">
    < cfprocparam type = 'in' cfsqltype = "CF_SQL_VARCHAR" dbvarname = "sourceRecordName" value = "Log" / >
    < cfprocparam type = 'in' cfsqltype = "CF_SQL_VARCHAR" dbvarname = "sourceRecordId" value = "0d8a6d3e-cf1e - 19(d) 5-2b9fc8ee1de01ad0" / >
    < name cfprocresult = resultset "getBySource" = "1" / >
    < / cfstoredproc >

    @... seems mysql does not use these to designate the params in a stored procedure

    Take them out - it works.

  • Process the Message on a stored procedure

    Hi all

    How do I call and diplay APEX the message of a stored procedure?

    Example of form on stored procedre.

    Thank you

    Hello

    What do you mean by 'the message '? If you are referring to the 'success Message', then you can use the variable apex.

    APEX_APPLICATION.G_PRINT_SUCCESS_MESSAGE := 'This is success message for page process';
    

    Kind regards
    Hari

  • How can I post pictures to the resulting internet forum photo album?

    How can I post pictures to a photo album on an internet forum?

    Use Safari or any web browser that supports the media browser and upload them (in the window download selection to the bottom of the left pane under media source == > photos == > Photos)

    LN

  • assign the value to a selection of the result of a query control

    I want to assign a value to my controls with the result of the query.

    It works for CFINPUT TEXT, but it does not work to SELECT

    I want to know are there any way tp affect my drop-down list value based on the result of questy.

    I have CFSTOREPROC as follows:

    < cfstoredproc procedure = "PSP" >

    < cfprocparam value = '#form. "IDNumber #" CFSQLTYPE = "cf_sql_integer" >

    < name cfprocresult = resultset "spResult" = "1" >

    < / cfstoredproc >

    < type CFINPUT = 'text' id = "txtIDNumber" value = "" #spResult.IDNumber # "/ >"

    I am able to name a TEXT of ENTRY CF as above the code value,

    < select id = "lstNumber" value = "#spResult.lstNumber #" > < / select >

    but it does not affect the value of my result of the query to SELECT entry.

    Is it possible to assign a value to the query result SELECTION control?

    I tried to use JavaScript that works if I pass a number, but it does not work if I pass a query result,

    Your help is very appreciated,

    Kind regards

    Iccsi,

    @Iccsi,

    My bad!  Yes, you will either need to the CFOUTPUT tag (that you commented out in your code) but without specifying a query or change the CFLOOP query CFOUTPUT = "Notes".  If one of these should work:

    OR

    -Carl V.

  • How to add additional data in the result set of cfquerry?

    Hi all

    I'm new to cold fusion it please help me

    I'm using the tag cfquery for running a select query and get the name of the system and the system is the...

    But I want an id system and additional system name to add to the result of this query with to change the database ...

    Please anyone suggest me... IT is URGENT

    Thanks in advance
    Sainaba

    UH... - What is a line or two columns?

    Whatever it is, there are functions to achieve is: queryAddRow() or queryAddColumn().  Take a look @ query functions:

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/functions-pt0_16.html#1099653

    --

    Adam

  • How to get zone selected by the user in the Managed bean code

    Hello

    In our project, we use af:inputDateto to get details about the information of Date, time, and time zone.

    < af:inputDate label = "#{bundle." LABEL_1}.
    autoSubmit = 'true '.
    value = "#{pageFlowScope.attributeValuesBean.DateTime} '"
    valueChangeListener = "#{pageFlowScope.resourceCreateEditBean.pageValueChangedListener} '"
    ID = "id3" >
    < af:convertDateTime type = "both" timeStyle = timeZone = "#{"long"pageFlowScope.resourceCreateEditBean.preferredTimeZone}" / > "
    < / af:inputDate >

    the value attribute of date. MinValue is mapped with pageFlowScope.attributeValuesBean.dateTime which is a java.util.Date.

    for specific details, I used following code

    SimpleDateFormat sdf = new SimpleDateFormat ("dd MMM yyyy hh: mm: z");
    String s = sdf.format (date);

    which returns the date in the format "dd MMM yyyy hh: mm: z". However, this API will always return timezone of server, and in accordance with our project we need the details of the user selected time zone.

    is it possible to get the time zone selected by the user on the dateTime picker?

    Ajay,

    When LOV TimeZone is active on the date picker, it is not possible to retrieve the time zone selected by the user. There is an enhancement request filed for this feature.

    Since this is a known issue, there is a way to accomplish what you want:

    (1) the date picker does the conversion of the local time zone to UTC (GMT) time and provides a Java Date object.
    In order to bypass this conversion, you can use one of the techniques is:

    It's basically asking for the date picker to convert time UTC time UTC (no conversion) :-)

    (2) separate the zone LOV the date picker. You can use the function af:getCommonTimeZoneSelectItems() for this purpose.

  • How to run SQL and export the results to Excel

    My task is to run a custom SQL script and create an Excel file through SQL Developer running from the command line (called by a scheduled script). Is this possible using SQL Developer?

    First, the thing I will try is to run a report user-defined in SQL Developer and save the results in an Excel file. Only 16000 result lines, but took 10 minutes to do the export and still cannot complete. Is there another way to do it?

    Thank you very much.

    Can't be done, but this is requested already exchanging SQL Developer, you can vote here and add weight to the possible future implementation.

    Kind regards
    K.

  • How to extract data from the APEX report with stored procedure?

    Hi all

    I am doing a report at the APEX. the user selects two dates and click on the GO button - I have a stored procedure linked to this region of outcome for the stored procedure is called.

    my stored procedure does the following-

    using dates specified (IN) I do question and put data in a table (this painting was created only for this report).

    I want to show all the data that I entered in the table on my APEX report the same procedure call. can I use Ref cursor return? How to do this?

    Currently, I use another button in the APEX that basically retrieves all the data from table. Basically, the user clicks a button to generate the report and then another button for the report. which is not desirable at all :(


    I m using APEX 3.1.2.00.02 and Oracle 10 database.

    pls let me know if you need more clarification of the problem. Thanks in advance.

    Kind regards

    Probashi

    Published by: porobashi on May 19, 2009 14:53

    APEX to base a report out of a function that returns the sql code... Your current code goes against a Ref cursor returns the values...

    See this thread regarding taking a ref cursor and wrapping it in a function to channel out as a 'table' (use a cast to cast tabular function vale)...

    (VERY COOL STUFF HERE!)

    Re: Tyring to dynamically create the SQL statement for a calendar of SQL

    Thank you

    Tony Miller
    Webster, TX

  • How to create the cursor in a stored procedure

    How to create the slider in the stored procedure. I want a simple example
    procedure - cursor - open-fetch - insert - last slider farm
    any idea or examples... Please help friends

    Thanks in advance

    Hello

    Search for explicit cursors in this link

    http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/static.htm#insertedID2

    Kind regards
    Prazy

  • How to take the user through a stored procedure input...

    Salvation has posted this earlier, but I'm sorry I think kept an incorrect object name...
    Here's my problem...

    First user will pass a parameter to insert or remove. Aftert that depeding on the insert or delete, we should as a user to spend still more values.
    I did the code below, but he was throwing an error.

    I'm not sure we can use '&' to enter the stored values Procedure.Bcause indidvidual States working with '& '.
    but not in the stored procedure.
    Individual Statement:
    insert into emp
          values      ( & emp_id  ,&emp_name ,&Manager_id,sysdate );
    --- Procedure :::::
    create or replace procedure emp_id ( p_test_input in varchar2 )
    as
      emp_id number;
    emp_name varchar2(20);
    manager_id
    begin
       if ( upper ( p_test_input ) = 'I' )
       then
          insert into emp
          values      ( & emp_id  ,&emp_name ,&Manager_id,sysdate );
       elsif ( upper ( p_test_input ) = 'D' )
       then
          delete from emp
          where       emp_id  = &emp_id;
       else
          dbms_output.put_line
             ( 'Please input ''A'' for ADD or ''D'' Delete  EMPLOYEE'
             );
       end if;
    end;

    Create a package and it contains an overloaded procedure, something like...

    CREATE OR REPLACE PACKAGE BODY
      emp_mgr
    AS
    PROCEDURE emp_update( in_emp_id   NUMBER,
                          in_emp_name VARCHAR2,
                               in_mgr_id   NUMBER )
    IS
    BEGIN
      INSERT
        INTO emp (emp_id, emp_name, manager_id )
      VALUES in_emp_id, in_emp_name, in_mgr_id;
    END emp_update;
    
    PROCEDURE emp_update (in_emp_id NUMBER )
    IS
    BEGIN
      DELETE
        FROM emp
       WHERE emp_id = in_emp_id;
    END emp_update;
    END emp_mgr;
    

    Now, if you call it with only the emp_id, it will remove. If you call it with emp_Id, emp_name and mgr_id, it will update.

  • Get the EXIT and the RETURN of a stored procedure parameters

    I have a stored procedure (SQL Server 2008 R2 MS) as in the following example.

    Thanks to the connectivity of database I get OUTPUT parameters, but I can't get the game DATA RECORDS and RETURN value.

    Someone knows how to do this?

    CREATE PROCEDURE [dbo]. [TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR (20), @STATUS INT OUTPUT, OUTPUT OF NVARCHAR (500) OF @ERRO)

    AS

    BEGIN
    DECLARE THE TABLE @TABLE (CODE INT, DESCRIPTION VARCHAR (30))

    INSERT VALUES INTO @TABLE (51, 'A')
    INSERT VALUES INTO @TABLE (52, 'B')

    INSERT VALUES INTO @TABLE (53, 'C')

    SELECT * FROM @TABLE

    SET @STATUS = 1

    SET @ERRO = "Nenhum erro!

    RETURN 0

    END

    I finally found what was wrong... He had a line in the stored procedure only aditional. It should be like this:

    CREATE PROCEDURE [dbo]. [TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR (20), @STATUS INT OUTPUT, OUTPUT OF NVARCHAR (500) OF @ERRO)

    AS

    BEGIN
    SET NOCOUNT ON;                                                                                               -NEW LINE!

    DECLARE THE TABLE @TABLE (CODE INT, DESCRIPTION VARCHAR (30))

    INSERT VALUES INTO @TABLE (51, 'A')
    INSERT VALUES INTO @TABLE (52, 'B')

    INSERT VALUES INTO @TABLE (53, 'C')

    SELECT * FROM @TABLE

    SET @STATUS = 1

    SET @ERRO = "Nenhum erro!

    RETURN 0

    END

  • How to pass an array as a parameter to a stored procedure

    Hi all
    I want to pass the name of a table as a parameter in a stored procedure, which will be used for cursors, etc..
    But when I pass the parameter and I compile the S.P. he gives me error (error: table exist not...)

    Any help?

    Thanks in advance, Marco

    Cannot open a cursor explicit when it comes to the dynamic table names or parameters. This is because the explicit and implicit cursors seek real table names since they are static.
    Here your name of the table is dynamic, so u need to use dynamic that is ref cursor to and not static cursor.

    I made the correction in the code below. Run it and check the result!

    CREATE OR REPLACE PROCEDURE "P_1" ( TAB1 VARCHAR2)
    AS
    field1 CHAR(5);
    field2 CHAR(5);
    
    c1 sys_refcursor;
    
    begin
    
    l_str := 'select a,b,c from '||tab1||' INNER JOIN tab2 ON a = .......';
    open c1 from l_str;
    
    /*OPEN C1;
    CURSOR C1
    IS
    SELECT a, b , c
    FROM TAB1
    INNER JOIN
    tab2
    ON a = .......
    OPEN C1;*/
    
    LOOP
    FETCH C1
    INTO ..... 
    
    EXIT WHEN C1%NOTFOUND;
    .....
    END;
    END LOOP;
    
    CLOSE C1;
    
    EXCEPTION
    WHEN OTHERS
    .....
    END;
    
  • The execution of a stored procedure from inside the cursor for loop?

    I posted this in the SQL Developer forum, but I tried in SQLPlus and get the same error, so I think it's an encoding issue.
    I have a piece of code that I'm trying to write that will only be executed once. The goal: we have three tables relating to the pieces of information. Each table has a column that stores the number of site that belongs to the part. We want to copy the parts of a site to about 130 sites which don't have any info on parts. The number of site is stored in another table. So I created three stored procedures, one for each of the three tables that we, who take 2 inputs: a source and destination site. Procedure names are: ptfile_copy_fac, ptxref_copy_fac and ptvndrs_copy_fac.

    The problem I have is that I can run the procedures in a separate worksheet in SQL Developer, but when they are integrated in this cursor for loop, I get the following message from SQL Developer:

    ORA-06550: line 23, column 11:
    PLS-00103: encountered the symbol "PTFILE_COPY_FAC" during the expected in the following way:
    := . (@ %; immediate)
    The symbol ': = ' was replaced by 'PTFILE_COPY_FAC' continue.

    He repeated this for each of the three methods. I have attached the code I am trying to run below. He expects an assignment operator, but I have no idea why.

    If there is a better way to do this, by all means let me know. I'm a SQL Server guy, I'm not sure how to do what I do using PL\SQL.

    / * Declares the variables source_fac and dest_fac.
    The source_fac is the installation that we copy parts.
    The dest_fac is the installation we copy parts to.* /

    DECLARE
    source_fac facility.facility_num%type;
    INSTALLATION OF DEST_FAC. TYPE % FACILITY_NUM;

    / * Declare cursor to use loop for.
    Slider load number installation and the status of the installation.
    Is not installation of 1 or 2, since these will be
    the main source of facilities.*.

    CURSOR fac_cursor
    IS
    SELECT
    facility_num,
    div_state
    Of
    installation
    WHERE
    facility_num NOT IN (1,2);
    BEGIN
    FOR fac_row IN fac_cursor
    LOOP

    / * Test for the State of the installation. If a Canadian State, the source_fac value 2.
    Otherwise, the value source_fac 1.* installation.

    IF fac_row.div_state IN ("AB", "BC", "Mo", "NB", "NL", "NT", "NS", "NAKED", "WE", "PE",
    "QC", "SK", "YT")
    THEN
    source_fac: = 2;
    ON THE OTHER
    source_fac: = 1;
    END IF;

    / * Sets the installation of destination to the facility_num from the cursor * /.

    DEST_FAC: = FAC_ROW. FACILITY_NUM;

    / * Execute the three procedures, past of the source and dest AEC variable * /.

    run ptfile_copy_fac (source_fac, dest_fac);
    run ptxref_copy_fac (source_fac, dest_fac);
    run ptvndrs_copy_fac (source_fac, dest_fac);

    END LOOP;

    END;

    Published by: SunDevilKid on March 3, 2010 15:31
    Update the comments you make more sense of the code.

    EXECUTE is a SQLPlus command, change your code to

    dest_fac := fac_row.facility_num;
    ptfile_copy_fac(source_fac, dest_fac);
    ptxref_copy_fac(source_fac, dest_fac);
    ptvndrs_copy_fac(source_fac, dest_fac);
    END LOOP;
    

    Max
    http://oracleitalia.WordPress.com

  • The JNI in Java, stored procedure call

    Dear,
    I want to know how to call stored procedure JNI Java. How to configure my java.library.path in Oracle to get a specific directlry containing DLLs file inorder to System.loadLibrary ("< dll_file_name >");

    Not sure if I'm on the right track, but it seems that Oracle does not support JNI.

    http://download.Oracle.com/docs/CD/B19306_01/Java.102/b14187/chthree.htm#CACFCDJF


    Oracle database does not support the use of JNI in Java applications. If you use JNI, then your application is not 100% pure Java and native methods need porting between platforms. Native methods can result in a server crash, violating the security and corrupted data.

Maybe you are looking for

  • Background service missing to install updates

    Please I need someone from Mozilla to contact me about this. On tools, then Options tab, under view update history, use A background Service to install updates, then now that I can't check this to do not allow installation service updates. I've just

  • iPod started to hum and does not light

    I used a magnetic to ventous for my iPod and it stopped working and started the buzz, now it's just to show message of support from apple

  • Satellite P - new driver AMD (ATi) for Firefox

    Would it not be possible to persuade Toshiba to publish an update for the graphics driver before Firefox 4.0 is released this month? For the average user with an older driver that October 2010 hardware acceleration is not available.

  • c ++ array of unsigned char dll

    Hi TestStand users, maybe someone already had this problem and can help me ;-) I'm trying to get an unsigned char out of my dll table... my function looks like this: typedef unsigned char _U_BYTE;    / * 8-bit unsigned integer data type * /. typedef

  • attempt to build for phones

    ... but I get: [INFO] Compilation of application BlackBerry WebWorkscom.palm.novacom.NovaDeviceInfo: error! : invalid constant pool entry. in Interesting, because I use BlackBerry packaging tools, and I the webOS sandbox full of her tools. Any though