The writing PLSQL functions with columns as arguments (without aggregation)?
Forum,. . . . Anyone know the shape / syntax of a function (Oracle10g) that works on a column (for example, SUM) without having to specify a GROUP BY clause (aggregators so defined by the user, although his end to adapt, is not quite what I'm looking for)? Web research point to a REF CURSOR argument - can I get an amen?
. . . . I have a function that adds two objects (type = MDSYS. SDO_GEOMETRY containing geometries 'unknown' for Oracle built in functions do not work on them). To add objects K, the user must call this function time (K-1). This isn't a big problem as long as the number of adds is small (K _ < _ 5?), but what happens if the user needed to add objects N (where N + 1 is the point they go postal)? The solution seems to be to overload the existing function so that it can take a column as an argument and the user can limit the number of objects in the WHERE clause.
See you soon,.
Noel
Published by: Christmas Khan on March 10, 2011 14:37 - Lavalin title of post
Hi Noel,
Noel Khan wrote:
. . . . As indicated during the initial post, aggregate defined by the user are close, but require the end user to use the GROUP BY clause...
This is not true. Aggregate functions do not require a GROUP BY clause. You have not said
SELECT COUNT (*)
FROM table_x;
When you want ot know if table_x had been filled? In addition, aggreagate user-defined functions can also be called analytically.
It would really help if you gave a concrete example of what you wanted to do.
Tags: Database
Similar Questions
-
How to get the orientation angle screen with 40 Hz stably without delay to sync?
Goal: Get orientation angle screen at 40 Hz stably without delay for synchronization.
Problem with two situations:
1. When you use the bbutil_swap and navigator_event_get_orientation_angle (event) to get the orientation angle screen with other data such as acceleration sensors and gyroscope data, the sampling frequency will be low grade at 10 Hz randomly. The difference of synchronization will increase from 25 ms to 100 ms.
2. when the screen orientation angle is collected in the following code to get the angle only, the difference in timing of sampling will be 1, 2 or 5 seconds at random.
Question: How do I get the orientation angle screen with 40 Hz stably without delay to sync?
or something wrong in my code?
Mini code:
public static void handleNavigatorEvent(bps_event_t *event) {}
switch (bps_event_get_code (event)) {}
case NAVIGATOR_ORIENTATION_CHECK:
navigator_orientation_check_response (event, true); If not the line, no updates on the screen rotation.
angle = navigator_event_get_orientation_angle (event);
break;
case NAVIGATOR_EXIT:
stop = true;
break;
}
}public static void handle_events() {}
for(; ) {
bps_event_t * event = NULL;
If (BPS_SUCCESS! = bps_get_event (& event, 0)) {}
fprintf (stderr, "bps_get_event failed\n");
break;
}
If {(event)
If (bps_event_get_domain (event) is {navigator_get_domain()})
handleNavigatorEvent (event);
}
} else {}
break;
}
pthread_create (& t1, NULL, (void *) & rawacceleration, NULL);
}
}int main (int argc, char * argv []) {}
screen_create_context (& screen_cxt, 0);
bps_initialize();{If (EXIT_SUCCESS! = {bbutil_init_egl (screen_cxt))}
fprintf (stderr, "bbutil_init_egl failed\n");
bbutil_terminate();
screen_destroy_context (screen_cxt);
return 0;
}If (BPS_SUCCESS! = screen_request_events (screen_cxt)) {}
fprintf (stderr, "screen_request_events failed\n");
bbutil_terminate();
screen_destroy_context (screen_cxt);
return 0;
}If (BPS_SUCCESS! = navigator_request_events (0)) {}
fprintf (stderr, "navigator_request_events failed\n");
bbutil_terminate();
screen_destroy_context (screen_cxt);
return 0;
}Rawlog = fopen (rawfilename, "w"); Save the file in a specific path.
fprintf (rawlog, "Absorption system, Angle\n");navigator_request_events (0);
While (! shutdown) {}
handle_events();
bbutil_swap();
}closeshutdown();
return 0;
}Thank you for your attention,
Using SENSOR_TYPE_ORIENTATION of sensor_type_t , you should be able to get > 10 Hz. Use sensor_set_rate() to get the slower delay to call sensor_info(). Make sure not to enable sensor_set_skip_duplicates().
However get the orientation at the 40 Hz streaming will not make your application any repsonsive more. The only way to make your app more would be to manage the orientation change in a short period of time. This is the time when orientation changes (at the hardware level), to receive you and to deal with it. It is usually a constraint system and there is not that you can do about it. What you see using the code above is the same information repeated over and over; FACE_UP, FACE_UP, FACE_UP, which is not really useful.
-
Problem using applescript to put data into the table of numbers with column heads
I have extracted the data from certain Web pages and want to place the data items in a table of numbers. I wrote the applescript to extract pairs of data into two lists, but encountered a problem when you try to put the data items in a table of numbers.
I hope I've isolated the problem eventually reduce version of the data table and writing.
Calendar_Month
Alvarez
Laundry
Linen
Products
March-2014
April 2014
May-2014
Totals:
0.00
0.00
0.00
0.00
Define theLabels to {"Alvarez", "Flax", "Laundry", "Products"}
the nominative value {11, 22, 33, 44}
Tell application "Numbers."
say table 1 on sheet 1 of 1
rowIndex Set of 3
q Set of 2
say the line rowIndex
colHead theLabels point q value
the columnIndex value address column colHead
tell the cell (columnIndex)
value defined in point q of the nominative case
tell the end
tell the end
tell the end
tell the end
I arbitrarily chose to line 3 of the table to demonstrate the problem.
Each data item is associated, due to its position in the list, with a label that determines the column of the data table, where it should be placed.
The illustrated script pitches the 2nd data element in the list in the column headed "Lin". This seems to work ok. But if q is set to 1 the script fails with
get address of column "Alvarez" in line 3 of table 1 to sheet 1 of the document 1
-> error number - 1728 column "Alvarez" in line 3 of table 1 of sheet 1 of document 1
It fails also with q the value 3 or 4.
I probably did something really stupid, but I can't understand this behavior. Advice please?
Under: Numbers v.3.6.1 Script Editor 2.7 2.4 OS X 10.5.5 Applescript
Two questions.
(1) the order of the text in theLabels = {"Alvarez", "Flax", "Laundry", "Products"} and differ from the order of the text in the header row. Is this correct?
(2) you are putting the value 22 (point 2 of nominative) in cell D3, where column heading of D = "Flax", which is article 2 of the theLabels?
Respect,
H
-
SQL for the interface of FILES with column headers
Hi all
I designed an interface to extract data from Oracle to flat (.txt file).
(1) I get the column headers in the output of file(. txt file) but I don't want to see any header column
(2) for the creation of the data source in data model if I give any type of Date column I get the null value in the output file, but if I give the column type as string date filed I am able to see the data in the output file.
Thank you
Patel.Hi Pierrot
(1) I get the column headers in the output of file(. txt file) but I don't want to see any header column
You can set GENERATE_HEADER = flase and flow properties.-approach step by step on how to load some data from an oracle to flat file table
http://www.Oracle.com/WebFolder/technetwork/tutorials/OBE/FMW/ODI/odi_11g/odi_project_table-to-flatfile/odi_project_table-to-flatfile.htm
http://odiexperts.com/Oracle-to-flat-file/(2) for the creation of the data source in data model if I give any type of Date column I get the null value in the output file, but if I give the column type as string date filed I am able to see the data in the output file.
I don't think you can use a data type Date during loading in the flat file. You can go with string or number/integer (if the date has no special characters. Here, you can use a conversion function to convert the data type Date existing according to your needs, but make sure that you select "source or on the staging")Concerning
KK -
error by calling the pl/sql function in column target
Hi guys,.
I get this error when my function in ODI:
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "mySchema". "" GET_ODI_DEFAULT_VALUE (1) ": ongeldige ID-> 1 is a parameter
While in sql developer, I get a good result with the following query:
Select mySchema.get_odi_default_value (1) double;
In my target for the primary key table, I call a sequence of mySchema, and it works fine.
I tried the synxtax following in my target column mapping:
-< % = odiRef.getObjectName ("" "," GET_ODI_DEFAULT_VALUE (1) "", "D") % >
-< % = odiRef.getObjectName ("L", "GET_ODI_DEFAULT_VALUE", "D") 1% >
Thanks for you adviceYou use in the interface? If that's when you come to write the name of the function and make its contribution. It should return the value. As
GET_ODI_DEFAULT_VALUE (1) -
Switch the Shift + del function with led?
When I press the button on a selected file he invites me to move to the trash. But generally, I want to delete it without moving it to the trash. To do this, press SHIFT + DELETE. I want to do with just the del key. I can't disable the Recycle Bin, but the shift + delete does nothing. Shift + del should move to the trash, and del delete. Possible?
Hello
I guess that's the nature of windows xp to prevent the user from accidentally delete permanent files. There is no default option to change the keys...
-
How can I call 3 buttons to the same server function with 3 different return URL?
Hello everyone...
I have a question...
Can I use the same function side server to send to guests 3 different swfURL whereby key pressed from one of them?
If the answer is positive... How can I do it?
Please, help me...
Emiliano.
on the client side
import flash.net.Responder;
var responder: responder = new responder (function name);
-
You can initialize a function with such an event without event?
For example, I have this function:
function doSomething(event:MouseEvent):void {}
trace ("do a lot of coding...");
}
Now, if I want to perform the same function as above without the event "click" on your mouse which makes
seem to be possible.
Is there a work around? Or is the best way to make one between the function like this:
function doManyThings() {}
trace ("lots of code here...");
}
function doSomething(event:MouseEvent):void {}
doManyThings();
}
I think the way you describe does, with code that could be called by the event or directly in a separate function would make for more readable code when you come back and look in 6 months :)
But if you want to do the opposite, I think two ways to do this, either by simulating a call event based in the Manager, or by making the event argument in optional Manager.
-
DROP table and CREATE with column name and ORA: 00904
Hello
I created a table with an attribute date CRTD_ON and two other attributes. Successfully created. I can see the data tab and the window empty data with column names in the header...
Now, I had to change the name of field attribute date on OPNG_DATE so I don't bother to change, instead, I deleted and created with the name of the column has changed. Then I restart the ddl. Once again managed to create. But this time I am not able to see the data tab or the column headings. And I see the error of the log of the data Publisher ORA-00904: "CRTD_ON": invalid identifier
Is this a bug?There is a current bug where you will get the data if you have a public synonym with the same table name pointing to another table with another structure. Can you confirm that in your environment?
K.
-
Call the function with the arguments in AS3
Hello!
I am a new in Flex development and cannot understand same code convention, im Java programmer.
How I can write correct function in ActionScript, my call call: var goodsWnd:CreateGoodsWindow = PopUpManager.createPopUp (this, CreateGoodsWindow, true) as CreateGoodsWindow;
I want call above function with argument, how do?
Where my class: public class CreateGoodsWindow extends extends TitleWindow
{
public CreateGoodsWindow(data:Object)
{....}
}Using PopUpManager.addPopUp () instead of of createPopUp(). addPopUp takes an object that has already been instantiated:
var createGoodsWindow:CreateGoodsWindow = new CreateGoodsWindow (data);
PopUpManager.addPopUp (createGoodsWindow); -
[8i] help with function with parameters (for the calculation of the work)
Let me start by saying, I've never written a function before, and I do not have access to create a feature in my database (that is, I can't test this feature). I am trying to achieve a function I can ask my IT Department to add for me. I hope that someone can take a look at what I wrote and tell me if this should work or not, and if it's the right way to go to solve my problem.
I'm creating a function to make a very simple calculation of work (add/subtract a number of days to a date in the calendar).
The database, I work with has a table with the schedule of work. Here is a sample table and sample data, representative of what is in my work table calendar:
The table includes since 01/01/1980 but 31/12/2015.CREATE TABLE caln ( clndr_dt DATE, shop_days NUMBER(5) CONSTRAINT caln_pk PRIMARY KEY (clndr_dt) ); INSERT INTO caln VALUES (To_Date('01/01/1980','mm/dd/yyyy'),0); INSERT INTO caln VALUES (To_Date('01/02/1980','mm/dd/yyyy'),1); INSERT INTO caln VALUES (To_Date('01/03/1980','mm/dd/yyyy'),2); INSERT INTO caln VALUES (To_Date('01/04/1980','mm/dd/yyyy'),3); INSERT INTO caln VALUES (To_Date('01/05/1980','mm/dd/yyyy'),3); INSERT INTO caln VALUES (To_Date('01/06/1980','mm/dd/yyyy'),3); INSERT INTO caln VALUES (To_Date('01/07/1980','mm/dd/yyyy'),4); INSERT INTO caln VALUES (To_Date('01/08/1980','mm/dd/yyyy'),5); INSERT INTO caln VALUES (To_Date('01/09/1980','mm/dd/yyyy'),6); INSERT INTO caln VALUES (To_Date('01/10/1980','mm/dd/yyyy'),7); INSERT INTO caln VALUES (To_Date('01/11/1980','mm/dd/yyyy'),8); INSERT INTO caln VALUES (To_Date('01/12/1980','mm/dd/yyyy'),8); INSERT INTO caln VALUES (To_Date('01/13/1980','mm/dd/yyyy'),8); INSERT INTO caln VALUES (To_Date('01/14/1980','mm/dd/yyyy'),9);
I have written (and validated) this parameter query that performs the calculation of my working day (mday):
Based on this request, I created the following function (and I have no idea if it works or if the syntax is right, etc..):SELECT cal.clndr_dt FROM CALN cal , ( SELECT cal.shop_days+:mdays AS new_shop_days FROM CALN cal WHERE cal.clndr_dt =:start_date ) a WHERE cal.shop_days = a.new_shop_days AND ROWNUM =1 ORDER BY cal.clndr_dt;
I'm also not sure how to do to have the function handle results that would return a date outside the range of dates that appear in the table (prior to 01/01/1980 or after until 31/12/2015 - or, another way to look at what was, before the caln.clndr_dt or the caln.clndr_dt MAX value MIN value).CREATE OR REPLACE FUNCTION add_mdays (start_date IN DATE, mdays IN NUMBER(5)) RETURN DATE IS new_date DATE; BEGIN SELECT cal.clndr_dt FROM CALN cal , ( SELECT cal.shop_days+mdays AS new_shop_days FROM CALN cal WHERE cal.clndr_dt =start_date ) a WHERE cal.shop_days = a.new_shop_days AND ROWNUM =1 ORDER BY cal.clndr_dt; RETURN new_date; END add_mdays; //edit 9:31 AM - noticed I left off this bit
My goal is to be able to use the function in a situation similar to the following:
First of all, here is a sample table and data:
And here's how I would use my function:CREATE TABLE orders ( ord_no NUMBER(5), plan_start_dt DATE, CONSTRAINT orders_pk PRIMARY KEY (ord_no) ); INSERT INTO orders VALUES (1,To_Date('01/08/1980','mm/dd/yyyy')); INSERT INTO orders VALUES (2,To_Date('01/09/1980','mm/dd/yyyy')); INSERT INTO orders VALUES (3,To_Date('01/10/1980','mm/dd/yyyy'));
Thus, the function would allow me to come back, for each command in my table of orders, the date is 3 days working (mdays) before the start of the plan of each order.SELECT orders.ord_no , orders.plan_start_dt , add_mdays(orders.plan_start_dt, -3) AS prep_date FROM orders
I go about it the right way? I have to create a function to do this, or is there a way for me to integrate my request (which makes my mday calculation) in the example query above (eliminating the need to create a function)?
Thank you very much in advance!
Published by: user11033437 on February 2, 2010 08:55
Fixed some typos in the last insert statements
Published by: user11033437 on February 2, 2010 09:31 (fixed some syntax in the function)Hello
Ah, referring to Oracle 8 and is not not able to test your own code makes me nostalgic for the good old days, when you have entered your cards and led to a window to the computer center and waited an hour for the work to be performed and then seen printing to find that you had made a typo.
If you write functions, you should really test yourself. Like all codes, functions forge be written small not: write a line or two (or sometimes just a part of what would later become a single line), test, make sure it is running properly and repeat.
Ideally, your employer must create a pattern of development in a development database that you can use.
You can legally download your own instance of Oracle Express Edition free; just be careful not to use features that are not available in the database where the code will be deployed.You need a function to get the desired results:
SELECT o.ord_no , o.plan_start_dt , MIN (e.clndr_dt) AS prep_date FROM orders o , caln l , caln e WHERE l.clndr_dt = o.plan_start_dt AND e.shop_days = l.shop_days - 3 GROUP BY o.ord_no , o.plan_start_dt ;
It would be more effective (and somewhat simpler) If you've added a column (let's call it work_day) identified whether each line represents a work_day or not.
For each value of shop_days, exactly 1 row will be considered as a working day.
Then, the query may be something like:SELECT o.ord_no , o.plan_start_dt , e.clndr_dt AS prep_date FROM orders o , caln l , caln e WHERE l.clndr_dt = o.plan_start_dt AND e.shop_days = l.shop_days - 3 AND e.work_day = 1 ;
You can use the analytic LAG function to populate the work_day column.
A function would certainly be useful, although perhaps slower.
The function you have posted has some errors:
an argument can be stated under NUMBER (5); Just NUMBER.
(b) when you SELECT in PL/SQL, as you do, you must SELECT a variable to store the results.
(c) ROWNUM is arbitrary (making it useless in this problem) unless you draw a neat subquery. I don't think you can use ORDER BY in subqueries in Oracle 8. Use the ROW_NUMBER analytic function.
(d) the service must end with an END statement.Given your current caln table, here's how I would write the function:
CREATE OR REPLACE FUNCTION add_mdays ( start_date IN DATE DEFAULT SYSDATE, mdays IN NUMBER DEFAULT 1 ) RETURN DATE DETERMINISTIC IS -- add_mdays returns the DATE that is mdays working days -- after start_date. (If mdays < 0, the DATE returned -- will be before start_date). -- Work days do not include Saturdays, Sundays or holidays -- as indicated in the caln table. new_date DATE; -- to be returned BEGIN SELECT MIN (t.clndr_dt) INTO new_date FROM caln f -- f stands for "from" , caln t -- t stands for "to" WHERE f.clndr_dt = TRUNC (start_date) AND t.shop_days = f.shop_days + TRUNC (mdays) ; RETURN new_date; END add_mdays; / SHOW ERRORS
Production code forge be robust (which includes "fool-proofing").
Try to anticipate what people errors might appeal to your function and correct for them where possible.
For example, if it only makes sense for start_date at midnight, mdays to be an integer, use TRUNC in the function where soembody passes a good value.
Allow default arguments.
Comment of your function. Put all comments within the service (i.e. after CREATION and before the END) so that they will remain in the data dictionary.
If, given the same arguments, the function always returns the same value, mark it as DETERMINISTIC, for efficiency. This means that the system will remember the values transmitted rather than to call the function whenever it is said to.I wish I could score questions such as 'Correct' or 'useful '; you get 10 points for sure.
You posted CREATE TABLE and INSERT statements (without even be begged).
You gave a clear description of the problem, including the expected results.
The code is well formatted and easy to read.
All around, one of the more thoughtful and well written questions I've seen.
Play well! Keep up the good work!Published by: Frank Kulash, February 2, 2010 13:10
Added to my own version of the function. -
ERR-9131 error in the body of PLSQL function for default code point, the point =
Hi all
I am filling a field element of text in two different ways, but on the same page:
1 - the page is called to change the values inside-> value of the element comes from field of database
2 - the page is called to insert new values-> value of the element comes from a calculated function that returns a default value
Point features:
Source->
always replace any existing value in session state
database column
-> Default
-----------------------------------------------------------------------------------------------------------------------------
default value
------------------------------------------------------------------------------------------------------------------------------
DECLARE
NUMBER OF THE LINHA;
gene number;
i_emp varchar2 (32000);
v_sql2 varchar2 (32000);
BEGIN
i_emp: =: P62_EMP_COD;
IF: P62_RDD_LIN IS NULL THEN
LINHA: = 1;
ON THE OTHER
LINHA: =: P62_RDD_LIN;
END IF;
v_sql2: =' select '. i_emp |'. Grh_1_utils. GRHFU_RUB_DEFAULT ('|: P62_ENT_COD |', 'R' ' |: P62_REM_COD |', 1, 1000000, to_date null, "D", ("' |: P62_DAT_INI |")) (', "DD/MM/YYYY"),' | LINHA |') the double ';
EXECUTE IMMEDIATE v_sql2 INTO gene;
COMMIT;
return deciphered;
end;
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
default value - body of the PL/SQL function
The error I get is:
ORA-00936: lack of expression
ERR-9131 error in PLSQL function for default code point body, item = ITEM_TO_POPULATE
Something is wrong with my function or is a different, better way to do this?
Cordially Pedro.Hello
You can do some tests?
(1) try to make this code first (to make sure that the P62_EMP_COD is not null when running):DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(2) then you can try to change your source, by changing 'replacement always of value that exists in the session state' "only when null.
(3) enter your variable dynamic SQL code and check it out:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT('||:P62_ENT_COD||',''R'','||:P62_REM_COD||', 1 , 1000000,''D'',null,to_date('''||:P62_DAT_INI||''',''DD/MM/YYYY''),'||LINHA||') from dual'; return v_sql2; EXECUTE IMMEDIATE v_sql2 INTO defeito; COMMIT; return defeito; end;
(4) prevent your run immediate code of SQL Injections using the link:
DECLARE LINHA NUMBER; defeito number; i_emp varchar2(32000); v_sql2 varchar2(32000); BEGIN i_emp := :P62_EMP_COD; IF :P62_RDD_LIN IS NULL THEN LINHA:=1; ELSE LINHA := :P62_RDD_LIN; END IF; v_sql2:='select '||i_emp||'.Grh_1_utils.GRHFU_RUB_DEFAULT(:1,''R'',:2, 1 , 1000000,''D'',null,to_date(:3,''DD/MM/YYYY''),:4) from dual'; EXECUTE IMMEDIATE v_sql2 INTO defeito USING :P62_ENT_COD, :P62_REM_COD, :P62_DAT_INI, LINHA; COMMIT; return defeito; end;
Best regards, Kostya Proskudin
-
I use:
3.6.1 the numbers
OSX 10.11.1
For clarity: afterwards, I use the term 'address of the cell' is the name of the Table, the numbers of row and column that is used to specify a particular cell. Please let me know if there is a name for this.
Am new on numbers and you want to create a database with two tables whose most variables in "Table 2" are determined by entries in 'Table 1' and vice versa. I use the functions to set up these relationships; However, it is not an obvious geographic relationship between the output in table 2 cell address and the address of the entry in table 1 cell, so I want the address of the cell called in any default function to "Preserve line - True" and "Preserve column - True" still, but don't be found anywhere to set this parameter. Is this possible?
Thank you in advance your help.
All the best,
RA
It is possible that you are trying to do things with numbers for which it is not designed. It's really good at crunching numbers, but this isn't a database program. If you look at the models in file > New in your menu, you will find good examples of use of numbers. To enter formulas usually you don't have to make a lot of seizure of addresses. You type = activate the formula editor, and then click the cell you want to reference. Numbers then inserts the address for you.
SG
-
How to use the TRUNC function with dates in the expression builder in OBIEE.
Hello
How to use the TRUNC function with dates in the expression builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.
Thanks in advanceUse it instead:
TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE) -
With the help of CAE/FGA columns specific null for all, but some users
I was read about VPD and - but there are many examples - I'm having a hard time to get together.
I have a table that - when most users select hand - they should get NULL in a specific column.
This column should only display a limited group of users as one value other than null.
Can someone help me with an example implementation of this?
Any help is appreciated.An excerpt from http://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php
CONN sys/password@db10g AS SYSDBA GRANT EXECUTE ON dbms_rls TO scott; CONN scott/tiger@db10g -- Create the policy function to restrict access to SAL and COMM columns -- if the employee is not part of the department 20. CREATE OR REPLACE FUNCTION pf_job (oowner IN VARCHAR2, ojname IN VARCHAR2) RETURN VARCHAR2 AS con VARCHAR2 (200); BEGIN con := 'deptno = 20'; RETURN (con); END pf_job; / -- Using the same policy function as before. BEGIN DBMS_RLS.ADD_POLICY (object_schema => 'scott', object_name => 'emp', policy_name => 'sp_job', function_schema => 'scott', policy_function => 'pf_job', sec_relevant_cols => 'sal,comm', sec_relevant_cols_opt => DBMS_RLS.ALL_ROWS); END; / -- All rows are returned but the SAL and COMM values are only -- shown for employees in department 20. SELECT empno, ename, job, sal, comm FROM emp; EMPNO ENAME JOB SAL COMM ---------- ---------- --------- ---------- ---------- 7369 SMITH CLERK 10000 7499 ALLEN SALESMAN 7521 WARD SALESMAN 7566 JONES MANAGER 2975 7654 MARTIN SALESMAN 7698 BLAKE MANAGER 7782 CLARK MANAGER 7788 SCOTT ANALYST 3000 7839 KING PRESIDENT 7844 TURNER SALESMAN 7876 ADAMS CLERK 1100 EMPNO ENAME JOB SAL COMM ---------- ---------- --------- ---------- ---------- 7900 JAMES CLERK 7902 FORD ANALYST 3000 7934 MILLER CLERK 14 rows selected. -- Remove the policy function from the table. BEGIN DBMS_RLS.DROP_POLICY (object_schema => 'scott', object_name => 'emp', policy_name => 'sp_job'); END; /
The function returns "deptno = 20" so no row corresponding to this condition will show the value of sal and comm, rest will display null value.
IN your case I suppose you want the user to the function that executes the query (select user to double), once you get the user to see if it is a user who is supposed to see the values of columns if yes return "1 = 1" in the case otherwise return "0 = 1".
Maybe you are looking for
-
All of a sudden today my email is displayed correctly. HTML emails simply display the actual html code instead of a graphical display. Texts emails show just a blank page. I changed the display setting to view html messages original, simple html and
-
Google links no longer work after iOS 9.3
After update to iOS 9.3 on my iPhone 6 Plus I can no longer click on the Google search links more. Tried in Safari and Chrome. Works well with Bing.com. If I hold down on the link and choose open in a new tab, it works. restarted apps-> same result T
-
I did a factory recovery using Recovery Manager on my desktop of windows 7 Home premium, Pavilion Elite 150ff. After having installed all the updates and download flash player and Adobe Reader and install my Antivirus HP Photo creations program won't
-
Installing WXP on Satellite L300-0HH
Hello I have laptop Satellite L300-0hh and I would chang my Windows Vista and install Windows XP.Please help me find the driver for Windows XP Home edition. Thank you.
-
As I close outlook wxpress yesterday, I got the prompt for compaction. It's been awhile, so I let it start and stop later the computer without checking anything. Today, when I went to check my messages, everthting from 2012 until yesterday was gone.