How to generate a dynamic of variable


Hello

my version of oracle's

Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

PL/SQL Release 11.2.0.3.0 - Production

"CORE 11.2.0.3.0 Production."

AMT for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 - Production

I use following code to create a file.

Declare
Type Typ_Test_Data is Table of TEST % Rowtype;
Test_Data Typ_Test_Data;
v_delimited varchar2 (1): =' | ' ;
L_Cur Sys_Refcursor;
L_Filehandle Utl_File.File_Type;
V_File_Path Varchar2 (1000): = 'abc ';
V_Table_Name Varchar2 (32): = 'TEST ';
P_Stg_Table_Owner varchar2 (32): = 'abc ';
v_partition_name varchar2 (32): = "P201308";
V_Str Varchar2 (20000);
V_Column_Names_Str Varchar2 (20000);
V_Column_Names_Str2 Varchar2 (32000);
V_Str1 Varchar2 (20000);
Start

l_fileHandle: = Utl_File.Fopen (v_file_path, '05022015.txt', 'W');

IF UTL_FILE.IS_OPEN (l_fileHandle) = FALSE
THEN
Dbms_Output.put_line ('file is not open');
On the other
dbms_output.put_line ('File_is_open');
End If;

"/ * V_Str: = ' select * from '.
|| V_Table_Name
||' Partition (')
|| V_Partition_Name
||')'; */

"V_Str: = ' select * from '.
|| V_Table_Name;


Dbms_Output.put_line (v_column_names_str2);

L_Cur open for V_Str;
loop
Extraction L_Cur bulk collect into test_data limit 1000;
Because me in 1.test_data. County
Loop
V_Str1: is Test_Data (I). Emp_Id | V_Delimited | Test_Data (I). Emp_name | V_Delimited | Test_Data (I). Address;
Dbms_Output.put_line (V_Str1);
-Utl_File.Put_Line (l_fileHandle, Test_Data (I). Emp_Id | V_Delimited | Test_Data (I). Emp_name | V_Delimited | Test_Data (I). Address);
Utl_File.put_line (l_fileHandle, V_Str1);
End loop;
When the test_data output. Count = 0;

End loop;
Close L_Cur;
Utl_File.Fclose_All ();

end;
/

This generates files. but I want below the dynamic type declaration. so that the same code can work for different tables. We do this for data archiving,

Type Typ_Test_Data is Table of TEST % Rowtype;

IS this possible? Yes, how?

Hello

You can find an example here

Re: export csv via pl/sql: select statement?

Concerning

Marcus

Tags: Database

