Another attempt to create "on the fly" condition in PL/SQL

Here is the code:
---BEGIN ----
declare
my_var_list VARCHAR2(4000);
cursor my_curr is select aa.column_name as my_col_name from user_tab_columns aa, user_tab_columns bb
where aa.column_name = bb.column_name
and aa.table_name = 'MY_SUBSET_TABLE' and bb.table_name = 'MY_SUPERSET_TABLE';
begin
for my_ind in my_curr loop
my_var_list := my_var_list || my_i.my_col_name || ', ';
end loop;
insert into MY_SUPERSET_TABLE (my_var_list) select my_var_list from MY_SUBSET_TABLE;
end;
run;
---END---
I plan to extract column name from user_tab_column, and concat it into a variable "my_var_list".
The question now is, given the my_var_list contain column names (separate by comma), how can I use it in the select statement below?
insert into MY_SUPERSET_TABLE (my_var_list) select my_var_list from MY_SUBSET_TABLE;
Any idea on how to improve this script? I am running on Oracle9i ... using SQL Dev.
Thanks much...

It's a terrible idea, but it can be done. It could leave you open for sql injection hacks:
declare
my_sql VARCHAR2(4000);
column_list varchar2(4000);
v_iteration number := 0;
begin
for i in ( select column_name from user_tab_columns where table_name = 'T1') loop
if v_iteration = 0 then
column_list := i.column_name;
else
column_list := column_list||','||i.column_name;
end if;
v_iteration := v_iteration + 1;
end loop;
execute immediate 'insert into t2('||column_list||') select '||column_list||' from t1';
end;
/

