With the help of inplace column number of the column name in the SQL Select statement

Is it possible to execute instructions select sql with the number of columns in
place names of columns?

Run SQL
select AddressId,Name,City from Address
Is it possible
select 1,2,5 from Address
Thanks in advance

You can extract the names of the columns for user_tab_columns
with

SELECT Column_name
FROM user_tab_columns
where table_name = 'MY_TABLE'
and Column_id in (1,2,5)

Use dynamic SQL and then the result to get the values.

But as others already mentioned, this wil it be given incorrect if your table is changed.

Tags: Database

Similar Questions

  • What is the sql SELECT statement to list all service names in the database?

    What is the sql SELECT statement to list all service names in the database?

    I tried
    SELECT name FROM dba_services
    But a long with valid service, he list also some other documents that are not the names of services.

    Hello

    You can try this query:

    select name, value from v$parameter where name = 'service_names';
    

    Hope this helps.
    Best regards
    Jean Valentine

  • Problem with the simple Select statements

    Hi experts,

    I have with SQL Server and I'm going to hurt when I use the similar syntax in sqlplus to query an Oracle table.

    For example... my table contains column SCHID SET in the numeric form. Table has thousands of lines and the SCHID column is filled.

    Select TOP 100 AFTSCHAUXDATA SCHID;

    Get the "Word FROM key not found where expected" error

    Select DISTINCT from AFTSCHAUXDATA SCHID;

    Download "no selected lines.

    Can someone help me please?

    Thank you, John

    Can someone tell me how to find the names of the 20 largest tables (bigger which means that most of the files)?

    Once you have updated statistics on the table, you can query the DataDictionary: USER_TABLES/ALL_TABLES/DBA_TABLES.
    I'm assuming that user_tables will do:

    select *
    from ( select table_name
           ,      num_rows
           from   user_tables
           order by num_rows desc nulls last
         )
    where rownum <= 20; 
    

    You can find more explanations about the DataDictionary in the Oracle Online Documentation.
    Just do a quick and easy search
    http://www.Oracle.com/pls/db112/homepage
    or
    http://www.Oracle.com/pls/db102/homepage
    Depending on your version of the database.

  • A loop using the SQL select query.

    Hello

    I wanted to know, if the concept of loop is possible thanks to the SQL select statement.

    For example
    =======

    Table T1

    Col1 Col2
    Slim 10

    I want to write a query in such a way, so that when I get the result of the query, I format below.

    Col1 Col2
    Slim 10
    Slim 10
    Slim 10

    Basically what I'm trying to achieve is, I have a table with two columns and it has a single line displayed above.

    I want to display this line several times as the output of my SELECT query.

    Let me know, if this target is achievable.

    Kind regards
    Saurabh

    Like this?

    SQL> SELECT 10 col1, 'Sourabh' col2
      2    FROM DUAL
      3  CONNECT BY LEVEL <= 3;
    
          COL1 COL2
    ---------- -------
            10 Sourabh
            10 Sourabh
            10 Sourabh
    
    SQL> 
    
  • VIX file in the user interface designer receives the data from the Web service application that communicates with the SQL server database

    I created the Web service VI ("Mt-insolacije.vi"), which has two terminals of the input string (FROM / TO) for the dates of arrival and exit of two data terminals (table 1 d) from database (MS SQL server). This VI communicates with the database with functions of the database with a DSN and SQL query appropriate palette. There are two tables with two data (time and Insolation) columns in the database.

    This VI works when you run in Labview 2010, but when I used it as VI in UI Builder it returns no data.

    Could you please help me find a solution. Is it possible to communicate with the SQL server database in this way or there is another way?

    There are two files attachmet: Image of .vix file in Interface builder and .vi file ("Mt-insolacije.vi")

    Please help me ASAP!

    Thank you

    Ivan

    I found the solution problem is in the DSN. I've been using the user instead of DSN system DSN.

    It's important to create the system DSN if you want your VI of web service to communicate with the database.

    PS Please put feature bundle format timestamp and XY graph in the web user interface designer. It's complicated to trace data with datetime on X axis without them.

  • See bug handles (and confiscation) with the direct Selection of the 5.5 tool?

    Install previous Illy (including 5.5), clicking on a path with the direct Selection "chose" tool this path or shape and showed all the anchors and handles, so I could catch. Now, when I click on a path or shape with direct selection, I get nothing. If I know where is an anchor, I can enter directly (with a guess) and move it - which shows me its handles, but I can't catch them.

    I've never had this problem before. Is there some preference that I need to put? I have a bad installation? Does anyone else have this problem?

    Thank you

    ND

    Fact View > Show Edges help?

  • Cannot see the whole picture when you move into a smaller template with the direct Selection tool

    Hello!

    I recently got my laptop cleaned in preparation for examinations and such (I'm in high school). As I belong to art class, when Basic programs have been re-installed we also got the Adobe programs, but we got the CC 2015 version instead of the version CS5, we had earlier. After a stressful week, I finally had time to sit and work on my projects aside, but I quickly found a big problem which stops at my work. After re size the image at the size I want, I don't see the whole picture when I move in the smallest area with the direct Selection tool more. Photos I use are generally quite large, that I've tried to work with now are 451mmx338mm after the scaling down and I have a 'framework of standard departure' to 60mmx15mm (I make the bosses), so now I have basically has to guess my way toward a good composition...

    Can I make it work again?

    Click on the image and hold the pointer of the mouse for a while. And then drag.

  • Hello I am a student and I have a problem with the tool Selection (V). When I opened the file AI CC with CS6 selection tool doesn't allow me to change the selection. What can I do? (I have reinstall AI CC and the problem persists)

    Hello I am a student and I have a problem with the tool Selection (V). When I opened the file AI CC with CS6 selection tool doesn't allow me to change the selection. What can I do? (I have reinstall AI CC and the problem persists)

    Ivan,

    If it's on the rectangular objects, you may have encountered the bug Rectangle Live which is limited to the MAC versions from 10.7 and 10.8, but not of 10.9 (Mavericks) or 10.10 (Yosemite). If all goes well, the bug will be fixed soon.

    Thus, a switch for the Mavericks or Yosemite with a reinstall might be the way to solve it here and now.

    To get around it, in each case, it is possible to develop direct Rectangles to get the normal old shaped rectangles or Pathfinder > unit, or use the scale tool or the free transform tool.

    A more permanent way round that is to create normal old shaped rectangles, after running the free script created by Pawel, see this thread with download link:

    https://forums.Adobe.com/thread/1587587

  • How to constrain angle of anchorage when I pull on a path with the direct Selection tool?

    How to constrain angle of anchorage when I pull on a path with the direct Selection tool, as it did in all versions of Illustrator since 1988? New behavior is costing me time.

    Open preferences > display selection and anchor.

    Here you can constrain the handles

  • Problem with the direct Selection in Illustrator CS5.1 tool

    Lost my ability to transform a selection with the direct Selection tool. When I select an element, I get not all my little manages to make a transformation directly on the object... have lost patience, trying to find the problem.

    View--> edges of the show.

    Mylenium

  • How can I disable overview of the hidden regions when you drag an image into the image with the direct selection tool?

    CS5, don't know how that Word...

    In the previous version of ID, if I had a graph in a framework, I could drag the image around inside this image with the direct Selection tool.  I can always do with CS5, but he seems to want to show the entire image in a manner of ghosts that is outside of the framework.  Is there a way to disable this type of song look as if it was in previous versions?  I want sound slow down my computer to the low bigtime because I am facing a large image.  Whenever I click to drag, everything slows to a crawl and unusable.

    Go to the preferences and delayed the Live Drawing screen value.

  • using the function - how to use the values of the input variables on the table select statement names

    Hello community, I have a problem when creating a function. The purpose of this function is to check the table of weather gave yesterday or not. We must check this on different tables on different sachems. We are creating a function with input variables.

    CREATE OR REPLACE FUNCTION IN_SCHEMA.IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    )

    RETURNS INTEGER

    AS

    -Declaring variables

    v_is_true INTEGER.

    BEGIN

    SELECT

    CASE

    WHEN MAX (in_datefield) = TRUNC(SYSDATE-1)

    THEN 1

    ON THE OTHER

    0

    END

    IN

    v_is_true

    Of

    in_schema.in_tablename

    ;

    RETURN v_is_true;

    END;

    /

    When creating, I got error: [error] ORA-00942 (44:19): PL/SQL: ORA-00942: table or view does not exist

    How to use the values of the input variables on the table select statement names?

    Hello

    Here's a way you can use dynamic SQL statements for this task:

    CREATE OR REPLACE FUNCTION IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    in_first_date DATE DEFAULT SYSDATE - 1,.

    in_last_date DATE by DEFAULT NULL

    )

    RETURNS INTEGER

    AS

    -IS_YDAYDATA_TO_TABLE returns 1 if in_schema.in_tablename.in_datefield

    -contains all the dates in the in_first_date of the range through included in_last_date

    - and it returns 0 if there is no such lines.

    -If in_last_date is omitted, the search only the data on in_first_date.

    -If in_first_date is omitted, it defaults to yesterday.

    -Time parts of the in_first_date and in_last_date are ignored.

    -Declaring variables

    sql_txt VARCHAR2 (1000);

    v_is_true INTEGER.

    BEGIN

    sql_txt: = 'SELECT COUNT (*).

    || 'FROM ' | in_schema | '.' || in_tablename

    || 'WHERE ' | in_datefield | ' > =: d1'

    || «AND» | in_datefield | '< >

    || 'AND ROWNUM = 1';

    dbms_output.put_line (sql_txt |) '= sql_txt in IS_YDAYDATA_TO_TABLE");  -For debugging

    Sql_txt EXECUTE IMMEDIATE

    IN v_is_true

    With the HELP of TRUNC (in_first_date) - d1

    TRUNC (NVL (in_last_date

    in_first_date

    )

    ) + 1                -- d2

    ;

    RETURN v_is_true;

    END is_ydaydata_to_table;

    /

    DISPLAY ERRORS

    If you must use dynamic SQL statements, put all the SQL statement in a single string variable, such as sql_txt in the example above.  In this way, you can easily see exactly what will be executed.  Comment out the call to dbms_output under test is completed.

    Try to write functions that will address not only the question that you have now, but similar questions that you may have in the future.  For example, now that interest you only to the verification of the data of yesterday, but later, you might want to check another day or range of days.  The above function combines the convenience of a function simple (looks like yesterday data if you don't tell him otherwise) with the power of a more complex function (you can use the same function to check any day or range of days).

  • SQL SELECT statement as a parameter in the procedure of string

    Hi all

    I'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?

    A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
    SET SERVEROUTPUT ON
    DECLARE
      TYPE my_cur IS REF CURSOR;
      query_cursor my_cur;
    BEGIN
      OPEN query_cursor FOR 'SELECT * FROM customers';
      DECLARE
        record_type customers%ROWTYPE;
      BEGIN
         LOOP
            FETCH query_cursor INTO record_type;
            EXIT WHEN query_cursor%NOTFOUND;
            DBMS_OUTPUT.PUT_LINE('some output ... ');
         END LOOP;
      END;
      CLOSE query_cursor;
    END;
    /
    My idea was to modify this example to work in the following code, but it does not work (I get a compile error):
    SET SERVEROUTPUT ON
    DECLARE
      TYPE my_cur IS REF CURSOR;
      query_cursor my_cur;
    BEGIN
    
      OPEN query_cursor FOR 'SELECT * FROM customers';
    
      DECLARE
        record_type query_cursor%ROWTYPE;
      BEGIN
         LOOP
            FETCH query_cursor INTO record_type;
            EXIT WHEN query_cursor%NOTFOUND;
            DBMS_OUTPUT.PUT_LINE('some output ... ');
         END LOOP;
      END;
      
      CLOSE query_cursor;
    
    END;
    /
    Does anyone has an idea how can I solve my problem?

    Thank you very much!
    (I'm using Oracle 11 g)

    This can help.
    Re: Dynamic Extraction on dynamic Sql

  • Date range of calculation with the SQL statement

    I'm sure that there is a way to do this in SQL, but I can't understand it. I can write a PL/SQL script to do it, but prefer to use a SQL statement. My database is the database of Oracle 10.2.0.4.0.

    I have a table that contains information such as employee number, service id, and date effective start-up of the person in this Department. There are data in another table I want to update their department number in based on their date of entry in the range. If I could figure out how to correctly select the entry into force, I can do the rest.

    I have data such as:
    EMP_ID DEPT_NO EFFECTIVE
    -------------- ----------------- ---------------------
    101 1000 1/15 / 2001
    1050 101 5/24 / 2005
    101 2010 6/8/2008
    101 1000 8/2/2010

    I want to write a SELECT statement that returns something like this where the end_date is the eve of the ENTRY into force and the last record didn't an end_date because they are always assigned to this service. In addition, the first record in the column, I won't choose a DEPT_NO because the logic of the entry into force has been added in January 2001, he says if a person started in 1985 they might have zero departments at several times so I won't update all data for this period:

    EMP_ID DEPT_NO EFFECTIVE END_DATE
    --------------- ---------------- ---------------- ----------------
    101 1/14 / 2001
    101 1000 1/15 / 2001 5/23/2005
    1050 101 5/24 / 2005 6/7/2008
    101 2010 6/8/2008-8/1/2010
    101 1000 8/2/2010

    Here is a script to create the data into a temporary table which can be used to write a SELECT statement. I added two records of employees with different dates.

    create the table temp_activity
    (emp_id number (12),)
    dept_no number (12).
    (entry into force);

    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1000,to_date('1/15/2001','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1050,to_date('5/24/2005','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,2010,to_date('6/8/2008','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1000,to_date('8/2/2010','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (102,1040,to_date('1/15/2001','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (102,2000,to_date('6/16/2006','MM/DD/YYYY'))
    /

    Any help is appreciated. It's probably easy, but I can't get my brain wrapped around it.

    Thanks - mike
    select  emp_id,
            dept_no,
            effective,
            end_date
      from  (
              select  emp_id,
                      dept_no,
                      effective,
                      lead(effective) over(partition by emp_id order by effective) - 1 end_date,
                      row_number() over(partition by emp_id order by effective) rn
                from  temp_activity
             union all
              select  emp_id,
                      null dept_no,
                      null effective,
                      min(effective) - 1 end_date,
                      0 rn
                from  temp_activity
                group by emp_id
            )
      order by emp_id,
               rn
    /
    
        EMP_ID    DEPT_NO EFFECTIVE  END_DATE
    ---------- ---------- ---------- ----------
           101                       01/14/2001
           101       1000 01/15/2001 05/23/2005
           101       1050 05/24/2005 06/07/2008
           101       2010 06/08/2008 08/01/2010
           101       1000 08/02/2010
           102                       01/14/2001
           102       1040 01/15/2001 06/15/2006
           102       2000 06/16/2006
    
    8 rows selected.
    
    SQL> 
    

    SY.

  • Problem with the update CFQUERY statement

    I can't get an SQL Update statement works correctly and I am scratching my head as to why.

    The result I get is:

    Syntax error in UPDATE statement

    SQLSTATE 42000
    "SQL UPDATE businesses SET CompanyName ="Insight Data Ltd", Address1 =" 5 Boulevard", address2 =", Address3 = ", city ="Weston-super-Mare", County is"North Somerset", postal code ="BS231NN", OfficeBranch ="BR", contacttitle1 = 'Mr', contactname1 is"Andrew", contactsurname1 ="Scott", contactposition1 ="Owner", mail1 = 'Yes', TelNumber = ' 01934 123456 ', GST = 'no', number of Fax =", FPS = "no", phone =", MPS = 'no', email = '[email protected]', EPS = 'no', Adresse_web =' http://www.insightdata.co.uk', = 'Mr' contacttitle2, contactname2 is"David", contactsurname2 ="Lewis", contactposition2 =" Office Manager " mail2 = 'no', contacttitle3 = 'Mr', contactname3 = ", contactsurname3 =", contactposition3 = "Owner", mail3 = 'no', contacttitle4 = 'Mr', contactname4 = ", contactsurname4 =", contactposition4 is 'Owner', mail4 = 'no', wPVCUfab = 'Yes', wALUinst = 'yes', WHERE companyid = 33415 information
    VENDORERRORCODE-3503
    Idv6 DATA source

    I checked all the data fields are in the correct format, and I don't see why I'm getting a syntax error. Any help on this would be appreciated

    Okay, but it looks like you already have the sql code. Take the query in the error message above and run it in your database. However, I have noticed have a comma between the last column and there WHERE clause.

    wALUinst = 'Yes', WHERE the companyid = 33415 information

    For optional columns, put the first comma to avoid errors due to the leak, or too many commas

    UPDATE Table
    SET column1 = 'value '.
    , Column2 = 'another value '.
    WHERE ID = 123

    Two other points to consider: use cfqueryparam and consider to normalize your table. The names of column as to Contact1, Contact2, Contact3... usually is a sign of his time to normalize.

Maybe you are looking for