How to SELECT * FROM varchar2 variable

Hi there!
I want to create a SELECT statement inside a FOR LOOP. With each loop iteration, this SELECT shall get data from a different table:
FOR R_CURSOR IN C_CURSOR LOOP
V_FROM_CLAUSE := R_CURSOR.TABLE;
SELECT *
INTO V_RESULT
FROM V_FROM_CLAUSE:
Obviously, this doesn't work (it might be possible that a table/view has exactly the name as the variable). But is there any possibility to create a statement like this? Please help me out :-)
Regards,
Thomas

you need dynamic sql:
EXECUTE IMMEDIATE
'SELECT * INTO V_RESULT FROM ' || V_FROM_CLAUSE

Similar Messages

  • How to Select from Oracle 8i database and insert into Sql Server 2005 datab

    Hi how to Select from Oracle 8i and insert into Sql Server 2005.
    Source db as Oracle 8i
    Target db as Sql Server 2005.
    I need to select one table data from Oracle 8i & insert into Sql Server 2005
    Thanks

    Thanks Khan..
    Is there is any query (OPENQUERY) available for that?
    Regards..

  • How to select from list of values?

    Dear All,
    I am using XML publisher for word, where I need to select a value from a list of values, for example I have hotel code like TTAG,TOBBR,TTAG,TOTM now I need
    to select hotel code and the corrosponding data should be display on word after
    running the RTF. Tell me, how can I achive the same?
    hare krishna
    Alok

    Thanks prety much,I am using XML to upload data from there into RTF templete. I've already insert table through load data option, but my problem is, how could I select a value from a list of values and based on that value selected from the list, it should displaydata corrosping to it. For example, I have few codes like TTAG, AMAG, TOTOM and if I select TOTM, it should display the complete address of that hotel named TOTM. If above given scenario is not at all possible, then Is there any alternate method to achieve this?
    hare krishna
    Alok

  • How to select from a stored procedure?

    Lets say I have a simple stored procedures
    Create Procedure stp_test
    As
    Begin
     Select * from tbl1
    End
    Go
    I would like to be able to do this in SSMS (actually, I want to do this from ADODB)
    Select top 10 * from ...stp_test... Order By rowID
    It looks like I want to use OpenQuery on the stored Procedure, but I have not been able to do it correctly.  How can I query my stored procedure?
    Rich P

    It looks like I want to use OpenQuery on the stored Procedure, but I have not been able to do it correctly.  How can I query my stored procedure?
    If you want to use the OPENQUERY method , use the following.. follow this link...
    http://stackoverflow.com/questions/209383/select-columns-from-result-set-of-stored-procedure
    Please mark as answer, if this has helped you solve the issue.
    Good Luck :) visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • How to select from multiple addresses of account in IC Web Client

    Hi all,
    We are implementing a B2C scenario for IC Web Client. We have customers with multiple addresses. However, when we search the acount, only standard address comes to screen.  We want to be able select the related address, and then confirm the acount with that address.
    Is there any way to customize the Web Client in order to be able to select from multiple addresses of the acount?
    Thanks in advance.
    Edited by: Danisman Danisman on Aug 31, 2010 2:52 PM

    Thanks for the answer. Yes, we are using 7.0 but in the account identification screen, there is no personalize button ( I assume you are suggesting adding an addres block by using that button, right?).
    We checked the necessary customizing : there is an entry for fucntional profile PERSONALIZATION : ALL_ENABLED.
    Should we do something else to show the button?
    Thanks again.

  • Open sys_refcursor for select from table variable?

    Hi,
    I've got a challenge for you! :-)
    I've got a procedure that has a lot of logic to determine what data should be loaded into a table variable. Because of various application constraints, i can not create a global temporary table. Instead, i'd like to create a table variable and populate it with stuff as i go through the procedure.
    The end result of the procedure is that i must be able to pass the results back as a sys_refcursor. This is a requirement that is beyond my control as well.
    Is there a way to make this sort of procedure work?
    Create Or Replace Procedure Xtst
    Mu_Cur In Out Sys_Refcursor
    Is
    Type Xdmlrectype Is Record (Col1 Varchar2(66));
    Type Xdmltype Is Table Of Xdmlrectype;
    Rtn Xdmltype;
    Begin
    Select Internal_Id Bulk Collect Into Rtn From Zc_State;
    open mu_cur for select col1 from table(rtn);
    end;
    11/42 PLS-00642: local collection types not allowed in SQL statements
    11/36 PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    11/19 PL/SQL: SQL Statement ignored
    Show Errors;

    Not anything i'd want to personally implement.
    But for educational purposes only of course....
    create table this_will_be_gross
       column1 number,
       column2 varchar2(30)
    insert into this_will_be_gross values (1, 'begin the ugliness');
    insert into this_will_be_gross values (2, 'end the ugliness');
    variable x refcursor;
    ME_XE?
    declare
       Rtn sys.ODCIVARCHAR2LIST;
    BEGIN
       SELECT
          column1 || '-' || column2 Bulk Collect
       INTO
          Rtn
       FROM
          this_will_be_gross;
       OPEN :x FOR
       SELECT 
          regexp_substr (column_value, '[^-]+', 1, 1) as column1,
          regexp_substr (column_value, '[^-]+', 1, 2) as column2      
       FROM TABLE(CAST(rtn AS sys.ODCIVARCHAR2LIST));
    end;
    17  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.09
    ME_XE?
    ME_XE?print :x
    COLUMN1                        COLUMN2
    1                              begin the ugliness
    2                              end the ugliness
    2 rows selected.
    Elapsed: 00:00:00.11In the above example i 'knew' that a hypen was a safe character to use to break up my data elements (as it would not be found anywhere in the data itself).
    I would strongly encourage you not to implement something like this. I realize it's tempting when you are working in strict environments where it can take a serious battle to get structures like temporary tables or SQL Types created, but that's really the proper approach to be taking.

  • How to select from multiple output tables in the SAP Data Source

    Hi,
    We're using the SAP Data Source to display SAP data in our portal from the Bapi: BAPI_INFORECORD_GETLIST. When defining the Bapi Meta Data we can select data from one of the two output tables (INFORECORD_GENERAL and INFORECORD_PURCHORG). But we want to select data from both tables (some columns we want to show are in INFORECORD_GENERAL and some are in INFORECORD_PURCHORG) .
    How can we do this ?
    With regards,
    Ramon van der Weiden

    You can query multiple TimesTen databases, but your original question was about joining tables from two databases, which is not supported.
    Using Cache Connect to Oracle to query an Oracle database is not distributed. It's still one single Oracle database you are querying. You cannot join a table in the TimesTen database with a table in the Oracle database, this is not allowed.
    If you are willing to share your business requiremens, we can take a look and see what solution might work for you. Would you like to discuss this offline?
    Susan

  • How to select from drop-down menu connected to SQL database and then autofill?

    Hello,
    I am in the process of creating a series of forms and I need some help if working out how to do the following.
    I have already set up a data connection to an SQL database, and I have three fields connected: Job Number, Job Name and Customer Name.
    What I want to do is have it so that the Job Number is a dropdown box, so they can select the number, and then the other two fields, Job Name and Customer Name, are autofilled to the information corresponding to the Job Number.
    Is anyone able to help me do this please??
    Thank you!!

    The 101 of database connections from LiveCycle Designer can be found in Stefan Camerons blog.
    This is the right place to start.
    http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
    http://forms.stefcameron.com/2006/12/18/databases-inserting-updating-and-deleting-records/
    http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records/
    http://forms.stefcameron.com/2006/10/12/displaying-all-records-from-an-odbc-data-connectio n/

  • How to select from multiple tables which reside on different data stores ?

    Suppose I have two data stores in one TimesTen instance:
    1) Datastore A:
    table1
    2) Datastore B:
    table2
    I want to make a query like this:
    select ... from table1, table2 where table1.colA = table2.colB
    Can I ? If not, is there a workaround ?
    BTW, because of business, we have to use two or more different datastores, so we can not put table1/table2 in the same datastore.
    Thanks very much.

    You can query multiple TimesTen databases, but your original question was about joining tables from two databases, which is not supported.
    Using Cache Connect to Oracle to query an Oracle database is not distributed. It's still one single Oracle database you are querying. You cannot join a table in the TimesTen database with a table in the Oracle database, this is not allowed.
    If you are willing to share your business requiremens, we can take a look and see what solution might work for you. Would you like to discuss this offline?
    Susan

  • How to select from 3 Ip network cameras

    Hi, I have previously used flash media live encoder to encode live streaming in flv and upload it to a web space provided from one or more analog cameras selecting manually at the input of a capture video card. Now, I wish to not stop the encoding select between 3 video streams input from three network cameras. Is it possible to have three windows with the 3 videos and send from a choice of three video streams without stopping the encoding to provide a live stream? Hopefully, which product to use?

    Hi,
    Unfortunately, FMLE does not currently have the dynamic switching feature outlined above.
    Thanks,
    Shiven

  • Select from 2 tables and insert same data into 2 other tables(BPEL Process)

    Hi All,
    Please suggest me how to select from 2 tables and insert the same data into 2 tables. I am successful in selecting data from 2 tables, but i am not able to insert the same data into 2 other tables. There is foreign key constraint between 2 tables.
    Thanks in Advance,
    MAH

    I have created DB Adapter for selecting from 2 tables and also DB adapter for insert and i have created parent child relationship between 2 tables.
    I am getting this error
    <Faulthttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>env:Server</faultcode>
    <faultstring>com.oracle.bpel.client.delivery.ReceiveTimeOutException: Waiting for response has timed out. The conversation id is 6f3fe20c1b031057:-6cc7dfb5:11b8bf5fbe1:-7fa4. Please check the process instance for detail.</faultstring>
    </Fault>

  • Selection from recordgroup

    i have recordgroup and i want to select from this object
    i want to know how to select from it
    and how i can to update the values int his record group

    Hello,
    Look at the following built-ins in the Forms Builder online help (ctrl+H)
    Get_Group_Row_Count()
    Get_Group_Record_Number()
    Get_Group_Char_Cell()
    Get_Group_Date_Cell()
    Get_Group_Number_Cell()
    Francois

  • How to select two variables from recordset

    Parse error: parse error in
    C:\wamp\www\dotweb\access\agreement_handbook.php on line 72
    I get the above error when I try to run the above page. I
    don't know how to select one variable which is the compid that I
    get from the url and a specific name from another column called
    documentname. I know that this is a very simple thing and I could
    do it just fine with ASP pages, but this is my first time with PHP.
    Please help!!!

    On Tue, 17 Feb 2009 20:56:30 +0000 (UTC), "kmlohr"
    <[email protected]> wrote:
    > $query_rsAgreements = sprintf("SELECT * FROM agreements
    WHERE CompId = %s and
    >DocumentName = "handbook"",
    GetSQLValueString($colname_rsAgreements, "int"));
    Change the above line to:
    $query_rsAgreements = sprintf("SELECT * FROM agreements WHERE
    CompId = %s
    and DocumentName = 'handbook'",
    GetSQLValueString($colname_rsAgreements,
    "int"));
    Gary

  • Error reading data from CLOB column into VARCHAR2 variable

    Hi all,
    Am hitting an issue retrieving data > 8K (minus 1) stored in a CLOB column into a VARCHAR2 variable in PL/SQL...
    The "problem to be solved" here is storing DDL, in this case a "CREATE VIEW" statement, that is longer than 8K for later retrieval (and execution) using dynamic SQL. Given that the EXECUTE IMMEDIATE statement can take a VARCHAR2 variable (up to 32K(-1)), this should suffice for our needs, however, it seems that somewhere in the process of converting this VARCHAR2 text to a CLOB for storage, and then retrieving the CLOB and attempting to put it back into a VARCHAR2 variable, it is throwing a standard ORA-06502 exception ("PL/SQL: numeric or value error"). Consider the following code:
    set serveroutput on
    drop table test1;
    create table test1(col1 CLOB);
    declare
    cursor c1 is select col1 from test1;
    myvar VARCHAR2(32000);
    begin
    myvar := '';
    for i in 1..8192 loop
    myvar := myvar || 'a';
    end loop;
    INSERT INTO test1 (col1) VALUES (myvar);
    for arec in c1 loop
    begin
    myvar := arec.col1;
    dbms_output.put_line('Read data of length ' || length(myvar));
    exception when others then
    dbms_output.put_line('Error reading data: ' || sqlerrm);
    end;
    end loop;
    end;
    If you change the loop upper bound to 8191, all works fine. I'm guessing this might have something to do with the database character set -- we've recently converted our databases over to UTF-8, for Internationalizion support, and that seems to have changed underlying assumptions regarding character processing...?
    As far as the dynamic SQL issue goes, we can probably use the DBMS_SQL interface instead, with it's EXECUTE procedure that takes a PL/SQL array of varchar2(32K) - the only issue there is reading the data from the CLOB column, and then breaking that data into an array but that doesn't seem insurmountable. But this same basic issue (when a 9K text block, let's say, turns into a >32K block after being CLOBberred) seems to comes up in other text-processing situations also, so any ideas for how to resolve would be much appreciated.
    Thanks for any tips/hints/ideas...
    Jim

    For those curious about this, here's the word from Oracle support (courtesy of Metalinks):
    RESEARCH
    ========
    Test the issue for different DB version and different characterset.
    --Testing the following PL/SQL blocks by using direct assignment method(myvar := arec.col1;) on
    different database version and different characterset.
    SQL>create table test1(col1 CLOB);
    --Inserting four CLOB data into test1.
    declare
    myvar VARCHAR2(32767);
    begin
    myvar := RPAD('a',4000);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('a',8191);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('b',8192);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('c',32767);
    INSERT INTO test1 (col1) VALUES (myvar);
    commit;
    end;
    --Testing the direct assignment method.
    declare
    cursor c1 is select col1, length(col1) len1 from test1;
    myvar VARCHAR2(32767);
    begin
    for arec in c1 loop
    myvar := arec.col1;
    --DBMS_LOB.READ(arec.col1, arec.len1, 1, myvar);
    dbms_output.put_line('Read data of length: ' || length(myvar));
    end loop;
    end;
    The following are the summary of the test results:
    ===================================
    1. If the database characterset is WE8ISO8859P1, then the above direct assignment
    method(myvar := arec.col1;) works for database version 9i/10g/11g without any
    errors.
    2. If the database characterset is UTF8 or AL32UTF8, then the above direct assignment method(myvar := arec.col1;) will generate the "ORA-06502:
    PL/SQL: numeric or value error" when the length of the CLOB data is greater
    than 8191(=8K-1). The same error can be reproduced across all database versions
    9i/10g/11g.
    3. Using DBMS_LOB.READ(arec.col1, arec.len1, 1, myvar) method to read CLOB data into a VARCHAR2 variable works for both WE8ISO8859P1 and UTF8
    characterset and for all database versions.
    So - it seems as I'd surmised, UTF8 changes the way VARCHAR2 and CLOB data is handled. Not too surprising, I suppose - may you all be lucky enough to be able to stay away from this sort of issue. But - the DBMS_LOB.READ workaround is certainly sufficient for the text processing situations we find ourselves in currently.
    Cheers,
    Jim C.

  • How can I pass Global Variable from Page1 to Page2

    I have the following senario.
    Pag1 - report is based on following PL\SQL
    declare
    g1 varchar2(100);
    begin
    g1 = select * from emp where dept = 10;
    return g1;
    end;
    Now I have Page2 - based on following PL\SQL
    declare
    g2 varchar2(100);
    begin
    g2 := g1; -- here i want to use variable g1???
    return g2;
    end;
    My question is - How can I use variable g1 from P1 in my new page P2.
    Thanks,
    Deepak

    Hi Andy,
    Thanks for the clarification.
    I did exactly the same, created a new Region with HTML (PL\SQL) and got the output. it was fine.
    Now when I am using exactly the same code in a Report (PL/SQL function returning a SQL Query), I am getting the following error.
    DECLARE
    g VARCHAR2(100);
    BEGIN
    g := 'This is a test string';
    APEX_UTIL.SET_SESSION_STATE('G_SQL_STRING', g);
    htp.p(v('G_SQL_STRING'));
    END;
    ERR-1002 Unable to find item ID for item "FLOW_SECURITY_GROUP_ID" in application "4000".
    ERR-1002 Unable to find item ID for item "G_SQL_STRING" in application "4000".
    I am doing the same thing, nothing changed....only difference is in 1st case I am using HTML (PL\SQL) Region and in 2nd case using the REPORT Region (PL/SQL function returning a SQL Query)
    thanks,
    deepak

Maybe you are looking for

  • Choice format for null or empty string vs non-empty

    How can I provide a choice format string for null or empty substitution strings? I know one would not nomally do this, but the substitution strings are being passed in by an independant legacy code. I need something equivalent to Some message with a

  • MacBook Air can't connect to external display

    2 months ago I bought a Thunderbolt to VGA adapter and its working normally, then after 2 weeks its stopped working. I plugged the adapter in and the VGA cable then the built-in display fades to black (nothing is happening on my external display at a

  • 5800 email client confuses me - or is it buggy?

    Have just started using Nokia email client (latest update) for push Gmail email and find the settings confusing. Two problems; 1) 'When to sync' is set to 07.30-22.00. Despite this, it checks email every four hours during the night (waking me up). 2)

  • Help ON Using Applets

    Hello, I've written an applet that is supposed to allow users to use my program on the Internet. The applet works alright but the problem is that when the applet containing the program is loaded, the functions(close, open file, and so on) doesn't wor

  • Problem with SDBINST -depend =   says...."unknown option"

    Hello! I'll got an "unknown option" for the -depend option when installing the MAXDB database part from sapinst. MAXDB 7.5 Build 18. On Linux SLES8. Does anyone have any idéa about this? Where can I check the support and compabillity matris between d