by default conditional value
I have the 'players' table like this:with Players as
(select 1 Code, 0 Flag1, null Newfield from Dual
union
select 2 Code, 1 Flag1, null Newfield from Dual
union
select 3 Code, 1 Flag1, 5 Newfield from Dual
)
select * from Players
/*
1 1 0
2 2 1
3 3 1 5
*/
;
I want to achieve depending on the needs:"1. if" Players.flag1 "= 1 then the default value for the Newfield column must be '4'."
2. If "Players.flag1" <>1, then by default the column value that Newfield does not exist, it may still be empty, whatever it is.
3. the triggers are not allowed to use because the architect of database does not allow them.
How can I get this conditional default value to be put on the table?
Note that this code is not correct:
ALTER TABLE Players MODIFY NewField DEFAULT 4;
Because he always sests default value in the NewField, which is not correct. We only want the default 'Flag1' = 1.It seems that we are not allowed to use this grammar:
ALTER TABLE Players MODIFY NewField DEFAULT 4 when flag1=1;
or
ALTER TABLE Players MODIFY NewField DEFAULT decode(flag1, 1, 4, null);
If you are 11g you can do this. You can create a virtual column that calculates the value for you.
create table players
as
with Players as
(select 1 Code, 0 Flag1, null Newfield from Dual
union
select 2 Code, 1 Flag1, null Newfield from Dual
union
select 3 Code, 1 Flag1, 5 Newfield from Dual
)
select *
from Players
/
alter table players add NewField_v number generated always as (nvl(newfield,decode(flag1,1,4,0,null))) virtual
/
select * from players
/
Version earlier than 11 g the best way would be a trigger. If you can use that you may consider to create Insert and Update API for this table and put your logic to this. But you must make sure only this API is used to insert and update in your table.
Tags: Database
Similar Questions
-
Is it possible to have scrolling enabled as a default condition?
Is it possible to have scrolling enabled as a default condition?
Hi alantbatdd,
You can restore the last display settings when opening the document in the menu Edit-> preferences-> Documents.
However if we look at a preferences defined in the particular document your setting will be overridden by preferences look a defined by the PDF Creator.
Kind regards
Nicos
-
How to clear the interactive element of default search values
Hi all
I have the page with interactive report, I'm passing a vulue to point the APEX by clicking the link Edit on the same page. The article must display information about clickiing button change.
I need to erase the question if I'm looking for something on the interactive report. If pages refresh the matter clear, but the default interactive value research work on Ajax call. Give suggestion.
Thank you
NrHello
You need set item value? You can set the IR filter in URL
http://docs.Oracle.com/CD/E23903_01/doc/doc.41/e21674/bldapp_rpt.htm#sthref1344If that does not match your need to create a process to clear the Cache for items at the point of process On Load - footer after
Kind regards
Jarihttp://dbswh.webhop.NET/dbswh/f?p=blog:Home:0
-
Hi guys,.
I have a report with a form. When the user clicks on the button change the appropriate database value for a line should appear in the form field. However, when the user clicks on the button create the database field should be filled with the last value entered into the database by this user. To do this, I have the columns to insert the date and the person (the user that inserted).
The following query works and returns the value required in SQL Workshop:
How can I include this in application? I tried to create different processes and calculations but I either get no display value or a certain shape error (for example ' select' word found that she dislikes). With all these I charge before regions, headers or after the headers.SELECT DATABASE FROM TBL_ENV_LOG WHERE PERSON = :APP_USER AND INS_DATE = (SELECT MAX(INS_DATE) FROM TBL_ENV_LOG WHERE PERSON = :APP_USER);
I created the following function which works too:
and he tried to do "select database_value(:APP_USER) from dual" as he worked in the workshop also, but not luck. Ideas?create OR REPLACE function database_value(p_user in VARCHAR2) return VARCHAR2 IS db VARCHAR2(50); cursor c1 is SELECT DATABASE FROM TBL_ENV_LOG WHERE PERSON = p_user AND INS_DATE = (SELECT MAX(INS_DATE) FROM TBL_ENV_LOG WHERE PERSON = p_user); BEGIN for c in c1 loop db := c.database; end loop; return(db); END;
MikeMike,
>
The following query works and returns the value required in SQL Workshop:
SELECT DATABASE TBL_ENV_LOG
WHERE NO =: APP_USER AND INS_DATE =
(SELECT MAX (INS_DATE) FROM TBL_ENV_LOG WHERE NO ONE =: APP_USER);How can I include this in application?
for "datebase article", "default" section, value "default value" as "PL/SQL function body" and put the following code
DECLARE -- change type to your database type v_dummy VARCHAR2(100) := NULL; BEGIN SELECT DATABASE INTO v_dummy FROM TBL_ENV_LOG WHERE PERSON = :APP_USER AND INS_DATE = (SELECT MAX(INS_DATE) FROM TBL_ENV_LOG WHERE PERSON = :APP_USER); RETURN v_dummy; EXCEPTION WHEN OTHERS THEN RETURN v_dummy; END;
See you soon,.
Hari -
I hv created two paintings.
1 > we have the default value of the column
2 > there is no default column values
in which the table insert will be faster?Hello
Test and measure and display the results of the tests, I wouldn't just take a statement like "default values are faster" for granted.
Default values are used to improve the modeling/application of the rules of business etc. in the first place, their primary use is not because of the performance. In addition, it is all documented (of course):
http://www.Oracle.com/pls/db102/search?remark=quick_search&Word=default+column&tab_id=&format=ranked
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:12719076179764
-
Hi all
Apex 4.0
In my data entry form page.
I have P2_DATE_CREATED. How can I set a default value to it as 'SYSDATE '?
I have P2_ORDER_NUMBER. I want to be in default, by selecting a sequence number > select nextval (order_seq) in: double P2_ORDER_NUMBER;
How do I achieve this thing please... Thank youHello
Subordinate the calculation:
Go to the calculation-> Condition Bugfix
Condition Type: Article 1 of the Expression value is NULL
Term 1:Kind regards
Kiran -
Problem in creating a default calculated values for fields
Hi all
We have a requirement in the field of product put in place where there are 5 fields say A - E, in which the values of the 3 fields depend on each other as following rule
-User between the values of the fields A and B
-Now the values of C, D and E are calculated as follows:
-C = A + B
E = C * D
We tried to apply it to help provide the calculation of the default values, but it does not work.
Is it because these values are calculated only when a new record is created and the values of C and D are not ready at this time here.
Please help us
Thanks in advanceHi, if the values of the dependent fields are entered by the user, then the calculation for calculated field can happen only "Save" on condition that you checked the box "Default Post" in the definition of calculated field. There is no functionality available as real-time calculation and when the user has entered the changes on the dependent fields
-John CRMIT
-
[Forms10g2] In Enter Query mode default element value
Hello!
How can I specify the default value for an item in Enter Query mode? For example I press KEY-ENTQRY, and: L_YEAR point gots year by default search condition (although this may change). I tried to implement in this way:
< pre >
Enter query;
: l_year: = extraction (year sysdate);
< / pre >
This work in a rather clumsy manner. If I run this once (for example due to a hotkey press), happening just in Enter Query mode, but if I run it twice (by pressing shortcut twice), it fills: variable of the year and with her search as a search condition! Then I tried to go straight and wrote:
< pre >
Enter query;
: l_year: = extraction (year sysdate);
Enter query;
: l_year: = extraction (year sysdate);
< / pre >
Well, it did work. And SYNCRONIZE appeal before the second entry-query did not help either. So, my questions are: 1) how can I achieve necessary behavior? (2) what is happening in my experiences? Why: L_YEAR is affected on second keypress (as in the first experiment), but not on the second subsequent call (as in the second experiment)?
Thanks in advance!I don't know why this does not work, but I have something that might:
trigger a times-news-record-instance:
if :system.mode = 'ENTER-QUERY' then :l_year := extract(year from sysdate); end if;
It is always best to use the block and the point of names... : block.l_year
-
I was wondering if I could clean up my old FF of database/values.
Can I set all settings by default in: config without any problems with my Add-ons?
How can I fix: default config?
Do you have other tips to make my cool FF as new without exporting all my data and then reinstall everything?Thank you!
You can delete the prefs.js file in the Firefox profile folder to reset all default prefs and start from the beginning to make changes.
- Help > troubleshooting information > profile directory: see file
-
I chose an option that has replaced "bookmarks" from the menu with the most visited, commissioning and the latest headlines. I have to go back to the default value, simply "bookmarks" How do I do this?
Don't see the menu bar not (File, Edit, View, history... (Help)? Hold down the key (key in OSX) and press the following letters in this exact order: V T M
The bar of menus must now appear permanently, unless you turn it off again (view > toolbars). Turn on/off the menu bar is a new feature in version 3.6.
See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missingSee the other toolbars under view > toolbars. By clicking on one of them will place a check mark (display) or remove the check mark (not shown).
To display the status bar, view, and then click status bar to place a check mark (display) or remove the check mark (not shown).
Mode full screen
http://KB.mozillazine.org/netbooks#Full_screenSee also:
Back and front toolbar buttons or others are missing
Customize controls, buttons, and Firefox toolbars -
I have a Sub VI that I use to launch a panel where he made a few selections, then made hits. What is happening inside a while loop. I took the associated Boolean value the while loop and it connected to the output of the Sub VI.
I use this subroutine inside my main VI VI, and what I'm trying to do is to hide the front panel of the VI main until the user presses 'Done' on the Sub VI.
The problem is that even though I explicitly set the value of the Boolean false inside an imposing flat sequence, there always seems to be initialized in my main VI. I say this because I put a probe and it simply says "Not executed" until I press the fact, how it becomes true. I expect what follows 'false' until I pressed 'done '.
I looked through the forum here and have also tried to set its default value with LabView, both without success. If anyone can help?
I have attached the VI Sub, and a picture of how I use it in the main VI.
Thank you
Stream!
Your loop where hide you the front panel are not even starting to run your sub - VI has not completed. You need to hide the front before you start your Subvi. Then when your time strand begins, it will take place either once if the Boolean value coming is eternally true, or to run if the value Boolean false.
In addition, there is no reason to hide the front panel in a loop structure. You're going just to hide several times as fast as your processor will allow (then it would only do once or forever.)
I recommend you watch the LabVIEW tutorials online
LabVIEW Introduction course - 3 hours
LabVIEW Introduction course - 6 hours -
Target platform by default the value of Visual Studio 2010
In Visual Studio 2010, how can I set the default target platform for new projects to x 86? For some models, which already seems the case, but for example for the class library Visual Basic, the default value is Any Cpu and even can not be changed.
Where I can centrally define that all projects should be directed to the x 86 platform?
This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)* -
Views of Oracle with parameter with default input values?
Hello
As in procedures, can we have a view of oracle which takes the parameter and if the calling routine does not pass the required number of parameter which can be set by default in the view. Thank you!
1 SYS_CONTEXT - if I store the value of this variable, it will be specific session.
What "variable" are you talking about?
'CONTEXT' is NOT a variable - is a data region that contains the pair name = value.
Contrary to what the other answering machine says that the context variables are "session specific" or not depends on how you create the context. You can create the specific context of the session (by default) or a GLOBAL context. Data in a global context is SHARED by all sessions of the Forum.
See the diagram of CONTEXT to CREATE the syntax and description in the Oracle documentation
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_5002.htm
ACCESSIBLE WORLDWIDE
This clause means that any context of the defined application
namespace
is accessible throughout the entire instance. This setting allows multiple sessions to share attributes of request.Aware that ALL the VALUES returned by a context using SYS_CONTEXT (see the function description in the documentation of the SQL language) are STRINGS.
Make sure that you do NOT rely on implicit conversions when the context data items using a DATE value stored in a string.
-
APEX 5: Dynamic Action do not run on DEMAND Condition = VALUE
After migration from APEX to APEX 5 dynamic action 4.2.5 which performed in 4.2.5 won't work in 5 APEX.
Event DA: BEFORE the PAGE is SENT
Condition: Ask = value
Value: SAVE
Page contains the button SAVE, in the debug REQUEST window appears like SAVE, but DA does not occur.
When the condition is not defined, DA works correctly in the APEX 5.
Is this a bug in 5 APEX?
Hey Bozo,
Bozo says:
How to have this in mind, can be made to run before Page submit DA specified button click?
It depends on what you want to achieve a click of button and what you want to achieve with DA.
The purpose of the button and DA can be combined in a javascript function or in the DA himself.
How this can be achieved in the DA itself is:
- Instead of shooting the DA "before submit Page', fire the DA to the click event of button. (to do this change the button action to listen for events from DA)
- In the first real action, run everything you want to achieve with DA.
- Write another real action, to submit the page and set the application to any value you want. (ensure that the processes we submit are conditional on the overall application, instead of the State of the button)
Kind regards
Kiran
-
By default a value of sysdate in a single field of view
Hello
The requirement is by default the sysdate within a single field of view say 'a' with the data type date
When re - polling also, the same day must appear what we have stored in the database.
Please suggest inputs for this
Thanks and greetings
Make the point a 'normal', not a displayed element and set insert_allowed and update_allowed to false.
Set this date only the "Initial value" property to "$$DBDATE$ $" or "$$DBDATETIME" for the date and time.
Maybe you are looking for
-
Why can't the Web icon for some of my saved favorites
A lot of my saved favorites have their correct Web icons.However, many fail to save their Web icon leaving the icon of the Virgin.The Web Sites in question have specific Web icons.I tried to delete the bookmarks in question and the recording of their
-
How can I add folders in outlook? When I try to add a folder, an error message says, the connection to the server is unavailable. Outlook must be online or connected to complete this action.I'm online, and I do not have a server, confused! Anyone kno
-
indicator problem ListView and activity
Hi, I was playing around with the sample application address book so that I have included a button to re-populate the list view. It takes a few seconds, that's why I've included an indicator of activity runs while the list view is being filled. The a
-
Hi BB family, I just made the switch to Z10. For some reason I can't save my downloads on my SD card. What I need to change a setting, or is there something more than that?
-
How to reinstall Windows 8 with the upgrade product key
I bought a Windows 7 laptop and then bought the upgrade of Windows 8. on the online store of Windows. The hard drive of the laptop has been altered somehow and both the partition of Windows 8 and Windows 7 recovery partition no longer works. When I t