Using the default values in INSERT INTO... SELECT...

Hello
I want to do after insertion in Oracle 10 g

INSERT
IN tab1
(
x 1,
x 2
)
SELECT
NVL (Y1, default)
Y2
Of THE tab2

but oracle throws missing expression error. I do not want to override the default values because it involves changing the code for any change of default. I guess Oracle transforms that SELECT tab2 while context, but is possible to carry out the INSET above?

Published by: ponn_raj on January 14, 2009 04:52

If you are going to need indeed a' by default-getter "function, I would probably go something like this."

SQL>  create or replace function get_default(p_table varchar, p_column varchar2)
   return anydata
is
   l_data_default_char    long;
   l_data_default_num     number;
   l_data_default_date    date;
   l_data_type            user_tab_columns.data_type%type;
   l_data_default         long;
   l_any                  anydata;
begin
   select data_default, data_type
     into l_data_default, l_data_type
     from user_tab_columns
    where table_name = upper(p_table)
      and column_name = upper(p_column);

    if l_data_type in ('CHAR', 'VARCHAR2') then
      execute immediate 'begin :1 := ' || l_data_default || '; end;' using out l_data_default_char;
      l_any := anydata.convertvarchar2(l_data_default_char);
    elsif l_data_type in ('NUMBER') then
      execute immediate 'begin :1 := ' || l_data_default || '; end;' using out l_data_default_num;
      l_any := anydata.convertnumber(l_data_default_num);
    elsif l_data_type in ('DATE') then
      execute immediate 'begin :1 := ' || l_data_default || '; end;' using out l_data_default_date;
      l_any := anydata.convertdate(l_data_default_date);
    end if;
    return l_any;
end get_default;
/
Function created.