Similar Messages

  • Please create "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]"?

    In Firefox 34, you have changed the search bar.
    The new style is perfect for those who always starts by typing in, letter for letter, the search term.
    People such as myself, we almost never type in the search term,
    but instead we mark a [word] in a text, right-click this marked [word], then select "Search [engine x] for [word]".
    Speaking for myself, I have now a total of 36 search engine providers, but I usually only use 7 of those.
    I use "Wikipedia (English)" most of the time..
    - but then I will switch to e.g. "AniDB" and use that one for 1 hour..
    - or switch to "Google" and use that one for 30 minutes..
    - or switch to "Wikipedia (Norwegian)" and use that one for 2 hours..
    - or switch to "Wiktionary (English)" and use that one for 15 minutes..
    ..and then I will switch back to "Wikipedia (English)" again.
    The way the search bar was in Firefox 33 and earlier, I could very easily switch the default search engine.
    Just one click to open the drop-down menu, then choose one.
    In Firefox 34, I have to choose "Tools" -> "Options", the "Search" tab..
    - before I can THEN click to open the drop-down menu.
    4 clicks instead of 1, that's like 400% more work..!
    Also, the fact that I have to go into "Options".. make this..
    ..I don't know how to put it, it's a kind of psychological barrier that I have to overcome each time.
    I mean, before Firefox 34, I went to the "Options" window like maybe 4 times each YEAR,
    now, I have to go there 4 times each DAY..!
    I am not saying you should revert to the old style Search bar,
    as I feel that those you are typing search terms are indeed very happy for this new style..
    Instead, I think of 2 possible ways to create happiness also for us that do mark text and choose "Search.."
    1) An "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]".
    This could work as a cascading menu option, where it says..
    Search for [word] in -> [engine x]
    ..and where [engine x] was the current default engine, and all the other engines was listed underneath,
    just like the drop-down menu when you switch the default engine.
    Additionally, you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Change default search engine when choosing another from the drop-down menu"
    THIS would actually be PERFECT.. It would be even much BETTER than in Firefox 33 and earlier..! :-)
    2) If there are things with the first option that don't work (something I've missed etc),
    then maybe you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Use old-style search bar"
    This would be off by default, but when switched on, it would give us the old Firefox 33 style Search bar.

    Strongly recommend Context Search extension which will solve your problem
    - https://addons.mozilla.org/en-US/firefox/addon/context-search/?src=search

  • Create on-the-fly menu in JSC 2

    Hi everyone,
    How to create an on-the-fly menu in JSC 2? the on-the-fly menu is something like the menu bar on this Sun Developer Netowork page. When you move a mouse over a link such as APIs, Downloads, and Technologies, there is a menu shown up.
    A sample code would be perfect.
    Thanks in advance,

    The Sun Developer Network page uses javascript to display on-the-fly menus.
    Browsers usually provide ways to view the source code of any HTML page. The instructions to view them will of course vary for different browsers. For mozilla1.4, You can do 'View | Page Source' to see which javascripts are used. You can also select the 'View | Page Info' menuitem, select the 'Privacy' tab and expand 'Scripts' to get the URLs of the scripts used in that page.
    The menucode used in Sun Developer Network page is http://forum.sun.com/jive/js/menucode.js.
    The following are the resources suggested by mozilla.org for javascript:
    http://www.mozilla.org/js/
    http://www.mozilla.org/js/scripting/
    You can of course obtain a lot of free javascripts from the web; for dynamic menus you might want to check out 'http://www.softcomplex.com/products/tigra_menu/'

  • Creating on the fly dynamic named bind variable names.

    I have an application process which gets called by a Dynamic action and Javascript.
    Everything is working great however I'm using it to drive dynamic charts.
    I could use IF statements at the end of the application process to decide what BIND vairable to fill with the information the process has collected however I'd prefer just to create the BIND variable from the
    name of the submitted information.
    So I have an application level variable called WHICHCHART. this gets populated with text upon calling the application process...so let's say 'chart1' is what it gets filled with.
    What I"d like to have at the end of the application process is just a bind variable waiting called :chart_1.
    So no matter what the value of WHICHCHART it will create an on the fly a bind variable with the same name.

    Ok. I guess this question was more how do you do this..then OH NO there are not other ways to do this.
    So I have a page with a chart region. this chart will have 3 Y Axes which prohibits the use of the default XML.
    So..
    I have the following Javscript:
    function getdata(whichchart) {
      var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=VM_XML_GENERATION',0);
            get.add('WHICHCHART',whichchart);
            gReturn = get.get('XML');
      get = null;
    Which is called when the page loads by a dynamic action:
    getdata('production');
    When the javascript is called as you can see it fires off:
    declare
       chart_series_data VARCHAR(32767);
       type array_cols is varray(7) of varchar2(100);
       array array_cols := array_cols('VM_HOSTS_NUM','VM_NUMBER','VM_PHYS_MEM','VM_VIRT_MEM','VM_CPU_COUNT', 'VM_TOTAL_DISK','VM_PROVISIONED_DISK');
    BEGIN
    --IF :WHICHCHART IS NULL THEN
    --RAISE_APPLICATION_ERROR(-20001,'Chart variable not set');
    --END IF;
    chart_series_data := null;
    chart_series_data := '      <data>'||chr(10);
    chart_series_data := chart_series_data||  '        <series name="Hosts Number" type="Line" color="0x1D8BD1" >'||chr(10);
    for c1 in (SELECT VM_REPORT_DATE LABEL,VM_HOSTS_NUM from TABLE where VM_REPORT_DATE between add_months(SYSDATE,-24) and SYSDATE and lower(VM_DCNAME)=lower(:WHICHCHART) )
    loop
    chart_series_data := chart_series_data || '<point name="'||c1.LABEL||'" ';
    chart_series_data := chart_series_data || 'y="'||c1.VM_HOSTS_NUM||'"></point> '||chr(10);
    end loop;
    chart_series_data := chart_series_data|| '      </series>'||chr(10)||'</data>';
    :PROD_DATA := chart_series_data;
    END;
    The : production variable at the end of this I want to change the name of based on the value I'm sending of WHICHCHART from the javascript. I hope this is clearer now.
    AGAIN this is not really a need. It is a want to be able to create dynamic bind variable names going forward.
    Thanks

  • Inserting into a table which is created "on the fly" from a trigger

    Hello all,
    I am trying to insert into a table from a trigger in Oracle form. The table name however, is inputted by the user in am item form.
    here is what the insert looks like:
    insert into :table_name
    values (:value1, :value2);
    the problem is that forms does not recognize ::table_name. If I replace :table_name with an actual database table, it works fine. However, I need to insert to a table_name based from oracle form item.
    By the way, the table|_name is built on the fly using a procedure before I try to insert into it.
    Any suggestion on how can I do that? My code in the trigger is:
    declare
    dm_drop_tbl(:table_name,'table) // a call to an external procedure to drop the table
    dm_create_tbl(:table_name,'att1','att2');
    insert into :table_name
    values (:value1, :value2);
    this give me an error:
    encounter "" when the symbol expecting one.....

    Hi ,
    You should use the FORMS_DDL built_in procedure. Read the on-line documentation of forms ...
    Simon

  • Print images created on the fly by a servlet

    Please, look at it... my tiff image doesn't print in my browser (IE6).
    Could somone tell me why !????
    // Method of a "Page" class
    public void write (OutputStream out) {
                // Reading of the tiff file (this.tempFile is a valid File)
         PlanarImage image    = JAI.create("fileload", this.tempFile.getCanonicalPath ());
                /*   // Test : the writed file is a valid tiff file --> the reading is OK !
                 *   File outFile = new File ("c:\\temp\\JLdsWeb\\Test.tif");
                 *   RenderedOp op = JAI.create("filestore", image, outFile.getCanonicalPath (), "tiff");
         // Writing of the tiff file in the received OutputStream
                JAI.create("encode", image, out, this.FORMAT_NAME, null);
    // my 1st JSP :page.jsp (to call the 2nd JSP witch have an other content type)
    <%@page
    contentType="text/html"
    language="java"
    errorPage="errorpage.jsp"
    import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
    %>
    <html>
    <head></head>
    <body>
    <IMG src=<%=request.getContextPath()%>image.jsp>
    </body>
    </html>
    // my 2nd JSP
    <%@page
    language="java"
    errorPage="errorpage.jsp"
    import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
    %>
    <html>
    <head>
    <%
        // pageToPrint is an instance of the class "Page" (getContentType ( ) give the String "image/tiff")
        response.setContentType(pageToPrint.getContentType ( ));
    %>
    </head>
    <body>
    <%
        ServletOutputStream bOut = response.getOutputStream();
        pageToPrint.write (bOut);
    %>
    </body>
    </html>

    You can get the Servlet to write an image out by changing the content type of the response object to "image/jpeg" and write the bytes of the image out down a ServletOutputStream you create from the response object.
    You must change the content type before you write anything to the response object. The servlet can only produce the image.
    I did it once but I've lost my code and am now trying to recreate it (I changed it to having a server app do the image processing and writing it to a socket which the servlet read the bytes from and wrote them to the ServletOutputStream but now want the servlet to do the processing).

  • Can't find how to create on-the-fly playlists using search

    I used to make ad-hock playlists on the fly using the quick search in iTunes 10:I would display a list of songs (the full library or from a play list), type somethings in the quicksearch box, and the list would narrow down to the search results, where then I could simply hit "play" and use these results as a temporary ad-hoc playlist.
    That features seems to be gone- even after getting iTunes 11 to LOOK like iTunes 10, typing any search term will show (partial) results in a drop down menu, not narrowing the display, and no option in a single click to simply play the results.
    Am I missing something? Did Apple really remove that functionality?

    Settings>cellular>cellular data

  • Is possible create in the contacts app, new groups, copy contact from one group to another group, and create in the business group, field to put the pictures of business cards. I think it would be a great idea, no?!

    App Store, Contacts App

    We are only other users here.
    Share the idea with Apple as feedback about the iPad;
    Apple Feedback
    http://www.apple.com/feedback/

  • Appending FLV files together on the fly

    I have a website that accepts video uploads. I then of a
    content management tool that always me to browse and uploaded
    videos and approve or deny them.
    For any I approve, I then convert the video to FLV, i then
    want the automated process on my site to append a cookie cutter
    trailer video to that uploaded video.
    so my question is, how to append one FLV to another FLV
    through code on the fly on the website?
    any help appreciated
    thanks
    bill

    hi,
    with fms you can create a serverside stream playlist using
    the stream object, this means you can interlace your trailer/advert
    to appear anywhere within the stream dynamically without needing to
    splice and reencode any videos you have.

  • SUM function for a column made 'on the fly'

    I have access to a database, however only SELECT statements can be run on the database. Basically the database lists switches, these switches can have up to 20 computers connected to them but some do not. I need to know the switches which contail less than 20 computers so I know where there is space for more computers (I've wrote the code for this already). I also need something to keep a tally/total for the number of spare spaces left so I can run the script and go 'ok we have a total of 20 spare places for computers theres 10 on this switch and 10 on this one'.
    I just need to get the sum funtion working for the column that I've created 'on the fly', the column revealing the number of spare slots, heres the code I've got so far:
    SELECT switch, COUNT(*) as "Servers", 20 - COUNT(*) as "Spare slots"
    from dedicated_servers
    where switch like 'rs%'
    GROUP by switch
    HAVING COUNT(switch) < 20
    order by Servers;
    Which gives the following:
    | switch | Servers | Spare slots |
    | rsj14-1.dc | 12 | 8 |
    | rsj12-1.dc | 15 | 5 |
    | rsi2-2.dc | 16 | 4 |
    | rsj13-1.dc | 16 | 4 |
    | rsi2-1.dc | 16 | 4 |
    Just need something at the end saying TOTAL=25

    OK I'll have to make em up though, but they are something like this for one switch:
    INSERT INTO dedicated_servers (switch, server_number, switch_socket)
    VALUES (rsj-1.dc, 100, 18)
    On switch rsj-1.dc there can be upto 20 servers (the server_number is the primary key)
    Message was edited by:
    slowpoke115

  • Can Access DRM encryption be applied on the fly?

    Hi,
    ... and thanks in advance for responding. I have the following questions:
    Can Access DRM-Core and Access DRM-Pro encryption be applied to a video file "on the fly" for RTMP?  (I'm not interested here in Access Protected Streaming)
    How about for HDS?
    How about for HLS?
    By "on the fly", I mean at the time the request was made from the client and as a prelude to the  response from the media server. This would allow us to avoid creating and storing an Access encrypted representation of the video in advance.
    Thanks!

    There are a couple ways to generate just the "DRM Headers" without having to encrypt the whole file.
    1. If you're an Adobe Broadcast Licensee, with access to our Broadcast SDK (HDKb), there are APIs in there to just generate the DRM Metadata.
    2. If you have a recent version of AMS, the f4fpackager tool that comes with the product has had a recent revision where you can update an existing F4M (manifest) file to include a new DRM Metadata, which is created on the fly.  I'm not sure if this new f4fpackager tool has been released yet in the latest AMS, however.
    Besides those routes, the only other way to create a DRM Metadata would be to package an entire video.
    cheers,
    /Eric.

  • Creating an SCD Type 2 in T SQL without using MERGE

    I am attempting to create an SCD type 2 using T-SQL without MERGE (I'm not allowed to use it as a condition of the development work I am doing). I can use a CTE, but I have not tried that yet.
    I have a temp table that contains ten records that I am testing with. The following is one variant of the code I have used to try and make this work:
    declare 
    @System_User nchar(50)
    ,@CurrentDate datetime 
    ,@MaxCheckDate datetime
    set @System_User = system_user
    set @CurrentDate = getdate()
    --INSERT
    insert dim.slot
    Source_Slot_ID
    ,Slot_Start_DateTime  
    ,Patients_PerSlot
    ,IsSlotSearchable
    ,IsSlotVisible
    ,[Created_Date]
    ,[Created_By]
    select
    src.IdSlot
    ,src.SlotDateTime
    ,src.PatientsPerSlot
    ,src.IsSlotSearchable
    ,src.IsSlotVisible
    ,@CurrentDate
    ,@System_User
    from #TmepSlot src
    left join dim.Slot dest
    on src.IdSlot = dest.Source_Slot_ID
    left join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
    on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
    and dest.Created_Date = MaxRecord.created_date
    where dest.Source_Slot_ID is null
    or
    src.PatientsPerSlot
    <> dest.Patients_PerSlot
    or
    src.IsSlotSearchable <> dest.IsSlotSearchable
    or
    src.IsSlotVisible
    <> dest.IsSlotVisible
    The problem with this variation is that when I change a value in the source like src.Patients_PerSlot, and then run the query, I get the new record i expect, but when I run the query again, a duplicate record gets created. 
    How do I correctly isolate the correct latest record and add the changed record without inserting that changed record more than once?
    Thank you for your help.
    cdun2

    Hi,
    shouldn't you use an inner join between dest and maxrecord like so:
    from #TmepSlot src
    left join (dim.Slot dest
    inner join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
    on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
    and dest.Created_Date = MaxRecord.created_date)
    on src.IdSlot = dest.Source_Slot_ID
    where dest.Source_Slot_ID is null
    regards,
    Rudolf
    Rudolf Swiers
    Thanks! I don't remember when I've done a join that way, but it makes sense.
    cdun2

  • Getting the output of two different sqls in analysis

    Hi,
    Please consider the scenario:
    I have to get the division value of two diffrent sqls in my analysis. The sqls will look like:
    1st SQL: SELECT DISTINCT <alias name1>.<col1>
    ,<alias name1>.<col2>,<alias name1>.<col3>,<alias name1>.<col4>
    FROM Table1 <alias name1>, Table2 <alias name2>, Table 3<alias name3>
    WHERE
    <alias name3>.<col2>= <alias name2>.<col2>    // joining condition
    AND <alias name3>.<col3>= <alias name1>.<col1>    // joining condition
    AND <alias name2>.<col1>= 'value1'
    AND <alias name2>.<col4>= 'value2'
    2nd sql: SELECT DISTINCT <alias name1>.<col1> FROM Table1 <alias name1>
    WHERE <alias name1>.<col4>= 'value2'
    The 1st sql has joining between 3 tables. and the 2nd SQL has no joining. whenever I drag and drop the columns with respect to the two sqls separately. it gives correct output. But it does not give me correct output when i try to do it together as all the tables are joined.
    The sql which works as 2nd sql is:
    SELECT DISTINCT <alias name1>.<col1>
    FROM Table1 <alias name1>, Table2 <alias name2>, Table 3<alias name3>
    WHERE
    <alias name3>.<col2>= <alias name2>.<col2>    // joining condition
    AND <alias name3>.<col3>= <alias name1>.<col1>    // joining condition
    AND <alias name2>.<col4>= 'value2'
    I need my 2nd sql to give me output without the join conditions of 1st sqls. how can I achieve this?
    Please help. I need it urgently.
    Thanks in advance..

    hi,
    I have tried by creating a separate alias for table1. But that is not working. alias is giving me joined output..
    Can you suggest me any other way to do it?
    Thanks

  • SAPINST hange creating database Web AS  640 win 2000 SQL 2000

    When I run sapinst to create a web AS 640 instance, the process hangs when creating the database tables. The message says (something like) "info: attempting to create BC_INDX_LOCKING table"
    When you look in SQL Enterprise manager, that table is there, and so are several others with later time stamps.
    When you look in MMC at the SQL logs it says the database has been 100% analyzed, which tells me the database is in fact completed.
    I've tried all sorts to overcome this so any help would be gratefully accepted.

    Hi Paul,
       Try deleting the database and run the SAPINST again. If it doesnt come up, please post the error in the trace file.
    Regards,
    Siva
    P.S: Award points if you find this useful.

  • Another site already exists at . Delete this site before attempting to create a new site with the same URL

    Hi Everyone,
    It would be great if you can help me with the below.
    Few days ago one of our content db went into suspect mode.  Our DB team had resolved the issue. But one of the sites that was created probably around the same time is no more available. When I try to create a site on the same URL, I get the following
    error.
    Another site already exists at <URL>. Delete this site before attempting to create a new site with the same URL
    When I try to delete the site or if I try to view the details of the site using Central Administration, I can find the site, but it doesn't display any details like Title, DB Name etc.
    If I use stsad -o enumsites command to list ll the site, for the given site I get the following error:
    <nativehr>0x80070002</nativehr><nativestack></nativestack>There is no Web named <URL>.
    I am not even able to delete it using Powershell.
    Please suggest.
    Thanks,
    Uttkarsh

    You might be dealing with orphaned site. Go through the following blog post and see if it helps you delete the orphaned sites.
    http://www.cjvandyk.com/blog/Lists/Posts/Post.aspx?ID=299
    Amit

Maybe you are looking for