30EA1: confusion in tab name holding PL/SQL code
If I edit a PL/SQL function and use it as a starting point to create a similar one, the buffer/tab keeps the original name even after successful compilation of the new function. After refreshing the list of functions in the left-hand tree, the new function appears, yet clicking on the original one simply re-activates the similarly named tab, which now holds the code for the new function. That's pretty confusing, really.
Fixed in EA3 (cannot remember if I checked EA2).
The tree even automatically refreshes as soon as you compile your new function, great!
Similar Messages
-
[SOLVED] Reverting Guake terminal tab names back to 'Terminal #'
The new version of Guake (0.4.3) implemented 'Better Tab Titling'. This means that instead of a new tab name being 'Terminal #' (where # is an auto incrementing integer), it instead forced the title to be equal to the VTE prompt.
My issues were that there was no way to set a preference to switch back (as I prefer the simple tab name) and that tab names could/would take a very large amount of space (as it would put my whole username@server:/path/to/where/i/am/at).
So I figured out how to fix and thought I'd share in case anyone else would like to switch back:
NOTE: I believe python is spacing-sensitive (please correct me if I'm wrong). All the lines (added/edited) are indented 8 spaces.
edit /usr/bin/guake
find: self.selected_tab = None
after that line, add:
# holds the number of created tabs. This counter will not be
# reset to avoid problems of repeated tab names.
self.tab_counter = 0
find: def on_terminal_title_changed(self, vte, box):
after that line add:
return
find: Adding a new radio button to the tabbar
the next line will read:
label = box.terminal.get_window_title() or _("Terminal")
change to:
label = box.terminal.get_window_title() or _('Terminal %s') % self.tab_counter
find self.tabs.pack_start(bnt, expand=False, padding=1)
after that line add:
self.tab_counter += 1
After editing the file, restart Guake for the change to take effect.
BeemerI have been using Guake for years and I think the tab bar is in the way. I disabled it a very long time ago and didn't look back.
Here are the shortcuts that I use:
"~" to toggle it.
Ctrl+T for a new tab (just like in Firefox, Chromium).
F1 and F2 for next and previous tab.
F3 close tab.
Basically, I don't need more than two tabs at a time; three tops, in very rare cases.
Hope it helps. -
Creating tabs for a single SQL report type region
I would like to find a way to use tabs in a single SQL report type region. The problem I have is that there are too many columns to be displayed so the report looks very cluttered. I would like to find a way to assign say columns 1 - 5 to tab 1, 6-10 to tab 2 etc so the user can find the columns they need by simply clicking on the various tabs without having to execute the query again.
I have looked at JQuery tabs but that seems to only be applicable to more or less unrelated regions. I tried to create different regions using the same query with different columns and that kind of works, but the regions don't stay in sync if say the user change the order for column 2 in tab 1, when they click on tab 2 everything displays in a different order.
Another wrinkle is that this is an updatable report so some of the columns are updatable.
I also looked at the hide / display column solution which is described in a few threads and that may also sort of work, but it is also not quite what I am looking for.
Any help is greatly appreciatedDoes anybody know if this can be accomplished using APEX? What I am really looking for is very similar to an old fashioned client / server screen developed using say Oracle Forms. Consider an order line screen where say columns line number, SKU and SKU description is to the left of the tabs so these columns are visible no matter which tab is active. Then the first tab has say pricing information including UOM, quantity, list price, unit selling price, price list. The next tab has say customer information including customer number, name, bill to and ship to addresses. the next tab has say shipping information with say the warehouse, shipping instructions and shipping method.
-
Getting tab name or tab id or tab label at runtime
Hi All,
I think the answer is "no" but I'm going to ask anyway just in case I missed something.
I am designing some authorization schemes for my application. The context behind the design is this:
1. Two-level tabs application.
2. Access is stored in a table where an assignment between a level 2 tab is assigned to a user (well, it's really assigned to groups of users but that's not that important for this question). The level 2 tab is assigned via a select-list LOV defined as:
select
tab_label d,
tab_id r
from apex_application_tabs
where application_id = :APP_ID
and workspace = :OWNER
order by 1
So I store the TAB_ID of the 2nd level tab and it's assigned to groups of users.
So what I'd like is this at runtime:
1. For page-level security, I read the Apex data dictionary and pass APP_PAGE_ID to a function that reads the page number. I traverse the tab hierarchy in APEX_APPLICATION_TABS to see if the APP_PAGE_ID resides in TAB_PAGE or TAB_ALSO_CURRENT_FOR_PAGES to get the TAB_ID. Then I check my own assignment table to see if that TAB_ID is accessible to the user. If so, return TRUE, else, return FALSE. This is working wonderfully and isn't a problem...at runtime if I navigate to a page that is on a 2nd level tab and I don't have access to the page, the security scheme errors (correctly).
2. For tab-level security, I want that at the parent tab level that if the user has access to one or more of the 2nd level child tabs, display the parent tab.
3. For tab-level security, if the user is on a parent tab (because he/she has access to at least one child tab), only show the child tabs to which they have access.
Now the problem(s). The thing is that the user sees the tabs before they navigate to them (#2 and #3 I don't have working right now) and I want to hide them if they don't have access.
For example, let's say my parent tabs are A, B, and C. Child tabs are A1, A2, A3 underneath A. B1, B2, B3 underneath B. C1, C2, and C3 underneath C.
Let's say everything in A and underneath A (so A1, A2, and A3) are available to anyone who has a login to the application. No problem there.
Then, let's say most or all users have access to B1 but fewer users have access to B2 and B3. What I want is that if anything from B is available to a user, show parent tab B. If the user clicks on parent tab B, then show B1, B2, and B3 but only show the tabs to which they have access (so if they have access to B1 and B2 but not B3, do not display B3).
Then, let's say C is a very powerful administrative tab and very few people have access to it. I want to not-show C at all for people who do not have any access to C1, C2, or C3.
The problem I have at runtime is that I cannot find a way for a tab to pass information about itself when the tab is about to paint (or not-paint). The only variable or substitution string at runtime that I can find to reference about a tab is "CURRENT_PARENT_TAB_TEXT". However this gives me only information about the parent tab's text of the parent tab that has focus right now; each parent tab cannot pass it's own info until I navigate there. I need to get that information w/o navigating to the tab first so that I can determine to show/hide the tab. Does that make sense? In other words, at runtime, I log into the system and let's say I'm not very powerful and should only be on tabs A1, A2, and A3 under A. I log in, I land on A1, and I can see A2 and A3 (good), but also I can see parent tabs B and C poking up there too. CURRENT_PARENT_TAB_TEXT does not resolve to B or C (it currently resolves to A) until I actually try to click on B or C. I need to hide B or C before the user clicks.
Yes I can do it if I hard-code the name of the tab in a security boolean function, but I would have to have as many authorization schemes as I have tabs. This is why I want just one tab-level scheme where I pass the tab name or ID at runtime dynamically but I can't seem to reference it.
Over in the template for two-level tabls I see #TAB_LABEL#, #TAB_NAME#, #TAB_ID#, and #TAB_LINK#. These don't seem to be available to PL/SQL to pass at runtime to a PL/SQL function. If they could, this would be my answer.
Any other options or am I stuck on this one?
BTW...we are on version 3.2 of Apex and going to version 4 soon. If something is available in 4 for this that helps, I can do it then.
Ideas? Thanks!Hey gti_matt,
Did you end up getting anywhere with this?
I'm in the same boat atm...
Thanks,
Dan -
Hi
I'm writing application with access control to several tabs there will be condition checking if user :APP_USER have access to selected tab. The point is how to get tab_name or tab_id. and use it in pl\sql function like I can use :APP_USER
Or
how can I do this without using tab_id
Regards
JaroslawCREATE OR REPLACE
FUNCTION can_user_access_tab(p_user IN VARCHAR2
,p_tab IN VARCHAR2
RETURN VARCHAR2
IS
ln_count number;
BEGIN
SELECT count(1) INTO ln_count
FROM acces_tab_users
WHERE username=p_user
AND tab_name=p_tab;
if (ln_count=0) THEN
return 'N';
else
return 'Y';
END;to each tab add a SQL expression condition
can_user_access_tab(:APP_USER,'<tab name>') = 'Y'
Note : <tab name> would be different for each tab , so you have to modify the conidtion for each tab with a new string that matches your table's(acces_tab_users) tab_name column.
If you want to use an authorization scheme which uses tabname and user , there is a substitution string named CURRENT_PARENT_TAB_TEXT that might work for you. But I couldn't find anything for the sub tab.
In the authorization scheme that would be
return can_user_access_tab(:APP_USER,:CURRENT_PARENT_TAB_TEXT) --function returns BOOLEAN in this caseI haven't used it, so can't provide any more info on this at the moment.
Update
Use Jari's method and pass :APP_USER and :APP_PAGE_ID to the authorization scheme. You would have to set up the tab access table based on the page number for this.
Edited by: vee on Mar 3, 2011 3:45 AM -
Version: 4.1.1.00.23
Hey,
I need to capture the tab name when it is clicked. Is there any way to do this??
I created dynamic breadcrumbs and when the user clicks the tab to enter a page the application items used to contain the values for the breadcrumb path are not being cleared. So when the user clicks a tab to go into the page directly the breadcrumb path is the last entry created in the trail, but it should be the only entry in the breadcrumb path.
eg: User is on Page 1 and clicks a button bringing them to page 2 and the breadcrumb will be Page 1>Page 2.
However, if the user clicks a tab to go directly into page 2, the breadcrumb should just be Page 2 and it's showing Page 1 > Page 2 and this is because the application items holding the values are not being cleared.
Does someone have a solution to this?
Thanks.
Parth.psampat wrote:
Version: 4.1.1.00.23
Hey,
I need to capture the tab name when it is clicked. Is there any way to do this??
If it's a standard tab then the value of the built-in substitution string REQUEST is set to the tab name when it is clicked.
Alternatively, query the APEX_APPLICATION_TABS view using the page ID in a Before Header computation/process in the destination page, something like:
select
aat.*
from
apex_application_tabs aat
where
aat.application_id = :app_id
and ( aat.tab_page = :app_page_id
or instr(
',' || aat.tab_also_current_for_pages || ','
, ',' || :app_page_id || ',') > 0) -
Hello,
In my page I have 4 tabs. I would like to get the tab name or tab id to pass to my pl/sql procedure. When user clicks the tab, I am passing certain parameters to the plsql procedure. So is there any way i can uniquely get the tab name or tab id?
Thanks in advance
Regardswell,
it is still vague for me to understand what do you mean by getting tab name from URL.
perhaps what you intend to have is a programmatic way of finding tab name from URL.
for that in 10.1.4 as the query strings do not work that way, so you may use the following API function call and use it to write some custom function. (note that it will work when you will call it from some page on your portal).
portal30.wwctx_api.get_path_infothis gives typically a result like this depending upon the page address/location (and provided that you are on a tab of a multi-tab page):
/!PORTAL30.wwpob_page.show/SHARED/U/PAGE_GRP/PAGE_NAME/TABNAMEhope that helps!
AMN -
Hi
I'm trying to include a page to submit bugs in my app and I'd like to include LOVs for the tab and sub-tab names, since the users never see the page numbers. Anyone know how I can query for them in my LOV definitions?
Thx
DerekAs Anton said, the best thing is to store your custom headings in a table so that you can use the table for your LOV as well as for your report headings.
To use dynamic report headings, you can use the 'PL/SQL function body returning colon-delimited headings' feature on the Report Attributes page.
So, if your report headings are stored in table t that function body can be
declare
l_headings varchar2(4000)
begin
for rec in (select heading from t) loop
l_headings := l_headings||':'||rec.heading;
end loop;
return ltrim(l_heading,':');
end;Hope this helps. -
Hi,
My dashboard has 10 tabs (pages). 5 of them are main tabs which are shown all the time. The rest of the tabs are sub-tabs and hidden so user don't get confused. When user navigate to a sub-tab via a link in main tab, I'd like to show the tab name up next to the dashboard name. Something like
myDashboard -> myTab
Is there a way to do this?
Thank you in advance for your ideas.You will have to write a VBScript to achieve what you want.
Here is an example. This VBScript returns the name of the first tab:
Set XLHandle = CreateObject("Excel.Application")
XLHandle.DisplayAlerts = False
Set XLBook = XLHandle.WorkBooks.Open("<path>\<file>.xls")
Set XLSheet = XLBook.Sheets.Item(1)
wscript.echo XLSheet.Name
XLBook.Save
XLBook.Close
XLHandle.Quit
Set XLSheet = Nothing
Set XLBook = Nothing
Set XLHandle = Nothing
Call the script tab.vbs from within your DS script and assign the result to a global variable.
$TabName = exec( 'cmd','cscript //nologo C:\\Users\\Administrator\\Documents\\BI4B\\tab.vbs',0); -
Rep-1401: formula name : Fatal Pl/SQL error occured
Hi,
I am using report builder 6.0 and recently came across a error while running the report. Rep-1401:<formula name> : Fatal Pl/SQL error occured.
I created a formula column in the report. In that i have three local variable.
f_val number := 0;
s_val number := 0;
t_val number := 0;
t_val := f_val/s_val ; --> this gives the above fatal error.
t_val := (f_val + 1)/s_val; --> this gives the above fatal error
t_val := f_val/(s_val + 1); ---> no error
if i change the value of s_val
s_val := 1;
t_val := f_val/(s_val - 1) ; ----> this gives the above fatal error.
Can anyone help me to solve this problem or is it report builder bug.
Please help me, as i desperately need help.
ThanksThanks for ur reply.
I used nvl too, but the same error occurred.
For the information in my question I by mistake typed
t_val := (f_val + 1)/s_val; --> this gives the above fatal error.
but when the value of f_val = zero and s_val is zero why it gives fatal error when i divide, i used nvl on both the variable while dividing but still got the same error.
but if s_val is greater than zero then no error occurs.
please help me, I feel it is a bug. -
In excel sheet tab name is not coming-urgent
hi all,
one small rewquirement. if u run this test program it opens a excel sheet which contains signle tab. here tab name is not coming. i dont no hot to display tabname here.anybody can make the changes and send me the code.
i am sending my code below.
thanks,
maheedhar.t
REPORT ytestvij MESSAGE-ID zv.
TABLES sscrfields.
TYPE-POOLS: icon.
TYPES : BEGIN OF zfnames_ds,
reptext TYPE reptext,
END OF zfnames_ds.
TYPE-POOLS ole2 .
DATA: wa_fntxt TYPE smp_dyntxt.
DATA : wa_t75_booking TYPE zvt75_booking_h,
t_t75_booking TYPE STANDARD TABLE OF zvt75_booking_h.
DATA : wa_fields TYPE dfies,
t_fields TYPE STANDARD TABLE OF dfies.
DATA : wa_fnames TYPE zfnames_ds,
t_fnames TYPE STANDARD TABLE OF zfnames_ds.
handles for OLE objects
DATA: h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
h_map TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object. " font
DATA h TYPE i.
DATA : lin TYPE i.
data: excel type ole2_object,
application type ole2_object,
books type ole2_object,
book type ole2_object,
sheet type ole2_object,
cell type ole2_object,
column type ole2_object.
PARAMETERS : p_input TYPE localfile.
Add button to application toolbar
SELECTION-SCREEN FUNCTION KEY 1. "Will have a function code of 'FC01'
INITIALIZATION.
Add displayed text string to buttons
wa_fntxt-icon_id = icon_xls.
wa_fntxt-icon_text = 'Input File template'.
wa_fntxt-quickinfo = 'T75 Header Data'.
sscrfields-functxt_01 = wa_fntxt.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = 'FC01'.
do nothing
PERFORM open_excel.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_input.
PERFORM get_filename USING p_input.
START-OF-SELECTION.
*set pf-status 'ONE'.
END-OF-SELECTION.
WRITE : lin.
*& Form GET_FILENAME
text
--> p1 text
<-- p2 text
FORM get_filename USING p_file TYPE rlgrap-filename . "localfile.
DATA : w_rc TYPE i.
DATA : wa_file_table TYPE file_table ,
t_file_table TYPE STANDARD TABLE OF file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER =
INITIAL_DIRECTORY =
MULTISELECTION =
CHANGING
file_table = t_file_table[]
rc = w_rc
USER_ACTION =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT t_file_table INTO wa_file_table.
p_file = wa_file_table-filename.
ENDLOOP.
ENDFORM. " GET_FILENAME
*& Form open_excel
text
--> p1 text
<-- p2 text
FORM open_excel.
SELECT * FROM ZVT75_BOOKING_H
INTO TABLE t_t75_booking
UP TO 10 ROWS.
start Excel
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
PERFORM err_hdl.
SET PROPERTY OF h_excel 'Visible' = 1.
PERFORM err_hdl.
get list of workbooks, initially empty
CALL METHOD OF h_excel 'Workbooks' = h_mapl.
PERFORM err_hdl.
add a new workbook
CALL METHOD OF h_mapl 'Add' = h_map.
PERFORM err_hdl.
output column headings to active Excel sheet
PERFORM fill_cell USING 1 1 1 'Financial year'.
PERFORM fill_cell USING 1 2 1 'Financial quarter'.
PERFORM fill_cell USING 1 3 1 'Customer number'.
PERFORM fill_cell USING 1 4 1 'Booking Year'.
PERFORM fill_cell USING 1 5 1 'Financial quarter'.
PERFORM fill_cell USING 1 6 1 'Contract type'.
PERFORM fill_cell USING 1 7 1 'Sub Contract type'.
PERFORM fill_cell USING 1 8 1 'Customer purchase order number'.
PERFORM fill_cell USING 1 9 1 'Booking Amount'.
PERFORM fill_cell USING 1 10 1 'Currency Key'.
LOOP AT t_t75_booking into wa_t75_booking.
copy items to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 wa_t75_booking-BOOKYEAR.
PERFORM FILL_CELL USING H 2 0 wa_t75_booking-BOOKQTR.
PERFORM FILL_CELL USING H 3 0 wa_t75_booking-.
PERFORM FILL_CELL USING H 4 0 wa_t75_booking-BOOKYEAR.
PERFORM FILL_CELL USING H 5 0 wa_t75_booking-BOOKQTR.
ENDLOOP.
disconnect from Excel
FREE OBJECT h_excel.
PERFORM err_hdl.
ENDFORM. " open_excel
*& Form ERR_HDL
outputs OLE error if any *
--> p1 text
<-- p2 text
FORM err_hdl.
data test type sy-subrc.
test = sy-subrc.
IF test <> 0.
Message e000(ZV) with 'Error in OLE-Automation:'.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
FORM fill_cell USING i j bold val.
CALL METHOD OF h_excel 'Cells' = h_zl EXPORTING #1 = i #2 = j.
set property of sheet 'Name' = 'T75'.
PERFORM err_hdl.
SET PROPERTY OF h_zl 'Value' = val .
PERFORM err_hdl.
GET PROPERTY OF h_zl 'Font' = h_f.
PERFORM err_hdl.
SET PROPERTY OF h_f 'Bold' = bold .
PERFORM err_hdl.
ENDFORM.Hi,
Look at the below thread, i posted complete code in this one, just copy that Program and past in your SAP and run the Program, it will create 3 sheets with the names also, then look at the Sheet name in the code, you will understand where to add the code
Re: format an excel
Regards
Sudheer -
How to use a variable as a table name in PL/SQL?
Hello all.
I was given one day to wrote a piece of PL/SQL code to do a query. That is,
First select two columns from one table and use them to build another table's name, then
join the two tables. I'm not sure if variables can be used in the select list, if possible,
how to reference them?
-- My code is
DECLARE
tablename varchar2(40);
CURSOR c1 IS
select a.sourcesystemcode, a.adminorganizationno from cdb1.organization_mapping a
where exists( select 1 from cdb1.organization_mapping b where
a.cdborganizationno = b.cdborganizationno and a.adminorganizationno != b.adminorganizationno)
order by a.cdborganizationno,a.adminorganizationno;
v_src_sys_cod cdb1.organization_mapping.sourcesystemcode%TYPE;
v_adm_org_no cdb1.organization_mapping.adminorganizationno%TYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_src_sys_cod, v_adm_org_no;
EXIT WHEN c1%NOTFOUND;
tablename := 'ODS1.SRC_' || v_src_sys_cod || v_adm_org_no || 'ACTORG_CURR';
select c.cdborganizationno, c.sourcesystemcode, c.adminorganizationno, c.sourceorganizationno, d.ibkcde, d.orgnam
from cdb1.organization_mapping c inner join tablename d on c.sourceorganizationno = d.orgidt;
END LOOP;
CLOSE c1;
END;
The error message says "... the table or view does not exist... line 18, column 66..."
It says the variable "tablename" wasn't build or build incorrectly.
Please give the solution.If the TABLEs being queried are already known, and it is just a matter of which one to query, perhaps you can CREATE a VIEW that uses all the TABLEs with a UNION ALL, and include an identifier COLUMN.
CREATE VIEW SRC_ALL_ACTORG_CURR
AS
SELECT 'aa' Name, ibkcde, orgnam FROM SRC_aa_ACTORG_CURR UNION ALL
SELECT 'bb' Name, ibkcde, orgnam FROM SRC_bb_ACTORG_CURR UNION ALL
SELECT 'cc' Name, ibkcde, orgnam FROM SRC_cc_ACTORG_CURR UNION ALL
SELECT 'dd' Name, ibkcde, orgnam FROM SRC_dd_ACTORG_CURR UNION ALL
SELECT 'ee' Name, ibkcde, orgnam FROM SRC_ee_ACTORG_CURR;
Then, in you query:
select c.cdborganizationno, c.sourcesystemcode, c.adminorganizationno, c.sourceorganizationno, d.ibkcde, d.orgnam
from cdb1.organization_mapping c inner join SRC_ALL_ACTORG_CURR d on c.sourceorganizationno = d.orgidt and d.Name = v_src_sys_cod || v_adm_org_no; -
How can I get the View Tab name on the Crystal Report Viewer at runtime?
When a report is displayed in the Windows Forms Crystal Report Viewer and the user drills into the report, the drill down view is displayed in a seperate view and is identified via a View tab at the top of the report. I can determine the index of the view tab that is currently selected, but I need to access the text that is on the View tab. The only properties that I've found that pertain to the "view" on the Crystal Report viewer are the ActiveViewIndex and the ViewCount. Unfortunately, neither of these items help me because they are not specific to a certain section of the report. Has anyone had any luck accessing the View Tab properties ? Thanks.
The tabs at the top of the page are nested within some of the viewers controls. Through trial and error you just have to find the right one. In this case the main part of the report is in the first control. This happens to be a TabControl. From there you can loop through the TabPages on the TabControl to grab the names of the tabs.
Here is a quick example of what I did to get the tab text. All this code was in a button click event.
Control oControl = crystalReportViewer1.Controls[0];
TabControl oTabControl = (TabControl)oControl.Controls[0];
foreach (TabPage oTabPage in oTabControl.TabPages)
MessageBox.Show(oTabPage.Text); -
How to get current tab name or tab id or related info?
Hi ,
I would like to hide/show tabs according to users' page privileges list. So I need get current tab ID or tab Name in runtime environment to know if show/hide it for current user. :APP_USER
Could you please provide any info about this requirement? Or do you have alternative method to control tabs' hide/show?
thanks
Ruiping最爱用中文 wrote:
Hi Jari,
Thanks for your info. Even if set authorize schema to tabs, I still need to get the relationship between "current tab" and "privilege&users". So I think evrm's hard-code method above is avaliable.I agree with Jari: APEX provides Authorization schemes specifically for this purpose. You need to reverse your thinking on how to implement this.
For more information consult the documentation on APEX security, specifically using authorization schemes to restrict access to pages and control rendering of components.
Tutorial: Adding Security to your Database Application (APEX 4.0)
Use Authorization Schemes to control access/rendering for security ("only managers see/access this page and it's associated tab"); and Conditions to control rendering for functional reasons ("region only displayed if account is in arrears").
Authorization Schemes have the benefits of being reusable, performing better, and allowing central maintenance of security-related code. This makes it easier to change the implementation—say moving from role information held in database tables to groups defined in LDAP.
I worked for a number of years with an application where authorization schemes are not properly used (decisions made before my involvement) and all security and business logic relating to rendering and processing is wrapped up in spaghetti code in conditions. It's impossible to maintain.
It is of course advisable to make both authorization scheme and business logic condition code more reusable and maintainable by locating it in API packages. -
I need the "Real" Table / Table Column names from a sql view
Firstly, we have a system with ~1000 tables and ~250 views. We have field level security on the table columns (in our code)
Now we have a lot of views which select data from the tables, but I need to get the "Table Column Name" that is linked in the view.
I know there are view columns that is not linked to a specific table column, (or concatenation of columns) so those columns can just return NULL.
From the sample you will see there is a view selecting data from another view. I know it is not the best sql performance (execution path) but that is another topic on its own.
I went through a lot of the sys.* stored procs or sys.* views to try and figure out if there is a view that we can use to get the expected results.
here is the sql code:
if
Exists (select
* from
sys.all_objects
where name =
'AliasView2')
drop view dbo.AliasView2
if
Exists (select
* from
sys.all_objects
where name =
'AliasView1')
drop view dbo.AliasView1
if
Exists (select
* from
sys.all_objects
where name =
'Table4')
BEGIN
alter table dbo.Table4
DROP CONSTRAINT [FK_T4_T3]
alter table dbo.Table4
DROP CONSTRAINT [PK_T4_Constraint]
drop table dbo.Table4
END
if
Exists (select
* from
sys.all_objects
where name =
'Table3')
BEGIN
alter table dbo.Table3
DROP CONSTRAINT [FK_T3_T2]
alter table dbo.Table3
DROP CONSTRAINT [PK_T3_Constraint]
drop table dbo.Table3
END
if
Exists (select
* from
sys.all_objects
where name =
'Table2')
BEGIN
alter table dbo.Table2
DROP CONSTRAINT [FK_T2_T1]
alter table dbo.Table2
DROP CONSTRAINT [PK_T2_Constraint]
drop table dbo.Table2
END
if
Exists (select
* from
sys.all_objects
where name =
'Table1')
BEGIN
alter table dbo.Table1
DROP CONSTRAINT [PK_T1_Constraint]
drop table dbo.Table1
END
create
Table dbo.Table1
T1_PK int
NOT NULL
Identity(1, 1)
CONSTRAINT [PK_T1_Constraint]
PRIMARY KEY (T1_PK),
T1_Field1 varchar
NULL,
T1_Field2 varchar
NULL,
create
Table dbo.Table2
T2_PK int
NOT NULL
Identity(1, 1)
CONSTRAINT [PK_T2_Constraint]
PRIMARY KEY (T2_PK),
T2_Field1 varchar
NULL,
T2_Field2 varchar
NULL,
T2_FK int
NOT NULL
CONSTRAINT [FK_T2_T1]
FOREIGN KEY (T2_FK)
REFERENCES dbo.Table1
(T1_PK)
create
Table dbo.Table3
T3_PK int
NOT NULL
Identity(1, 1)
CONSTRAINT [PK_T3_Constraint]
PRIMARY KEY (T3_PK),
T3_Field1 varchar
NULL,
T3_Field2 varchar
NULL,
T3_FK int
NOT NULL
CONSTRAINT [FK_T3_T2]
FOREIGN KEY (T3_FK)
REFERENCES dbo.Table2
(T2_PK)
create
Table dbo.Table4
T4_PK int
NOT NULL
Identity(1, 1)
CONSTRAINT [PK_T4_Constraint]
PRIMARY KEY (T4_PK),
T4_Field1 varchar
NULL,
T4_Field2 varchar
NULL,
T4_FK int
NOT NULL
CONSTRAINT [FK_T4_T3]
FOREIGN KEY (T4_FK)
REFERENCES dbo.Table3
(T3_PK)
GO
--Create a basic view to select some data
CREATE
VIEW dbo.AliasView1
AS
select
t2.T2_FK as Table2_ForeignKey,
t1.T1_Field1 as Table1_FieldOne,
t2.T2_Field1 as Table2_FieldOne
FROM Table1 t1
Left outer
join Table2 t2 on t2.T2_FK
= t1.T1_PK;
GO
--Create another view that select basic data, and also selecting data from view 1
CREATE
VIEW dbo.AliasView2
AS
select
v1.Table1_FieldOne
as Table1_FieldOne,
v1.Table2_FieldOne
as Table2_FieldOne,
t3.T3_Field1 as Table3_FieldOne,
t3.T3_Field2
FROM Table3 t3
Left outer
join AliasView1 v1 on v1.Table2_ForeignKey
= t3.T3_PK;
GO
--My attempt to get the desired output, but no luck
SELECT
col.COLUMN_NAME as AliasColumnName, col.DATA_TYPE, col.CHARACTER_MAXIMUM_LENGTH
as max_length, colu.*
FROM
information_schema.COLUMNS col
left
outer join
(SELECT
VIEW_SCHEMA, VIEW_NAME, COLUMN_NAME,
min(TABLE_NAME)
as TABLE_NAME
FROM information_schema.VIEW_COLUMN_USAGE colu
WHERE VIEW_NAME =
'AliasView2'
Group by VIEW_SCHEMA, VIEW_NAME, COLUMN_NAME
) COLU ON colU.VIEW_NAME
= col.TABLE_NAME
and colu.COLUMN_NAME
= col.COLUMN_NAME
left
outer join
(select a.name
as TableName, c.name
as FieldName
from sys.foreign_key_columns fk
join sys.all_objects a
on a.object_id
= fk.parent_object_id
join sys.all_columns c
on c.object_id
= a.object_id
and c.column_id
= fk.parent_column_id
join sys.all_objects ar
on ar.object_id
= fk.referenced_object_id
join sys.all_columns cr
on cr.object_id
= ar.object_id
and cr.column_id
= fk.referenced_column_id
join sys.schemas scr
on scr.schema_id
= ar.schema_id
) fks on fks.TableName
= colu.TABLE_NAME
and fks.FieldName
= colu.COLUMN_NAME
WHERE COL.TABLE_NAME
= 'AliasView2'
order
by col.ORDINAL_POSITION
This is the results being returned: (That is not 100% what I am looking for)
AliasColumnName
DATA_TYPE
max_length
VIEW_SCHEMA
VIEW_NAME
COLUMN_NAME
TABLE_NAME
Table1_FieldOne
varchar
1
dbo
AliasView2
Table1_FieldOne
AliasView1
Table2_FieldOne
varchar
1
dbo
AliasView2
Table2_FieldOne
AliasView1
Table3_FieldOne
varchar
1
NULL
NULL
NULL
NULL
T3_Field2
varchar
1
dbo
AliasView2
T3_Field2
Table3
The desired results must be like the following:
AliasColumnName
DATA_TYPE
max_length
VIEW_SCHEMA
VIEW_NAME
COLUMN_NAME
TABLE_NAME
Table1_FieldOne
varchar
1
dbo
AliasView2
T1_Field1
Table1
Table2_FieldOne
varchar
1
dbo
AliasView2
T2_Field1
Table2
Table3_FieldOne
varchar
1
dbo
AliasView2
T3_Field1
Table3
T3_Field2
varchar
1
dbo
AliasView2
T3_Field2
Table3
NOTE: the COLUMN_NAME and TABLE_NAME must the REAL field of the TABLE it belongs to and not only ONE LEVEL Higher’s ALIAS View NameNow we have a lot of views which select data from the tables, but I need to get the "Table Column Name" that is linked in the view.
If you are using SQL Server 2012/2014, then you can use
sys.dm_exec_describe_first_result_set (Transact-SQL) to gte the informations.
Olaf Helper
[ Blog] [ Xing] [ MVP]
Maybe you are looking for
-
i established a tab for my gmail account in the toolbar, can this tab indicate the status of new incoming gmail emails?
-
I've tried several different pages and websites and none of them will print. I'm using Windows 7 on a brand new Dell computer and Dell printer. Please help me. [email protected]
-
Problem with the cost centre budget is being copied to profit centres 1KE0
Hi Experts I am trying to cost centre budget is being copied to profit centres using transaction code 1KE0. The log displays all entries were successful but does not update the table and i did run foreground and backgound.can any one help me.
-
Hinge faulty? / Harddisk speed on 2011 Macbook Pro
I've just (4 days ago) moved from a silver unibody 2008 macbook pro to a new 2011 macbook pro, I'm noticing differences and so far they're not really positive . I like to work laying on the sofa with the base of the macbook resting vertically on my c
-
Why is photoshop only reading 4mb of ram?
I have photoshop 5.1 64bit and it is reading 24mb ram. When I upgraded to photoshop cc it is only reading 4mb. There was no option I seen for 64 bit systems.