Similar Questions

  • How to generate URLS with several variables of input fields?

    I create an ad with four text fields labels fname, lname, city and province, and I wanted to know how to generate URLS based on the information entered in the fields. The text of the default fields to display "Name," "Last Name", "City" and "State", respectively, but if a user does not enter information in these fields, I want the URL to behave as if those who were empty, if that makes sense. Text fields are in a clip called 'input_text' and the button is titled 'send '. If any of you can provide insight, I would greatly appreciate. Thank you.

    1 use the instructions to see if if the properties your textfields text meets your requirements for the creation of this url.

    2. you can use the properties and methods string flash to create your url.

    p.s. the + sign can be used to concatenate strings.

  • How to generate a value of variable "fast"? Only possible with dbms_outpu

    Suppose I have defined a variable in a script from SQLplus and want it output in a quick statement.

    How can I do?

    The following does NOT work:

    accept myvar prompt "enter value ="
    prompt & myvar

    Here, I am invited again a second time.

    What can I do else?

    Is dbms_output.put_line (...) the only way?

    Peter
    SQL> accept myvar prompt 'Enter value='
    Enter value=222
    
    SQL> prompt you entered &myvar
    you entered 222
    

    Max
    http://oracleitalia.WordPress.com

  • How to dynamically create variables of StationGlobals who are LabVIEWIOControl

    I'm looking for a way to dynamically create variables StationGlobals LabVIEWIOControl.  I know not how to create variables through "PropertyObject/SetValXXX", however I have some difficualty create variables that are custom data types.

    Thank you

    Bryon

    Bryon,

    You can use an expression as follows:

    StationGlobals.NewSubProperty("MyVariable",PropValType_NamedType,False,"LabVIEWIOControl",0)

    I hope this helps!

  • How to have a dynamic variable name?

    I have a form that determines how many phone numbers, a customer must edit by running a query on the database. The client may have anywhere from 0 to 3 telephone numbers. I guess I can just wrap a CFOUTPUT QUERY tag around my input field so that it will make a loop if there is more than 1. What I don't know is how to dynamically name input field in the CFOUTPUT tag for the UPDATE query I run after the user submits the form.

    For example, if the query is that the user has 2 phone numbers for the table, how can I control their name?

    < name cfinput = ""? "" ... >

    < name cfinput = "?" 2 "... >

    How is it possible dynamically in the cfoutput which returns the result of the query?

    do not make your goal?

  • How to run execute immediate with variables

    Hi friends,
    How to run execute immediate with variables in v_stmt below?
    I don't know how to declare value I have here.
    Set serveroutput on;
    DECLARE
       i        VARCHAR (20);
       v_stmt   VARCHAR2 (100);
    
       CURSOR c
       IS
          SELECT sqlid FROM temp1;
    
    
    BEGIN
       OPEN c;
    
       LOOP
          FETCH c INTO i;
          EXIT WHEN c%NOTFOUND;
          DBMS_OUTPUT.put_line (i);
          v_stmt := 'select * from table(dbms_xplan.display_cursor('&i',null))'
          execute immediate v_stmt;
       END LOOP;
    
       CLOSE c;
    END;
    /
    Regds,
    Kunwar.

    You must first use a variable binding (named ': v' in the SQL statement in my example):

    set serveroutput on;
    DECLARE
       i        VARCHAR (20);
       v_stmt   VARCHAR2 (100);
    
       CURSOR c
       IS
           -- modified for a quick test
          SELECT sql_id FROM v$sql where child_number > 2;
    
    BEGIN
       OPEN c;
    
       LOOP
          FETCH c INTO i;
          EXIT WHEN c%NOTFOUND;
          DBMS_OUTPUT.put_line (i);
          v_stmt := 'select * from table(dbms_xplan.display_cursor(:v,null))';
          execute immediate v_stmt using i;
       END LOOP;
    
       CLOSE c;
    END;
    /
    

    However because your SELECT statement returns multiple lines, you need to adapt your code to process all rows returned (as already suggested in first response to your message).

    Instead of using the PL/SQL, I recommend you to generate a SQL file using only SQL, and then run the generated SQL file.
    For example:

    spool edx.sql
    set serveroutput on
    declare
    v_stmt varchar2(100);
    v_q char(1):='''';
    begin
    dbms_output.put_line('spool edx.log');
    for s in (select sql_id from v$sql where child_number >2)
     loop
      dbms_output.put_line('select * from table(dbms_xplan.display_cursor(' || v_q || s.sql_id || v_q || ',null));');
     end loop;
     dbms_output.put_line('exit');
    end;
    /
    spool of
    

    This generates a file similar to:

    spool edx.log
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('5rygsj4dbw6jt',null));
    select * from table(dbms_xplan.display_cursor('fsbqktj5vw6n9',null));
    select * from table(dbms_xplan.display_cursor('6q42j0018w7t8',null));
    select * from table(dbms_xplan.display_cursor('a5mmhrrnpwjsc',null));
    select * from table(dbms_xplan.display_cursor('3c1kubcdjnppq',null));
    select * from table(dbms_xplan.display_cursor('3c1kubcdjnppq',null));
    select * from table(dbms_xplan.display_cursor('9gkq7rruycsjp',null));
    select * from table(dbms_xplan.display_cursor('f0wj261bm8snd',null));
    select * from table(dbms_xplan.display_cursor('ab3swhv5g138y',null));
    select * from table(dbms_xplan.display_cursor('6vgvyh4xw9c5g',null));
    select * from table(dbms_xplan.display_cursor('ak5crjygnpk60',null));
    select * from table(dbms_xplan.display_cursor('9p6bq1v54k13j',null));
    select * from table(dbms_xplan.display_cursor('19x1189chq3xd',null));
    select * from table(dbms_xplan.display_cursor('7sx5p1ug5ag12',null));
    select * from table(dbms_xplan.display_cursor('730vdzhng6m6g',null));
    select * from table(dbms_xplan.display_cursor('730vdzhng6m6g',null));
    select * from table(dbms_xplan.display_cursor('0v3dvmc22qnam',null));
    select * from table(dbms_xplan.display_cursor('0v3dvmc22qnam',null));
    select * from table(dbms_xplan.display_cursor('a1zv6wju3ftgv',null));
    select * from table(dbms_xplan.display_cursor('7ng34ruy5awxq',null));
    select * from table(dbms_xplan.display_cursor('7ng34ruy5awxq',null));
    select * from table(dbms_xplan.display_cursor('b2gnxm5z6r51n',null));
    select * from table(dbms_xplan.display_cursor('b2gnxm5z6r51n',null));
    select * from table(dbms_xplan.display_cursor('g4gp07gt2z920',null));
    select * from table(dbms_xplan.display_cursor('1gu8t96d0bdmu',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('g00cj285jmgsw',null));
    select * from table(dbms_xplan.display_cursor('bn4b3vjw2mj3u',null));
    select * from table(dbms_xplan.display_cursor('38243c4tqrkxm',null));
    select * from table(dbms_xplan.display_cursor('2abjfnvy5rkyg',null));
    select * from table(dbms_xplan.display_cursor('350f5yrnnmshs',null));
    select * from table(dbms_xplan.display_cursor('350f5yrnnmshs',null));
    select * from table(dbms_xplan.display_cursor('3s1yukp05bzg6',null));
    select * from table(dbms_xplan.display_cursor('3s1yukp05bzg6',null));
    select * from table(dbms_xplan.display_cursor('1tgukkrqj3zhw',null));
    exit
    
    PL/SQL procedure successfully completed.
    

    Edited by: P. Forstmann March 20, 2013 19:06

    Edited by: P. Forstmann March 20, 2013 19:33

  • How to generate the script to insert data tables present in a

    How to generate the script to insert data from one table in an entire schema under environment sqlplus




    with toads it please help me please!

    905310 wrote:
    How to generate the script to insert data from one table in an entire schema under environment sqlplus
    with toads it please help me please!

    The correct method by using the pump of the database or import/export or unload the data in CSV format for loading using SQL * Loader.

    Generate instructions insert with literals is very bad choices - the bind variable is missing. It will be quite slow because many other CPU cycles are spend on hard analysis. The shared pool will become fragmented. This can cause errors of memory for other applications when they attempt to analyze SQLs for cursors.

  • How to multiply the channel by variable

    Hello

    I have a timestamp that is not real time, but the next number. I know that the interval (such as 1 or 10 seconds) of the measures. So I am this conversion to standard time. In this case, I need to multiply this channel by given interval. It's easy, because you can multiply the channel by a constant like below:

      Call ChnCalculate ("Ch(""[2]/Seconds1"") = Ch(""[1]/#"") * 1")
    Call ChnCalculate ("Ch(""[2]/Minutes1"") = Ch(""[2]/Seconds1"") / 60")
    Call ChnCalculate ("Ch(""[2]/Hours1"") = Ch(""[2]/Minutes1"") / 60")

    But how to do this using the variable? Let's say we have variable s_interval and we want to put this variable instead of multiplying it by constant.

    Ch(""[1]/#"") * 1 ")

    Do you know how to do this?

    Best regards

    Piotr

    Hi Piotr,

    You can set it like this:

    Dim dFactor
    Call ChnCalculate ("Ch(""[2]/Noise_1"") = Ch(""[2]/Noise_1"") /"& dFactor ")

    But I prefer a DIAdem function for this calculation, because it is faster using a well-defined function than the calculator.

    Dim dFactor, dOffset
    dFactor = 10
    dOffset = 0
    Call ChnLinScale ("[1] / Time", "[1] / Time", dFactor, dOffset)

    or if you use the channel object:

    Dim oChn, dFactor, dOffset
    Set oChn = Data.GetChannel("[1]/Time")
    dFactor = 10
    dOffset = 0
    Call ChnLinScale (oChn, oChn, dFactor, dOffset)

    Greetings

    Walter

  • When dynamically created variables are emptied in the sequential process template?

    I have a sequence TestStand 2014 in which I dynamically create and fill many FileGlobal variables in the installation section of my main sequence.  I have it using the TestStand API to read the data in an Excel file (the data consists mainly of thresholds, limits, etc.).  The methodology itself works flawlessy.

    However, there are differences in behavior when using entry points both execution of the sequential process model.  When you use the entry point of execution 'Single Pass', he has no problem in test a DUT after another.  However, when you use the entry point for execution "Test DUT", I encounter the following error after completing of DUT1 and DUT2 testing:

    An error occurred the call 'InsertSubProperty' in 'PropertyObject' of 'NI TestStand 2014 API.

    The name of the element "VariableName" is not valid because it is already in use.

    I interpret this error message means that the variable I am trying to dynamically create the DUT2 track is already present race of DUT1.  I have a few questions about this:

    1. at what point in the sequential process template are dynamically created variables flushed, such as run a further by using 'Single Pass' starts with a clean slate?

    2. is there a reminder that I can substitute such as variables to rinse after each HAD run, allowing me to dynamically create variables on each HAD, during execution using "Test UUT?

    3. better yet, is there a counter of TestStand I can query to determine if I already ran DUT1 when using "Test DUT", such as DUT2 uses the variables that were created dynamically on trail of DUT1?

    Or you can simply use the PropertyExists function as a precondition.

    PropertyExists ("Locals.Foo")

  • How to generate random numbers from 1 to 5

    How to generate random numbers from 1 to 5

    -1110340081

    Thank you I ended up

  • How to create a nested local variable control custom?

    I inherited code which has a cluster of CTL control nested inside another group of control CTL.  If I drag the control nested outside the border of the other, I can right-click to create a local variable, I need to connect to the bundle name.  However, as soon as I drag the inside the limits of external control, it breaks the local variable.

    How can I create a local variable in a cluster THAT CTL nested in a second group CTL?

    Is there some kind of reference OuterCluster.InnerCluster, that I can use if I do a local variable of the external group?

    It turns that I need a local variable for the cluster internal.

    JPG attached shows that I created a local variable for the external cluster (ParametersCluster), used a Unbundle based on the name to access cluster internal (EmptyParmeters) and can access one of the elements through an another Unbundle by name.

  • How to generate an impulse to test short circuit in an inducer

    Hello

    IM new to labview and am in need of complete SURG - SURGE STRESS TEST

    This test is intended to detect a short tour inter by applying a number of high
    voltage pulses (or surge) for the selected winding.
    Each pulse should produce one sinusoidal transient that eventually decreases to zero.

    How to generate the impulse using labview.

    Hi Jessica,.

    Please see the "pulse pattern.vi" function--> pallets of signal processing signal generation.

    Otherwise, you can browse through examples of LabVIEW.

    Kind regards

    Srikrishna.J

  • How to generate a vector under LabVIEW?

    How to generate a vector as n = 0:Ts:T in LabVIEW with the need for the mathscript node and with out of the loop?

    Focus on the ramp VI model.  It is located in the treatment-> Palette generation of Signal of the Signal.

  • How to generate curves under labVIEW

    Hi all
    Can someone please tel me how to generate the following curves under LabVIEW.
    Haversine curve 1.)
    2 Lorentz curve.)
    3 bell curve.)
    4.) exponential rise curve
    5. exponential decay curve)

    Note: Entries required for this curves are Amplitude, Phase, Offset
    Frequency and number of samples

    Have you read the second part of my post above?

  • How to convert a dynamic disk to a basic?

    How to convert a dynamic disk to a basic? I can't really deleat the C and readers of the system, and if so, how?

    Hi Brad,

    Welcome to Microsoft Community and thank you for the query display.

    According to the description, it seems that you want to convert a dynamic disk to Basic.

    However, we need more information about the issue to help you better.

    Please help me to answer these questions.

    1 how many partitions are on the hard drive?

    2 is installed Windows on drive C?

    3. you have any operating system installed on the hard drive?

    To convert the dynamic disk to basic, here are some steps that you can try.

    You can try to convert the dynamic disk drive basis (except your drive C :) using the Diskpart.exe in the command line. By following these steps, you can avoid reinstalling Windows XP. But if you want all the hard disk as a single partition, then proceed as follows.

    Note: Before formatting the hard drive or perform the steps, back up your data to an external storage device.

    Steps to convert dynamic disk to basic

    a. press Windows key + r on the keyboard and in the immediate window, type cmd.exe

    b. in the command prompt and type D iskpart .

    c. at the Diskpart prompt, type list disk . Note the number of the disk you want to convert to dynamic.

    d. at the Diskpart prompt, type select disk . (select the dynamic disk you want to convert.)

    e. at the Diskpart prompt, type clean to remove all volumes on the disk.

    (f) then, at the Diskpart prompt, type: convert base to begin to restore the disk to basic training.

    Respond us if you have any queries with hard drive problems and we will be happy to help you.

Maybe you are looking for

  • video does not work in firefox

    Suddenly unable to display any video on Firefox. Can see on other browsers. No idea on the extensions or plugins.

  • error in pc

    VAIO care has stopped working

  • replacing the fan comppaq cq62-219wm laptop

    I can't find step by step to replace my fan [or lubricant] Please forward any information I Thank you ENRIQUE

  • How to change the email contacts?

    I need to change my e mail contacts and forgot how... Help

  • Set the APN

    I am trying to establish a httpconnection via service provider using their apn. the connection works if the user has all of the correct apn based on their service provider, but when when apn is not properly defined and is set on blackberry.net enforc