SQL>  create table t (
   a varchar2(5) default '',
   b varchar2(5) default 'null',
   c varchar2(5) default null,
   d varchar2(5) default '''',
   e date default sysdate,
   f integer default 1+1,
   g varchar2(3) default upper('a')
 )
/
Table created.

SQL>  select column_name,
       get_default(table_name, column_name).accessvarchar2() c,
       get_default(table_name, column_name).accessnumber() n,
       get_default(table_name, column_name).accessdate() d
  from user_tab_cols
 where table_name = 'T'
/
COLUMN_NAME C              N D
----------- ---------- ----- -------------------------
A
B           null
C
D           '
E                            15.01.2009 22:14:51
F                          2
G           A                                         

7 rows selected.

Tags: Database

Similar Questions

  • Is it possible to use the default value as sql expression in obiee 11g report?

    Hi all

    Is it possible to use the default value as sql expression in obiee 11g report?. Actually what I'm trying to make is that we send an ibot users. They want the same default values that are assigned in the command prompt in the report. So when we send the ibot it shows the report for default values assigned in the report criteria which is obsolute. As a solution, I kept the report in a dashboard page and send the dashboard like ibot page. But the problem here is that I can send only pdf format. Is it possible to do so at the level of the report (without using session variables). I want something like that

    Date between Date ' @{PV1} {Timestampadd (SQL_TSI_DAY,-90, CURRENT_DATE)} and Date ' @{PV2} {CURRENT_DATE}

    Thanks in advance

    Thank you

    AJ

    http://www.w3.org/2001/XMLSchema-instance"container ="http://www.w3.org/2001/XMLSchema"xmlVersion ="201201160' xmlns:sawx="com.siebel.analytics.web/expression/v1.1" > "

    "Question time '." Date '.

    "Question time '." Date '.

    BOX WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 1) THEN TIMESTAMPADD (SQL_TSI_DAY,-2, cast (max (CURRENT_DATE) as date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 2) THEN TIMESTAMPADD (SQL_TSI_DAY,-3, cast (max (CURRENT_DATE) as date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 3) THEN TIMESTAMPADD (SQL_TSI_DAY,-4, cast (max (CURRENT_DATE) as date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 4) THEN TIMESTAMPADD (SQL_TSI_DAY-5 (, cast (max (CURRENT_DATE) date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 5) THEN TIMESTAMPADD (SQL_TSI_DAY,-6, cast (max (CURRENT_DATE) as date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 6) THEN TIMESTAMPADD (SQL_TSI_DAY, 0, cast (max (CURRENT_DATE) as date)) WHEN (DAYOFWEEK (cast (max (CURRENT_DATE) date)) = 7) THEN TIMESTAMPADD (SQL_TSI_DAY-1, cast (max (CURRENT_DATE) date)) END

  • How to use the default value of a column in a table in insert or upda

    Hello

    I try to use the values by default so that the user should not have to enter data, but when I select default type and a default, I see an error message if I try to add a new line.

    How can I use a default value to a column in a tabular presentation?

    Gouri

    Published by: user1046395 on April 3, 2009 09:58

    Gouri,

    You can change simply to attribute each report column. For example,.

    To set the default date.
    Default type: PL/SQL Expression of function
    Default: sysdate

    To set the default text,
    Default type: PL/SQL Expression of function
    Default: * "CLERK."

    If you still get an error, what is the error message?
    Tarraf

  • I can't have my Subvi simply use the default values for some of its entries?

    I use the code for a DS345 machine, using the sample code from here: http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E9149659CE034080020E748...

    I use version 7.0 (because I'm in 7.1).

    Anyway. I managed to get the proper waveform I wanted, just stored waveform in the default values and frequency input, so I can some frequency I want input. When I run the example VI itself, it displays the waveform for the machine just that very well, however, when I use this example VI as a Subvi, it didn't come out of the machine data.

    Any ideas?

    Thank you

    Edit:

    When I say defaults for some of its entries, I mean the values that are usually connected by a user, controls that are not 'inputs' in VI.

    I understood the question, and I must say that I am embarrassed. If you look at the code, I'm feeding a resource VISA name, when the Subvi needs just a chain with the GPIB address number.

  • Setting the default value for a dynamic selection menu

    Hi I have a php with 2 forms to this topic page, you feed on the other to achieve a lock down (manufacturer > model). The menu then select I have a static default value 'Select a model aircraft', I want to set a value for the first menu select dynamic to read "select the manufacturer. When I add a static value to my list, it tells me I alreay have a dynamic behavior on this menu and choose another. I've included the code for two menus. Thank you in advance, I know it must be a stupid question, but it has left me speechless.

    Tom

    This is the menu that I want to add static value defaults to.

    < td width = "667" > < select name = "airMake" style = "" width: 200px; "" OnChange = "This.Form.Submit (); "id ="airMake">

    <? PHP

    {}

    ? >

    < option value = "<?" PHP echo $row_rsAirManufacturer ['aircraft_manufacturer']? > "<?" PHP if (!) strcmp () ($row_rsAirManufacturer ['aircraft_manufacturer'], ((isset($_POST["airMake"]))? $_POST ['airMake'] :""))) {echo "selected =-'selected\'" ;}?})) > > <? PHP echo $row_rsAirManufacturer ['aircraft_manufacturer']? > < / option >

    <? PHP

    } While ($row_rsAirManufacturer = mysql_fetch_assoc ($rsAirManufacturer));

    $rows = mysql_num_rows ($rsAirManufacturer);

    If ($rows > 0) {}

    mysql_data_seek ($rsAirManufacturer, 0);

    $row_rsAirManufacturer = mysql_fetch_assoc ($rsAirManufacturer);

    }

    ? >

    < / select >

    < table >

    < /tr >

    < / table > < / make >

    < do action = "quoteResult.php" method = "post" name = "quoteForm" > "

    < table width = "100%" border = "0" cellpadding = "5px" >

    < b >

    < td width = "260" style = "color: #000;" text-align: right; "> aircraft model: < table >

    < td colspan = "2" > < span id = "spryselect2" >

    This is the menu that works properly.

    < select name = "airModel" style = "" width: 200px; "id ="airModel">"

    < option value = "" <? " PHP if (!) () strcmp ("", ((isset($_POST["airMakeField"]))? ") $_POST ['airMakeField'] :""))) {echo "selected =-'selected\'" ;}?} > > < / option >

    <? PHP

    {}

    ? >

    < option value = "<?" PHP echo $row_rsAirModel ['aircraft_model']? > "<?" PHP if (!) strcmp () ($row_rsAirModel ['aircraft_model'], ((isset($_POST["airMakeField"]))? $_POST ['airMakeField'] :""))) {echo "selected =-'selected\'" ;}?})) > > <? PHP echo $row_rsAirModel ['aircraft_model']? > select a model airplane < / option >

    <? PHP

    } While ($row_rsAirModel = mysql_fetch_assoc ($rsAirModel));

    $rows = mysql_num_rows ($rsAirModel);

    If ($rows > 0) {}

    mysql_data_seek ($rsAirModel, 0);

    $row_rsAirModel = mysql_fetch_assoc ($rsAirModel);

    }

    ? >

    < / select >

    -Change

    So if the value of "airMake" is - 1, you know that no choice has been made.

  • Use the default values of the parameters when calling FND_REQUEST. SUBMIT_REQUEST

    Hello
    I submit a program concurrent with FND_REQUEST. SUBMIT_REQUEST in pl/sql.
    The simultaneous program settings are attached to sets of value and have default values.

    I want to give these parameter values only, which do not have the default when sending the request of pl/sql.

    That doesn't seem to work. Is it possible that I can get the defaults settings kick when I submit pl/SQL?

    Thank you
    SITA

    Published by: user451773 on December 3, 2012 05:05

    Published by: user451773 on December 3, 2012 05:06

    You will have to code a "preliminary stage" for it... aka... a function that calls your conc.req.

    the FND_REQUEST. SUBMIT_REQUEST will ask you to provide all the necessary at the start of the conc.req parameters. It's also what happens when you start through forms. So, you will need to code something that checks the settings which are given by you and for those not given not check LOV configuration and query by default.

    This is how you can solve this problem. It will need an additional coding.

    Kind regards
    Johan Louwers.

  • ERR 126 cannot load "" DLBAPRP. "» DLL. Using the default values. This message keeps me from printing some forms of online sites.

    For example, when I do my banking online, it keeps me print my statements.

    This happens on other browsers? Please see http://support.microsoft.com/kb/918730 this should help with your problem.

  • Set the default value to select the list

    Hello
    I have a question about the page, which is a selection list
    And I have a LOV associated with this issue, which is a database query.

    How one of the values of this LOV to a default value of this selection?
    I need this value that appears first, instead of a Null value.

    Thank you!

    That's right - use the default value of your definition of the element box.
    Take a look at this post:
    Re: previous option selected as default

    Maybe you will find it useful...

  • How to select the default value for a choice of selection when page.jsff load

    Hello everyone, I am newbie have little problem

    I have problem with soc (selectOneChoice)
    in this case I ' to select the default value of af: SelectOneChoice (select first selectItem) when the page is finished loading

    < af:selectOneChoice label = "" Jenny Bahan: "id = 'soc1'"
    autoSubmit = 'true '.
    valueChangeListener = "#{WHStockSetReleaseBean.cekJenisBahan} '"
    Binding = "#{WHStockSetReleaseBean.v_jenisBahan}" >
    * < af:selectItem label = "GBB" value = "GBB" id = "si2" / > * = > i'want to select this value for the default (select first selectItem)
    < af:selectItem label = "GBP" value = "GBP" id = "si1" / >
    < / af:selectOneChoice >

    If someone help me to solve this problem

    THX
    agungdmt

    Hello

    try to set the attribute value to af:selectOneChoice like that.

    
    

    Kind regards
    Sicard.

  • Application of interactive report of apEx using the last value of the point

    My interactive report is based on a field, but the value of the field is not applied when executing the query

    SELECT *.

    MyTable FROM A

    where A.registration_year =: REGISTRATION_YEAR_ITEM

    I created an item in the page REGISTRATION_YEAR_ITEM

    When I run the query, I want the user to type in a year, and then run the query and display the corresponding results.

    The query always seems to use the default value of points instead of the current value

    How can I do use the value of the current field?

    I also tried the V method, but produce the same results

    where A.registration_year = v('REGISTRATION_YEAR_ITEM')


    The environment is ApEx 312, 10.2.0.4 database

    Unfortunately, the upgrade is not an option


    Thanks for any help you can offer

    S.Bovin wrote:

    My interactive report is based on a field, but the value of the field is not applied when executing the query

    SELECT *.

    MyTable FROM A

    where A.registration_year =: REGISTRATION_YEAR_ITEM

    I created an item in the page REGISTRATION_YEAR_ITEM

    When I run the query, I want the user to type in a year, and then run the query and display the corresponding results.

    The query always seems to use the default value of points instead of the current value

    How can I do use the value of the current field?

    Add the REGISTRATION_YEAR_ITEM to the IR Page elements to submit property. He will submit the current value in session state.

    Why bother with the page element at all? Why users can't create just an IR filter?

    I also tried the V method, but produce the same results

    where A.registration_year = v('REGISTRATION_YEAR_ITEM')

    For performance reasons, use bind variable notation when you reference values from session state in SQL queries.

    The environment is ApEx 312, 10.2.0.4 database

    Unfortunately, the upgrade is not an option

    Why not? That it will provide you with a safe and supported environment and your users with a much better life.

  • Values are inserted into a SQL PL table to a database table

    Hello

    Here's my dilemma.

    I have values inserted into a pl sql table which I have collected from a web page. Now, I need to add these values in a database table. I see the values as 1-'AA', 2 = 'BB' etc.

    I use the following code to insert into a table outside in the database, and it seems to be crashing.

    for me in app_table.first... loop app_table. Last
    r_convention (i) .priority_country_code: = app_table (i);

    insert into test_countries
    values (test_seq, tion (i) .r_convention (i) .priority_country_code);

    commit;

    end loop;
    When I run this code, I see the values. But he goes to the first value and then crashes and does not pass by the
    the rest of the values. What I'm missing here?

    Thank you!

    and move the validation outside of the loop :-)

  • Default values for Insert and Update

    What is the default way the current sysdate to a date on one column table when you perform an insert or update via a form? And related to this, what is the best way by default of the current user (APP_USER) for a varchar2 column when you perform an insert or update via a form?

    For these columns, I want to display in a report, but they must be hidden on the form, because I have the default app to sysdate and APP_USER values. However, when I tried to use the default values in table in 'the default UI settings' and using either: APP_USER or & APP_USER or SYSDATE, it shows that this literal value on the form (element is not hidden while to debug it). It does not show the actual value, I would, like "user1". Does make sense?

    Thanks for your help.
    -Reid

    I think that the triggers are the best device.

    Scott

  • Why print does not use the default printer?

    I have two main printers to use at home and whenever I print a web page, Firefox will automatically print using the default printer. If I select the default printer from the drop-down list, it works very well. I wouldn't select the printer by default every time I want to print.

    Try of the reset described here for print.print_printer preference:

    http://KB.mozillazine.org/Problems_printing_web_pages#Reset_printer

  • How the values to insert into the table with the command insertion

    Dear all
    can someone tell me how the values to insert into the table with the command insert, I want to say I always use command insert behind my forms on what shutter release button press the button of my save, but today I had a form of 6i, where controls (textbox, combo, etc.) are delineated with directly the table with I guess than the Properties Windows , I created 3 columns in tand 3 text on forms fields, now kindly tell me how to do this fields to fill and do not insert command, I mean directly defined with table column



    Please help me its urgent

    Hello

    If the block is based on your database table, just committed the shape, then changes will be applied to the database.

    François

  • How to set the default value in the select list to cascaded

    Hello
    I use Denes Kubicek cascade example list of selection http://htmldb.oracle.com/pls/otn/f?p=31517:119

    And I want to give cascading the selection list with a default value. So, anyway, I use this application process:

    < pre >
    BEGIN
    OWA_UTIL.mime_header ("text/xml", FALSE);
    HTP.p ('Cache-Control: non-cache');
    HTP.p ('Pragma: non-cache');
    OWA_UTIL.http_header_close;
    HTP.prn ("< select >");
    HTP.prn ("< option value ="' | 1 |) "" > ' | '- all employees-' | ' < / option > ");"

    FOR c IN (SELECT ename, empno
    WCP
    WHERE mgr =: cascading_selectlist_item_2)
    LOOP
    HTP.prn ("< option value ="' | c.empno |) '">' || c.Ename | ("< / option >");
    END LOOP;

    HTP.prn ("< / select >");
    END;
    < / pre >

    How can I select for example empno default 1000?
    Thanks in advance.
    Jacob

    Jakob,

    In this case, your default value is

    HTP.prn (')

    However, you can set the default value in the loop as you want. You just say that is your default - first, second, third...

    In the list select ajax there's no submit and no calculation of values then I assuem your default is the punch one you wan to display when a selection list has been changed?

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for

  • Best alternative to Photoshop for iPad Pro?

    I am a print and web designer and I just bought an iPad Pro. IM has decided to try to work only on my projects using my new iPad Pro for the next few days. Certainly, it should not be a replacement for my iMac, but I want to give it a try. I notice t

  • Update iOS 9.3.2 - password iCloud could not recall

    Since the update to iOS 9.3.2 my iPad keeps asking my iCloud/Apple ID password.  After having put in it, it makes me enter my recovery key and set a new password.  This was repeated atleast doing times so far.  Is that what the problem of ideas? Than

  • Pavilion g6 - 2217cl: the HP Pavilion g6 - 2217cl RAM and CPU/GPU upgrade

    Hey there, I am looking to upgrade the RAM and CPU/GPU on my G6 Pavilion. Here's my current characteristics; Laptop model: HP Pavilion G6 - 2217cl Operating system: Windows 10 family (x 64) Current RAM: 6 GB (used 2 slots) CPU/GPU: AMD A8 - 4500 APU

  • Error code 606

    I get an error trying to update

  • Cannot view the files on a flash drive from a Mac on a PC with Vista.

    Hello my friend put files of photos and music on a USB mass storage. She has an apple mac and I have windows vista on my pc. WHN I plug in the USB on my computer that nothing comes. What can I do so that I can view and use the files. some tips would