View with a column that is derived from a function
We can create a view with a column being filled using a pl/sql script, which uses 2 other columns on the same line as input?Example,
Let's say I have a vision with
Reg. Don't | Total | Customer account | Flag of billing. CodeFn
$1234 45 2109 Y < value in this column would be what returns the expected script pl/sql, after using the Reg # (1234) and Total (45) as entries >
$1236 15 2101 Y < input values would be 1236 & 15 >.
Basically, I would like the script to generate a number that is returned in this column rather than do a simple Select stmt to extract columns from other tables/views.
Edit: The point of view does not display right... Here is a picture
view
Thank you!
Published by: jess_saunders on May 8, 2012 14:05
Hello
jess_saunders wrote:
We can create a view with a column being filled using a pl/sql script, which uses 2 other columns on the same line as input?Example,
Let's say I have a vision withReg. Don't | Total | Customer account | Flag of billing. CodeFn
$1234 45 2109 Y
$1236 15 2101 Y.
Of course, you can use a function that you created in the same way that you would use a built-in function:
CREATE OR REPLACE VIEW view_x
AS
SELECT reg_no
, total
, customer_account
, billing_flag
, my_function (reg_no, total) AS codefn
FROM table_x
;
You cannot reference the procedures or anyonymous blocks in a CREATE VIEW statement (or any other SQL statement of stinks); only functions.
Basically, I would like the script to generate a number that is returned in this column rather than do a simple Select stmt to extract columns from other tables/views.
I don't know what you're saying here.
As long as the function has no arguments, or make any kind of DML or DDL, then you can use it in the definition of the view, as stated above. The function failed to contain SELECT statements.
Your notice must be based on other tables or views. If she does not really need anything from any other table, you can base your opinion on double. A CREATE VIEW statement must contain a query, and a query in Oracle must refer to a table or a view.
Tags: Database
Similar Questions
-
Hi all!
I'm using Labview 8.6, but the file is saved in labview 8.5.I'm almost done with this mission, but I can't understand how to draw a tangent line at the top of the chart with the derivative of the function.
Can someone help me please?
Thank you
LabVIEW file:
Analysis of the assignment:
Hello
here a solution how to add Ct to C
Concerning
Tinnitus
-
Create a view with a column change journal
Hello
I have the following table:
create table test1)
number of site_number
date of change_date,
number of area_ha);
insert into test1 values (1, TO_DATE('1/1/2007','DD/MM/RRRR'), 20);
insert into test1 values (1, TO_DATE('1/1/2008','DD/MM/RRRR'), 30);
insert into test1 values (1, TO_DATE('1/1/2009','DD/MM/RRRR'), 25);
insert into test1 values (2, TO_DATE('1/1/2007','DD/MM/RRRR'), 50);
insert into test1 values (2, TO_DATE('1/1/2008','DD/MM/RRRR'), 60);
insert into test1 values (2, TO_DATE('1/1/2009','DD/MM/RRRR'), 60);
insert into test1 values (3, TO_DATE('1/1/2007','DD/MM/RRRR'), 20);
insert into test1 values (3, TO_DATE('1/1/2008','DD/MM/RRRR'), 25);
insert into test1 values (3, TO_DATE('1/1/2009','DD/MM/RRRR'), 30);
What I want to do is to have a view based on the table above which includes a column of change (change_log below) based on the anterior surface (area_ha) for each specific site_number. For example in the first line site_number 1 has increased the area of 20 hectares on the 01/01/2007 to 30 hectares on the next change_date for this site that 01/01/2008. How this could be done?
SITE_NUMBER CHANGE_DATE AREA_HA CHANGE_LOG 1 01/01/2007 20 NO CHANGE 1 01/01/2008 30 ADDED SPACE 1 01/01/2009 25 DELETED DOMAIN 2 01/01/2007 50 NO CHANGE 2 01/01/2008 60 ADDED SPACE 2 01/01/2009 60 NO CHANGE 3 01/01/2007 20 NO CHANGE 3 01/01/2008 25 ADDED SPACE 3 01/01/2009 30 ADDED SPACE I am using oracle 11g R2
Select site_number,
change_date,
area_ha,
sign of case (area_ha - lag(area_ha,1,area_ha) over (partition by order of change_date site_number))
When 1 "AREA ADDED.
When-1 then "ZONE DELETED."
Another 'NO CHANGE'
end change_log
of test1
order of site_number,
change_date
/
SITE_NUMBER CHANGE_DA AREA_HA CHANGE_LOG
----------- --------- ---------- ------------
1 1 JANUARY 07 20 NO CHANGE
1 1 JANUARY 08-30 ADDED SPACE
1 1 JANUARY 09 25 DELETED AREA
2 1 JANUARY 07 50 NO. CHANGE
2 1 JANUARY 08 60 ADDED SECTOR
2 1 JANUARY 09 60 NO. CHANGE
3 1ST JANUARY 07 20 NO. CHANGE
3 AREA 1 JANUARY 08 25 ADDED
3 1ST JANUARY 09 30 ADDED AREA9 selected lines.
SQL >
SY.
-
Definition of the erroneous view importing view with text column expression
Hello
I use SQL DM v 3.3.0.744.
When importing a view designer and the column has a column expression, a frowned upon request is created.
Example generated by the designer:
CREATE OR REPLACE FORCE VIEW VIEW6
+ (COL1) +.
AS SOME substr (col1, 55, 1)
OF TAB1 T1
The following text is generated by DM:
CREATE OR REPLACE VIEW VIEW6 (COL1)
IN SELECT
COL1 COL1;
The following remarks:
-l' column expression is not repeated.
-the underlying table/view is not included.
Can you trigger a bug for that?
JoopHi Joop,
Can you trigger a bug for that?
Our knowledge of the designer is limited, so it's better create you a service request and describe how you created this view and/or provide an example in the form of exported the repository designer example.
Maybe that's the best export to do as a text file.
The same applies for this Migration of Designer: bad alias for the table/view used in viewsPhilippe
-
How to create a table with a column that is the value in another table?
Hi all,
It's my first post n I changed my ODI of DATASTAGE platform. Help me friends n I know basic steps in 11 ODI version which I was training in my company. I hope to have your support and can do everything an action ODI related documents.
My question is...
Table T1 > > > > > > > > > >
service id / / / attr.name / / / attr.value
S1 / / / product_code / / / P1
S1 / / / provider / / / pro1
S2 / / / product_code / / / P2
S3 / / / provider / / / pro3
Table T2 > > > > > > > > > > > > > > >
ID / / / product_code / / / provider
S1 / / / p1 / / / pro1
S2 / / / p2 / / / nullvalue
S3 / / / nullvalue / / / pro3
I have a table T1 since I should show the table T2 is released. Can we say everything on how to write a logic and steps to follow.
Thanks in advance.
Published by: 854662 on April 26, 2011 01:59Hello
U go.
1 the interface:
"Put a filter in your 1 on attr.name = array ' PRODUCT_CODE.
In the map target TABLE2
SERVICE_ID = TABLE1. SERVICE_ID
PRODUCT_CODE = TABLE1. ATTR_VALUEUse SQL IKM append control
Interface 2:
"Put a filter in your 1 on attr.name = array ' PROVIDER '.
In the map target TABLE2
SERVICE_ID = TABLE1. SERVICE_ID
PROVIDER = TABLE1. ATTR_VALUEDo SERVICE_ID as KEY (when you click the column target in properties, you can see KEY under properties of the target column) and use the incremental update of the IKM Oracle.
PS: I assume that Oracle as the source and target.
And you can refer to the documentation,
https://Apex.Oracle.com/pls/Apex/f?p=44785:24:4413167952886630:no:24:P24_CONTENT_ID, P24_PREV_PAGE:5185, 29
http://odiexperts.com/
And of course this OTN.
Thank you
Guru -
When you use a viewer with thumbnails widget that the viewer disappears
When you preview in multiple browsers Safari and firefox slide show disappears and runs on a colored background. AutoPlay does not work... This widget is provided in the muse...
Noises of this is exactly how the Lightbox widget is suppose to work. Any display of the page should show only thumbnails and then clicking on a thumbnail should open some sort of pop up with the image. There is no automatic reading with a lightbox widget.
-
Derived from the existing columns
Hello
How to create a new column that has derive data from another table on this logic:
Table A
Name identity
1 dsf
2 homeless
3 SDS
Table B
ID name tableA_ID
1 dd 1
2 of 2
I added another column in table A in desperation to denormalize our data and didn't need to make a join to table B
ID name tableB_name
1 SD dsf
2 sdf of
3 SDS
basically just try to merge 2 tables with a 1-1 relationship. I tried to fill in the data of table B in A, but by making an inner join and when I query the data, does not return a row ID 3 in table a.In model MDB make outer join. Make sure that you select next outdoor table.
Score pls correct/good
-
Create table works, create materialized view only - long column names?
Hello.
I have no probs creating a table as well: -.
CREATE TABLE blah
(
DEVICE_ID
)
in select
"Device_ID" AS DEVICE_ID
"of"sum" Device"@ed_link_3
where "Device_ID" < 5;
But when I try to create a materialized view:
Blah1 CREATE MATERIALIZED VIEW
(
DEVICE_ID
)
< various materialized view parms >
in select
"Device_ID" AS DEVICE_ID
"of"sum" Device"@ed_link_3
where "Device_ID" < 5;
It fails with errors: -.
ORA-04052: error occurred when searching to the top of the remote object Aggregate.Device@ED_LINK_3
ORA-01948: length of the name of the identifier (31) exceeds maximum (30)
Is there a way to get around this?
Is the problem with the columns of the remote table of device, which I do NOT need to import to have column names that are longer than 30 characters?
For now, I want only the Device_ID column which is a simple 9 characters long.
Oh, and the remote database is MySQL.
I'm uncomfortable with the < parms of materialized view > as they work fine when I choose a different remote table with only short column names.
Thank you.To my knowledge, you have the option
(a) create view (with shortened column names or only with desired columns if they are already less than 30 char limit) side of mysql
(b) use dbms_passthrough to force the analysis to be done on mysql (as in the example provided by SY here use dbms_passthrough to create a view )
However, I prefer to stick to one), because with dbms_passtrhough, you retrieve row by row.Best regards
Maxim
-
While talking with a friend, he told me that sometimes he uses tables with 300 columns that will be available only once for the extraction of information. For me, it's a little strange because 300 columns looks like a large number of columns for me...
Have tables with columns as is common practice in the data warehouse? If Yes, can you explain to me on what situations, this can happen and how often?
ConcerningWe have tables with columns of cca 150.
You should know that we don't talk to relational systems which are standardized. Its common practice when building data warehouse. Number of columns in the tables will depend on the complexity and the size of your warehouse and the number, size and complexity of your source systems.
Point is that even now, when the data warehouse is "done", we still add/remove columns changes to warehouse such as changing the source systems.
-
ORA-01481 when we click on the report with link column.
Request Express 3.1.0.00.32
I have a sql on a form page report with a column that clickable allowing the end user to quickly change the values.
I seem to have is because there is a mask of format on the column ($1234,56) I get the error
Googling the error came up with "check your manual.ORA-01481: invalid number format model Unable to fetch row.
Under format of date column / number, I'm using the following:
The column in the database is number (15.2)FML999G999G999G999G990D00
The only value I'm passing is the pk_id which is present in the case of the URL:
Anyone had this problem and if so found a work around?http://...f?p=293:2:3616213833707847::NO::P2_PK_BUDGET_ID:1
Thank you.Leland,
The error was caused by apply you the mask of YYYY format a number field. I changed a switch of dates for a list of selection and gave you an LOV query that would give you the current year, the last 3 years and the next two years. You can adjust that, according to the needs. I also put the definition LOV to accept other values incase you had a value in the db that was not in the LOV I've defined.
-
I have a pdf form that has 4 columns, with each column having 28 check boxes and text between. I did so he goes by column, but when I do anything for a checkbox it takes it out of line. How can I keep that from happening?
You talk about the tab order? If Yes, go to Edit - Preferences - forms and make sure the box "Automatically adjust tab order when changing fields" is NOT checked.
-
I recently published my muse built the Business Catalyst site for preview and all from the 'Site in the web browser view' function in the program of the Muse does not work. Screen comes up with a message that it cannot locate the page and suggests I check the ip address.
Hello Jimw93000314,
Are you preview site in the edge browser? When you preview the page in the browser Muse create a local server to give you the preview in the browser. With the edge browser, there was a reported issue to access the local server.
Please click the link below that shows the steps to enable the browser to edge.
I'm sure this will help.
Kind regards
Vivek
-
Create the view with the dynamic from clause
Hi all
you might have some ideas to help me out of my problem I just "created myself" ;-)
I have an unknown quantity and not constant of the tables using the same structure of the table and I have a main table
that contains all the names of these table types. Now, I want to create a unique view that contains all the columns in each table
and an extra column name containing the name of the corresponding table.
I found a solution for this but only if I knew that all the table names while creating my view.
Here is what I currently have:
master_table:
TABLENAME ID
1 table_01
2 table_02
table_01:
ID NAME
1 eins
zwei 2
drei 3
table_02:
ID NAME
1 a
2 two
3 three
I think 'tab1tab2' on these 2 table looks like this:
ID NAME TABLENAME
1 table_01 eins
2 zwei table_01
3 drei table_01
1 a table_02
2 two table_02
3 three table_02
I have reached this point of view with:
CREATE OR REPLACE VIEW TAB1TAB2 ('ID', 'NAME', 'TABLENAME')
AS
SELECT id, name, 'table_01' AS table_01 FROM tablename
UNION
SELECT id, name, 'table_02' AS tablename FROM table_02;
Is it possible to create as many select statements and union that I entered (tablenames) into my master_table to achieve the same results as my opinion hard?
Thank you very much in advance for your help
Best regards
Majocreate or replace view v_alltables
Select * from v_all;These two statement contradict each other in some way, Don't they?
path ID number name 'id', varchar2 (20) 'name' of the path) x;
the column names are case sensitive - try
id number path 'ID' , name varchar2(20) path 'NAME' ) x;
assuming that the names of the columns are named like that.
-
Original title: scams?
I continue to receive calls from numbers not available with an Indian accent saying that they are from the Technical Department of windows and I have a problem with my computer. Normally, I just say that I don't have and hung up. Today, I took a little further and he said that they discovered that I had loads of malware/viruses etc and that they could identify with them. I was obviously very suspicious because he seemed to have my correct Windows ID number and with care on 'Run' he told me to type things like cmd eventviewer and inf where he referred to a file 1394.pnf. I stopped while he asked remotely to access my computer. However, I got a phone number 01916450337 and his P786000 id I noticed that many people are posting on your forum-is this another one of those scams?
Continue to put the phone down. They are all crooks.
They get you to open Event Viewer, because there are words such as 'critical' and 'error' along the this.
-
How to select columns, that we need a table with pivot
Hello
How can I select only the required columns that I need the table
My goal is to keep everything in one line
Database: 11.2.0.2.0
I have a table called Table Agent
create the table AGENT_DETAIL
(
agent_id NUMBER (20) not null,
agent_type_code VARCHAR2 (10) not null,
agent_type_prefix VARCHAR2 (10) not null,
Type_Code VARCHAR2 (10) not null,
type_prefix VARCHAR2 (10) not null,
last_modified DATE not null
)
INSERT INTO agent_detail VALUES
(29709, ARE ',' OFFICE ',' DNSWEB ',' AGTDETAILS', SYSDATE);
INSERT INTO AGENT_DETAIL VALUES
(29709, ARE ',' OFFICE ',' DNSNATID ',' AGTDETAILS', SYSDATE);
INSERT INTO AGENT_DETAIL VALUES
(29709, ARE ',' OFFICE ',' DELIVERY ',' AGTDETAILS', SYSDATE);
INSERT INTO AGENT_DETAIL VALUES
(29709, ARE ', 'OFFICE', "WEBUSAGE", "WEBUSER" SYSDATE);
When you query it against the table
SELECT * FROM AGENT_DETAIL;
AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX TYPE_CODE TYPE_PREFIX LAST_MODIFIED 1 29709 RE OFFICE DNSWEB AGTDETAILS 22:14:15 12/09/2015 2 29709 RE OFFICE DNSNATID AGTDETAILS 09/12/2015-22:15:26 3 29709 RE OFFICE DELIVERY AGTDETAILS 09/12/2015-22:21:37 4 29709 RE OFFICE WEBUSAGE WEBUSER 10/12/2015-09:27:52 Because my goal is to put everything in a single line instead of get in 4 rows
My query is like that
(select *)
the Dungeon of pivot (min (TYPE_CODE) AGENT_DETAIL (last dense_rank command by LAST_MODIFIED) for TYPE_CODE in ('DNSWEB' as the WEB)
'DNSNATID' as
NATIONAL,
'DELIVERY' AS
DELIVERY,
"WEBUSAGE" AS WEBUSAGE
)
))
Result:
AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX TYPE_PREFIX WEB NATIONAL DELIVERY WEBUSAGE 1 29709 RE OFFICE WEBUSER WEBUSAGE 2 29709 RE OFFICE AGTDETAILS DNSWEB DNSNATID DELIVERY Is it possible to get everything in one record, I know that I have two type_prefixes different (WEBUSER, AGTDETAILS)
But all I want to see my data is like this
Agent_id Agent_type_code Agent_type_prefix WEB WEBUSAGE NATIONAL DELIVERY
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
RE OFFICE DNSWEB DNSATID DELIVERY WEBUSAGE 29709
Hello
When you use SELECT... PIVOT, the result set contains 1 row for all the distinct combinations of the values of all columns except columns mentioned in the PIVOT clause. If you want to ignore some columns completely, then let the PIVOT operated at a "table" that does not include the. For example:
with RELEVANT_AGENT_DETAIL as
(
Select AGENT_ID, AGENT_TYPE_CODE, AGENT_TYPE_PREFIX, TYPE_CODE, LAST_MODIFIED
of AGENT_DETAIL
-where--if you filter, put it here
)
Select *.
of RELEVANT_AGENT_DETAIL
Pivot (min (TYPE_CODE) Dungeon (last dense_rank command by LAST_MODIFIED))
for TYPE_CODE in ('DNSWEB' as WEB
'DNSNATID' as NATIONAL
'DELIVERY' as DELIVERY
"WEBUSAGE" as WEBUSAGE
)
)
;
If you are lazy or trying to be cute, maybe you can give the columns unwanted some lazy jobs in the PIVOT clause, like this:
Select *.
of AGENT_DETAIL
Pivot (min (TYPE_CODE) Dungeon (dense_rank last order by LAST_MODIFIED)
TYPE_CODE
TYPE_PREFIX
)
for TYPE_CODE in ('DNSWEB' as WEB
'DNSNATID' as NATIONAL
'DELIVERY' as DELIVERY
"WEBUSAGE" as WEBUSAGE
)
)
;
But this makes the code confusing and may be difficult to maintain.
Maybe you are looking for
-
Can I add a second monitor?
I'm used to 2 monitors, and I want to keep it this way. I hung on a samsung monitor I have via HDMI to my Sprout. It works, except that I can't seem to operate as one extension of the other. I have set them up as an extension, but this is only to
-
Hit to swipe "slide to unlock" doesn't let me get into the iPad. After trying to swipe it just stops and the screen will Dim. In the upper right corner is also a symbol of halfpipe.
-
reading emails from gmail by labview
I easily found a sample program to send an email to Gmail in LabVIEW and it works well. But I want to read emails from Gmail in LabVIEW so. Is this possible? Thank you Jay
-
attempt to add a printer (Epson Stylus CX7400
Adding a printer
-
I have a Vista 64 bit OS. I tried to do a system restore to the last checkpoint to interrupt a Service Pack. Restore failed (don't remember exact error), now when I try to boot Vista, I get a message saying to run CHKDSK /F to check for hard drive