Does CTAS evaluate "order by" in APEX SQL Command window?

I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
Is this expected behavior?

user648567 wrote:
Please update your forum profile with a real handle instead of "user648567".
I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
What do you mean by "order by"?
Using an "ORDER BY" clause in a CTAS (in APEX or anywhare else) will have no effect on column order, which is determined by the order in which columns appear in the projection. It will affect the order in which rows are returned by that query, and it will not determine the order in which rows will be returned by querying the new table in the future.
To change the column order the columns in the SELECT clause of the CTAS would have to be in a different order from those in the original table,

Similar Messages

  • UTL_HTTP, different error codes: APEX SQL Commands vs. Oracle SQL Developer

    Hi, omniscient all!
    I have a code sample where I try to request some URL from an inactive server:
    declare
      l_text varchar2(32000);
    begin
      l_text := utl_http.request('http://inactive.url:7777');
    exception
      when others then
        declare
          l_errcode number := utl_http.get_detailed_sqlcode;
        begin
          dbms_output.put_line(l_errcode);
          dbms_output.put_line(sqlerrm(l_errcode));
        end;
    end;
    /When I run it in Oracle SQL Developer it shows:
    anonymous block completed
    -12541
    ORA-12541: TNS:no listenerWhen I run it in the APEX 4.0 SQL Commands window it shows:
    -29263
    ORA-29263: HTTP protocol error
    Statement processed.The question is: why?
    In real world, I need to make a HTTP POST request (no problem) and catch some exceptions. But instead of the usual ORA-12541 error APEX throws an ORA-29261 one.

    Any thoughts?

  • Short cut to run SQL under SQL Commands window

    Hi people
    what is the keyboard key to run the sql statements under SQL Commands windows in APEX. like in PL/SQL Developer its F8.
    Thanks

    Thanks dccase
    It works
    Appreciate ur help

  • Access to Previously-saved SQL in SQL Commands Window

    Hi all,
    If I've saved some SQL in the SQL Commands window, shouldn't that be available to other developers when they click on the Saved SQL tab? I saved a sample query and one of my other developers doesn't see it. I don't see any setting available in the developer account that controls whether or not the account can see others' saved SQL.
    If this isn't allowed, then I don't really see the point of the Owner drop-down in the Saved SQL tab.
    Any advice?
    Thanks!!
    John

    Hi Sc0tt,
    I think you may be referring to the Schema drop-down that appears in the upper-right area in SQL Commands, Object Browser, etc. That isn't the drop-down I'm referring to. I'm referring to the Owner drop-down that appears in the lower-half of the SQL Commands window then you click the Saved SQL link. I understand that to be the ApEx developer who saved the SQL - nothing to do with database schemas.
    I saved some SQL using the Save button assuming I could tell my other developers that if they click Saved SQL they'd see it listed. They don't, and the only choices in the Owner drop-down for any of us are "-- All Users --" or our own user. I don't see any setting I can change for our accounts to allow/prevent seeing others' Saved SQL, so either it's a bug, or if it's intentional that a user can only bring back their own saved SQL then there doesn't appear to be any point in having an Owner drop-down.
    Thanks,
    John

  • SQL*PLUS Verus using new Oracle10 xe   SQL commands window

    Can I run all manor of queries in SQL COMMAND as in sql*plus .Put another way
    does the new orcale 10 xe (SQL command window) have any restrictions at all in terms
    of code ?
    P.S. Up to now I think this DATABASE program is great.( still testing large files)
    Thanks
    Bob

    Great that's exactly the answer I was hoping to get, I am new to Oracle products
    but not new to SQL and find the new Oracle interface to be top notch compared to any
    "FREE" programs out there right now! I tried the free microsoft SQL server program
    and found almost no help or free tutorials like Oracle 10 xe has ( Way to go Oracle !)
    Thanks
    Bob

  • Crystal Reports XI does not allow to change Table to SQL command?

    I have report that has Table in Datasource and this table used in report and all fileds are mapped. I need to change table to SQL Command with the same result set of collumns. When I try to Update in Set Datasource Location - it does not work. CR XI allow to update Command to table but Table to Command just do nothing.
    What I have to do or how I can do it?

    Alexander,
    That's probably the "Best" way to do it, and long term you'll want to start adding BOE to your work flow.
    If you want to get around it, here how:
    1) MAKE A COPY OF YOUR REPORT AND WORK FROM THE COPY!!! This involves some a good deal of destruction before you get into reconstruction.
    2) Once you have created your command, remove the table.
    3) Now the fun part... Go through report and manually change all references to the 1st table...
       report fields
       formulas
       selection criteria
       groups
       the whole 9 yards...
    A short cut for the future... If you make all of your formula copies of all of your fields ( fCustomerName = {Table.CustomerName} ) and then only use the formula version of the field in the reports, you can make these changes very easily. (All you have to do is update the one set of formulas.)
    Also as a side note before you get started... You may want to think twice before you mix commands with tables. You loose the server side filtering and grouping on the tables when you do that.  So if you have several tables, you are better off doing the whole thing in one SQL command, do all of your filtering and sorting there and use it to replace ALL of your tables.
    Basically, Graham's way is the easy way... Assuming you have access to the BOE.
    Jason

  • Adding more statements to the sql commands window

    Hi, I'm using oracle database express edition10g and I just started using oracle.
    And I'm having a problem adding more then one statement inside the sql commands gui window.
    I write:
    CREATE TABLE "testTable" (
         "field1" VARCHAR2(2),
         "field2" NUMBER(2,0),
         "field3" NUMBER(2,0),
         CONSTRAINT "Test_PK" PRIMARY KEY("field1")
    Oracle reports: table created
    I write
    DROP TABLE testTable;
    CREATE TABLE "testTable" (
         "field1" VARCHAR2(2),
         "field2" NUMBER(2,0),
         "field3" NUMBER(2,0),
         CONSTRAINT "Test_PK" PRIMARY KEY("field1")
    Oracle reports: ORA-00911: invalid character
    I remove the ; char
    ORA-00933: SQL command not properly ended
    I look in the help files and it sais that ; / and nothing is allowed to end a operation.
    I gues ; is a valid char so it's reporting something else?
    I tried pasting my code inside wordpad and even retyping it. Mayby I have a hidden char? =>same error.
    When I run drop and create seperatly it works.
    When I run both sql statements inside sql+ it works
    What m I doing wrong?

    To run multiple SQL in one shot, you need to save them as SQL batch file,
    Save your statements as recreate.sql
    DROP TABLE testTable;
    CREATE TABLE "testTable" (
    "field1" VARCHAR2(2),
    "field2" NUMBER(2,0),
    "field3" NUMBER(2,0),
    CONSTRAINT "Test_PK" PRIMARY KEY("field1")
    );Then call it from SQLPlus,
    @recreate.sql

  • Create OS filesystem Directory Using Apex, SQL commands of SQL worshop

    I am using Apex 3.0, Oracle Database 10g and IE 6.5
    Code Here:
    Create or replace Directory 'Data_Dir' as 'C:\temp\'
    Error Message:
    Insufficient Priveleges
    This code runs fine when I access server remotely. Our projec team has no APex experience. our workspace administrator does not know how to grant appropriate privileges to my user accounts.
    Please provide us step by step help immediately on 'How to create OS Directory from APEX'.
    Thank you very much.

    Please provide us step by step help immediately on 'How to create OS Directory from APEX'.Please bear in mind that most people in this forum are doing it in their own time, without any financial gain from it. If you have an urgent support issue that is critical to your business and you want it answered immediately you should contact Oracle support, otherwise remember that you may need to wait some time for someone to answer your question here (especially considering it's the weekend).
    However, in answer to your question, yes your DBA will need to grant 'create directory' or 'create any directory' to the user you've specified. If you're saying it runs fine when you access the server remotely (I'm assuming you mean via SQLPlus etc), that probably suggests your DBA has granted the right via a role which won't work while connected in the APEX environment (you will need to explicitly grant the permission to the user).
    Hope this helps.

  • Is sql command window available

    I thought i could do away with that scratchpad/Enterprise manager set of tools for development with this VS add in.
    I'm trying to find a way to run sql (plus?) queries from with VS (not using Microsoft's OLE db for oracle - that does not provide syntax colouring). You can do this for Microsoft's SQL server in their server explorer.
    is it doable from ODT for VS ?

    A query window will be available in the production release which is less than a week away.
    Christian

  • SQL Commands window

    Can HTML_DB do multiple commands ?
    Im trying to update a column in a table using update but I want to chain multiple updates togeather to save time.
    all the updates work but I cant figure how to chain them together.
    I have tried adding a comma after each statement also adding a semi colon but to no avail.
    Any ideas?

    There's another way to do this, which I have found very useful in the past. Basically, do a select on the data that needs to be updated, and create a sql statement that creates the script to do the update. This works because you can quote strings in the select clause and have them appear in the result, as:
    Select 'update <table name> set <field name> = <new value>
    where <field name> = '||<value retrieved by query>
    from <table name>
    where <field name> = <search string>
    For each selected value, a query in this form will return a runnable update statement, as:
    select 'update emp set dept = ''manager''
    where dept = '||dept||';'
    from emp
    where dept = 'clerk';
    returns
    update emp set dept = 'manager'
    where dept = 'clerk';
    If you get the quoted syntax right, and are careful with the quotes so that you get proper quoting in the output ( note the '' and concat requirements) you can generate a runnable script. I've done this for deduping, for example, using a select that returned rowid, and deleting the duplicate record that had the lowest rowid (select min(rowid) where <selection criteria> and count(*) > 1, or something more or less like that. You have to test the select in order to make sure that the script returns the records you need to modify. Oh, and keep autocommit set off....

  • APEX - SQL Workshop - SQL Commands : Issue in extracting hour from date

    Hello All,
    When I run
    SELECT to_char(sysdate,'hh24') from DUALon SQL Developer and APEX SQL Commands window, both are returning correct hour value.
    But when I run
    SELECT to_char(i_date,'hh24') from t_factthen I'm getting correct values in SQL Developer but not in APEX SQL Commands window. In APEX, it always returns '00' for all rows. I'm totally lost what could be the issue with APEX? Any suggestions?
    DB Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    APEX Version: 4.0.1.00.03
    Web Server : EPG
    Table structure:
    CREATE TABLE  "T_FACT"
       (     "TF_KEY" NUMBER,
         "TOWER" VARCHAR2(20),
         "LOC_ID" NUMBER,
         "TF_CAT" VARCHAR2(35),
         "EQP_NAME" VARCHAR2(35),
         "I_DATE" DATE,
         "MON_CATEGORY" VARCHAR2(35),
         "EVENT" VARCHAR2(35),
         "UNIT" VARCHAR2(35),
         "TF_VALUE" NUMBER
       );Regards,
    Hari

    Hi,
    Just silly question case you have same table in multiple schemas:
    You run query in same schema?
    Regards,
    Jari

  • Code block works in SQL Command Processor but not in application

    Hello forum,
    Been struggling with this for a few days without success:
    I have a form with a popup LOV called P6_POPUP, a file browse item called P6_BROWSE, a SUBMIT button, and a Process with the following code:
    declare
    q_image_id number;
    begin
    select host_family_photos_seq.nextval into q_image_id from dual;
    insert into host_family_photos (image_id, file_object_id, image_name)
    select q_image_id, id, filename
    from htmldb_application_files where filename = :P6_BROWSE;
    update host_family set image_id = q_image_id where family_name = :P6_POPUP;
    end;
    The Process Point is set to On Submit after Computations and Validations and When Button Pressed is set to the Submit button.
    When I run the page the file is imported into HTMLDB_APPLICATION_FILES
    but the insert and update do not occur.
    The URL header after submitting is as follows:
    http://127.0.0.1:8080/apex/f?p=115:1:480837828458787::NO:::&success_msg=Photo%20Imported%2FB87C5A54684B0DF005D09D0DFE6E98D6%2F
    However if I run the above code in the APEX SQL Command window and supply the required variables it works every time - most confusing.
    Not sure what to try from here.
    thanks for your time,
    Brett

    Scott:
    I always thought that the File Browse item maps to the NAME column in the view (below) and that is guaranteed to be unique. The NAME column seems to have a system-generated "F1234" id embedded in it (to guarantee uniqueness, I thought).
    In other words, when we put a File Browse item on the page, submitting the page uploads the file into the HTMLDB_APPLICATION_FILES table and the way to access that record (to copy/move it into our own custom table) is by doing
    from htmldb_application_files
    where name = :P1_BROWSEThanks
    SQL> desc htmldb_application_files
    Name                                      Null?    Type
    ID                                        NOT NULL NUMBER
    FLOW_ID                                   NOT NULL NUMBER
    NAME                                      NOT NULL VARCHAR2(90)
    FILENAME                                           VARCHAR2(400)
    TITLE                                              VARCHAR2(255)
    MIME_TYPE                                          VARCHAR2(48)
    DOC_SIZE                                           NUMBER
    DAD_CHARSET                                        VARCHAR2(128)
    CREATED_BY                                         VARCHAR2(255)
    CREATED_ON                                         DATE
    UPDATED_BY                                         VARCHAR2(255)
    UPDATED_ON                                         DATE
    LAST_UPDATED                                       DATE
    CONTENT_TYPE                                       VARCHAR2(128)
    BLOB_CONTENT                                       BLOB
    LANGUAGE                                           VARCHAR2(30)
    DESCRIPTION                                        VARCHAR2(4000)
    FILE_TYPE                                          VARCHAR2(255)
    FILE_CHARSET                                       VARCHAR2(128)

  • "Between NVL" - Works in SQL Command, not in APEX report region

    First, I realize I could use dynamic SQL (model 4), but I don't want to (too hard just yet).
    I have a select statement with a series of Where conditions that employ values, in bind variables, supplied by the user.
    I want the choice of parameters to be optional, so I am checking for and replacing nulls.
    Select emp_name from employee_table where
    emp_rating between nvl(:p7_rating_choice, 0) and nvl(:p7_rating_choice, 99)
    and
    emp_language_no between nvl(:p7_lang_choice, 0) and nvl(:p7_lang_choice, 99);
    (the binds should be numeric).
    The actual statement is quite a bit longer, but the point is that the BETWEEN NVL(:x, min) AND NVL(:x, max) piece does not seem to work when used in a report region.
    It works fine if ALL parameters are provided, but returns an error if one or more are null.
    In the SQL command window it works (with a pop-up) just fine.
    By the way, the :p7_lang_choice bind variable is chosen from a LOV list which works in all other cases.
    Also, if I disable nulls (choosing "no" in ITEM page), everything works fine. It seems that the substitution of the min and max values via the NVL returns the wrong data type.
    Any ideas what I have done wrong?

    Thanks Scott.
    Every day brings a little more understanding!
    I also noticed a simplified method in the APEX documentation (although there was no explanation of the code) as follows:
    Where
    (column = :p1_user_input_1 OR :p1_user_input_1 = [null substitution value])
    AND
    (column = :p1_user_input_2 OR :p1_user_input_2 = [null substitution value])
    AND
    etc...
    Using the value you provide in the LOV section for the null, the second part of the OR handles the null situation.
    For some reason I was so tied up with comparing to the column that I never thought to have an OR with a compare to something else.
    Oh well.
    Thanks,
    Norm

  • Query help in sql commands

    using apex 4.1 i'm entering the following query in the sql command window and I keep getting a pop-up for Entering Bind Variable. I'm not using bind variables though, anyone else see this issue before?
    SELECT A.FIRST,A.LAST,A.COMPANY AS CNAME,
    J.TOT_MAN_HOURS,
    J.ACREAGE,
    W.NUM_WORKERS,
    W.START_DT
    FROM EW_ACCOUNTS A, EW_WORK_ORDER W, EW_JOBS J
    WHERE A.ID = J.ACCT_ID
    AND J.JOB_ID = W.JOB_ID
    AND W.START_DT >= SYSDATE
    AND W.START_DT < SYSDATE+1
    ORDER BY W.START_DT

    I tried that and it didn't seem to help either.
    Funny though, if I write a new query against just one of the tables and write out each column name. it works. If I use the * instead of writing each column name, I have the same issue.
    This is in apex.appshosting.com free demo environment. I sent them an email asking about it and they told me it was a code issue and they don't support the demo environment.

  • COPY command not working SQL Commands editor

    Hi All,
    I want to have a simple 'one-button-solution' for copying few tables from an external DB into the database where my Apex application is running.
    When I issue the following from the sqlplus command line I get the following output:
    SQL> COPY FROM schema/password@tnsnames_sid TO schema/password@tnsnames_sid REPLACE TABLE_TEST USING select * from TABLE_FOREIGN;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
    Table TABLE_TEST dropped.
    Table TABLE_TEST created.
    2 rows selected from schema@tnsnames_sid.
    2 rows inserted into TABLE_TEST.
    2 rows committed into TABLE_TEST at schema@tnsnames_sid.
    SQL>
    However, if I try exactly the same command from within the Apex 'SQL Commands' editor, I get the following error message:
    ORA-00900: invalid SQL statement
    NOTE that the reason I use COPY command is to overcome problems with LONG datatype which arise when doing simply CREATE TABLE AS.... with dblink.
    In anycase, how can I make this work from within the 'SQL Commands' editor (and therefore in a button process).
    Regards,
    Pawel.

    Hi Harman,
    yes, this is a known issue.
    It's fixed with NW04 SPS 13.
    Regards Matthias Röbig-Landau

Maybe you are looking for

  • ICI - How to display custom error messages in SAP CRM

    Hello, we are working on a custom Contact Center which interfaces with SAP CRM Version 7 with Enhancement Package over ICI. The basic call functions like accepting, hanging up, holding and retrieving are fully implemented and are working already. Our

  • "No signal" on screen with new mac mini

    Hi I have just bought my first Mac Computer. When everything ist properly connected and I start the Mini, the monitor shows "no signal". The Mini ist switsched on and starts (light goes on). The Monitor is a 4 year old TFT with Analog port (white ada

  • Portfolio not printing in alphabetic order

    I first posted this in the printing forum but did not get a response. Perhaps someone here can provide some guidance? I have a binder full of perhaps 50 pdfs that I want to assemble into a portfolio to ease printing. It seems the portfolio feature is

  • TS3694 iphone stuck in recovery

    I tried to update my iphone 3g using iTunes and now it is stuck in recovery mode with an error code 1015. Please help. Im not confident using any Youtube suggested sites as i dont know what they will eventually do to my phone, or if they actually wor

  • How can i put norton Toolbar in firefox 4?

    i cannot add the norton toolbar to fire fox and i need it..