Variable column names
I'm working on a data collection application. Actual device names to be logged can change. Two tables are used: a log "header" table that contains an entry with input descriptions (one record per "run") and another table that contains logged data every 10 secondss
Log header table:
DT | run_num | input1_desc | input2_desc |
xxxx 1234 inlet_temp zone_1_temp
Data table:
DT | run_num | input1 | input2 |
xxxx 1234 12.234 45.675
How can I create a view to show data with actual column names (ex: inlet_temp)? Or should db be re-designed?
Are you using an application express report to display the results?
If so, you could use the custom pl/sql headings for that purpose.
This example could get you started:
DECLARE
l_ret VARCHAR2 (500);
BEGIN
SELECT 'DT:RUN_NUM:' || input1_desc || ':' || input2_desc
INTO l_ret
FROM logheader
WHERE run_num = :p1_run_num;
RETURN l_ret;
END;These custom headings only make sense for a single run_num.
So create a report for the details :
select * from data where run_num = :p1_run_num; and use the above mentioned pl/sql block on the report attributes tab for a heading type of pl/sql.
The variable :p1_run_num refers to a variable on page 1 on which you set the current run_num value for the details.
Regards,
~Dietmar.
Similar Messages
-
Variable column name in a trigger
I have a table with many columns, and would like to make a log table of all the updates in the first one. So my idea was to bulid a "before update" trigger which would first create a cursor to get the column names from the user_tab_columns table. In a cursor loop it would check if the :new.column_data is somehow different from :old.column_data. If this was the case, trigger would build a sql statement for inserting old and new values into the log table, and then execute this statement using the "execute immediate".
Here i run into a problem, because i shuld pass the old and new values of a column instead of :new and :old variables, which are not bound in the execute immediate. Any suggestion besides writing a long trigger for checking each and every column name in a table?Or don't create it like this at all.
This way you'll get:
- complex trigger code
- a hard parse each and every insert into that log table
- a trashed shared pool, because it gets populated with all "almost the same" insert statements
Querying a log table probably is not something you do everyday, so it likely doesn't pay to store it in a complex way to make sure the retrieval goes smoothly.
If you want to log, you could do it in a single insert statement with all the information you could possibly need. This makes the code easy and the SQL sharable. It could look like below, and just skip the columns you don't need:
insert into log_table
( action
, action_date
, action_user
, column1_old_value
, column1_new_value
, did_column1_change
, column2_old_value
, column2_new_value
, did_column2_change
, columnN_old_value
, columnN_new_value
, did_columnN_change
values
( case when inserting then 'I' when updating then 'U' when deleting then 'D' end
, sysdate
, user
, :old.column1
, :new.column1
, case when updating('column1') then 'Y' else 'N' end
, :old.column2
, :new.column2
, case when updating('column1') then 'Y' else 'N' end
, :old.columnN
, :new.columnN
, case when updating('columnN') then 'Y' else 'N' end
);Or you can use a flashback archive instead of a log table in 11g, but I don't have enough experience with it yet to fully recommend that one.
Regards,
Rob. -
How to make dynamic query using DBMS_SQL variable column names
First of all i will show a working example of what i intend to do with "EXECUTE IMMEDIATE":
(EXECUTE IMMEDIATE has 32654 Bytes limit, which isn't enough for me so i'm exploring other methods such as DBMS_SQL)
-------------------------------------------------CODE-----------------------------------
create or replace PROCEDURE get_dinamic_query_content
(query_sql IN VARCHAR2, --any valid sql query ('SELECT name, age FROM table')
list_fields IN VARCHAR2) --list of the columns name belonging to the query ( arr_list(1):='name'; arr_list(2):='age';
-- FOR k IN 1..arr_list.count LOOP
-- list_fields := list_fields || '||content.'||arr_list(k)||'||'||'''~cs~'''; )
AS
sql_stmt varchar (30000);
BEGIN
sql_stmt :=
'DECLARE
counter NUMBER:=0;
auxcontent VARCHAR2(30000);
CURSOR content_cursor IS '|| query_sql ||';
content content_cursor%rowtype;
Begin
open content_cursor;
loop
fetch content_cursor into content;
exit when content_cursor%notfound;
begin
auxcontent := auxcontent || '||list_fields||';
end;
counter:=counter+1;
end loop;
close content_cursor;
htp.prn(auxcontent);
END;';
EXECUTE IMMEDIATE sql_stmt;
END;
-------------------------------------------------CODE-----------------------------------
I'm attepting to use DBMS_SQL to perform similar instructions.
Is it possible?Hi Pedro
You need to use DBMS_SQL here because you don't know how many columns your query is going to have before runtime. There are functions in DBMS_SQL to get information about the columns in your query - all this does is get the name.
SQL> CREATE OR REPLACE PROCEDURE get_query_cols(query_in IN VARCHAR2) AS
2 cur PLS_INTEGER;
3 numcols NUMBER;
4 col_desc_table dbms_sql.desc_tab;
5 BEGIN
6 cur := dbms_sql.open_cursor;
7 dbms_sql.parse(cur
8 ,query_in
9 ,dbms_sql.native);
10 dbms_sql.describe_columns(cur
11 ,numcols
12 ,col_desc_table);
13 FOR ix IN col_desc_table.FIRST .. col_desc_table.LAST LOOP
14 dbms_output.put_line('Column ' || ix || ' is ' ||
15 col_desc_table(ix).col_name);
16 END LOOP;
17 dbms_sql.close_cursor(cur);
18 END;
19 /
Procedure created.
SQL> exec get_query_cols('SELECT * FROM DUAL');
Column 1 is DUMMY
PL/SQL procedure successfully completed.
SQL> exec get_query_cols('SELECT table_name, num_rows FROM user_tables');
Column 1 is TABLE_NAME
Column 2 is NUM_ROWS
PL/SQL procedure successfully completed.
SQL> exec get_query_cols('SELECT column_name, data_type, low_value, high_value FROM user_tab_cols');
Column 1 is COLUMN_NAME
Column 2 is DATA_TYPE
Column 3 is LOW_VALUE
Column 4 is HIGH_VALUE
PL/SQL procedure successfully completed.I've just written this as a procedure that prints out the column names using dbms_output - I guess you're going to do something different with the result - maybe returning a collection, which you'll then parse through in Apex and print the output on the screen - this is just to illustrate the use of dbms_sql.
best regards
Andrew
UK -
Query from variable column name?
Running on LAMP
Table - CONTACTS (35 COLUMNS APPROX)
I want to be able to create a results page from a detailed
query.
My first attempt was to include 35 text fields in a form and
then build the query: like '%namesearch%' and like
'%companysearch%' and like '%companytype%' etc. etc. etc.
But this is time consuming and prone to bugs.
I though a much easier way would be to have two fields: one
criteria field and one field representing the column you want to
search in....
Hmm...
This is the query that I thought might work.
SELECT * FROM CONTACTS
WHERE 'colsearch' LIKE '%critsearch%'
ORDER BY COMPANY, FULLNAME
Obviously 'colsearch' is a variable from a menu drop down
field.
Strangely, if I set the default value for colsearch as
COMPANY and default value for critsearch as '%', it does seem to
return a result (all records) on the page load (I have the form and
results on the same page) but if I hit submit, it returns no
recordset!
Is this even possible?
CODE:
$colsearch_recordlookup = "COMPANY";
if (isset($HTTP_POST_VARS['scolumn'])) {
$colsearch_recordlookup = (get_magic_quotes_gpc()) ?
$HTTP_POST_VARS['scolumn'] :
addslashes($HTTP_POST_VARS['scolumn']);
$critsearch_recordlookup = "%";
if (isset($HTTP_POST_VARS['scriteria'])) {
$critsearch_recordlookup = (get_magic_quotes_gpc()) ?
$HTTP_POST_VARS['scriteria'] :
addslashes($HTTP_POST_VARS['scriteria']);
mysql_select_db($database_dbcrm1, $dbcrm1);
$query_recordlookup = sprintf("SELECT * FROM CONTACTS WHERE
'%s' LIKE '%%%s%%' ORDER BY COMPANY, FULLNAME",
$colsearch_recordlookup,$critsearch_recordlookup);RichardODreamweaver wrote:
> This is the query that I thought might work.
>
> SELECT * FROM CONTACTS
> WHERE 'colsearch' LIKE '%critsearch%'
> ORDER BY COMPANY, FULLNAME
>
> Obviously 'colsearch' is a variable from a menu drop
down field.
The name of the column should not be in quotes:
SELECT * FROM CONTACTS
WHERE colsearch LIKE '%critsearch%'
ORDER BY COMPANY, FULLNAME
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Passing column names in as a variable
I know in SQL server there is a way you can pass a variable in to the procedure and put that variable as a column name, Oracle doesn't seem to pick the variable up as a column name. Can anyone show me how with a simple select statement
bgulcu wrote:
I'm having a similar problem. I didn't want to open up another thread since it's related.
Problem:
I have 107 columns on a table. The number of columns increases almost every month.
I have an array of columns, which I have gathered from the db. I need to pivot the whole table, but due to indefinite number of columns, it had to be dynamic sql.
Premature Solution:
Right now, the solution that we have runs through the array of columns and uses dynamic sql to query for every single cell to get the value. Considering that we have 1000+ rows on this table, in order to do the transformation, we send 107000+ queries which is just ugly. It works, but I don't feel comfortable about it.
Solution:
Since we are able to get a single row of 107 columns, why don't we gather the whole row, and get the information out from it instead of tiring up the server? The indefinite number of columns is a problem, but we have the whole list in an array, lets say feature_array. So what I want to do is to get the date from the row, ie myRow.feature_array(1), myRow.feature_array(2), ..., myRow.feature_array(i).
I just learned that it's not possible to do it (from this thread).You just misunderstood the contents of this thread. What we said is that you can't do such things with static SQL, so you need to use dynamic sql.
What has also been told was that using dynamic sql for such a purpose is just the result of a bad design. Use a relational table as a bi-dimensional array is not right, it is possible but it's not right for the simple reason that you need a procedural language to process the dynamic SQL that is needed to retrieve data.
Probably on database programming there's only a rule of thumb and it says: "Maximize SQL minimize PL/SQL" (or any procedural language like java). The only exceptions to keep code in procedural language must depend on a complexity reduction determined by its use. In your case there is no complexity reduction determined by the use of a procedural language.
In the thread on this link(Schema integrity I discussed about how to implement a solution you can use as alternative for submitting queries with variable column names.
If you introduce parameter management in your model probably you could have your problem solved with the use of only a single SQL statement. And that may be a good designed model.
Bye Alessandro -
Using variable coulmn name in sql function
Hi there,
I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
My function is:
CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
TEMP_ID NUMBER;
TEMP_USER_ID NUMBER;
BEGIN
SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
IF TEMP_ID > TEMP_USER_ID THEN
LOOP
SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
EXIT WHEN TEMP_USER_ID = TEMP_ID;
END LOOP;
ELSE
WHILE TEMP_ID < TEMP_USER_ID LOOP
SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
END LOOP;
END IF;
COMMIT;
RETURN (TEMP_ID);
END;
What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
eg ifaTrigger = 'SQ_U_FINALRESULT'
than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
The above function will not work, but what will?????
I hope you can help me out!
CheersA very strange function indeed.
But here is what I think he meant to do:
SQL> create procedure reset_sequences
2 ( p_sequence_name in varchar2
3 , p_nextval out number
4 )
5 is
6 l_nextval1 number;
7 l_nextval2 number
8 ;
9 procedure reset_sequence_value
10 ( p_sequence_name in varchar2
11 , p_current_value in number
12 , p_new_value in number
13 )
14 is
15 l_dummy number;
16 begin
17 execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
18 execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
19 execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
20 end reset_sequence_value
21 ;
22 begin
23 execute immediate
24 'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
25 into l_nextval1, l_nextval2
26 ;
27 if l_nextval1 < l_nextval2
28 then
29 reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
30 end if
31 ;
32 if l_nextval1 > l_nextval2
33 then
34 reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
35 end if
36 ;
37 p_nextval := greatest(l_nextval1,l_nextval2)
38 ;
39 end reset_sequences;
40 /
Procedure is aangemaakt.
SQL> show err
Er zijn geen fouten.
SQL> create sequence testseq start with 5 increment by 1
2 /
Reeks is aangemaakt.
SQL> create sequence testseq_user start with 2 increment by 1
2 /
Reeks is aangemaakt.
SQL> declare
2 l_new_value number;
3 begin
4 reset_sequences('testseq',l_new_value);
5 dbms_output.put_line(l_new_value);
6 end;
7 /
5
PL/SQL-procedure is geslaagd.
SQL> select testseq.currval from dual
2 /
CURRVAL
5
1 rij is geselecteerd.
SQL> select testseq_user.currval from dual
2 /
CURRVAL
5
1 rij is geselecteerd.Regards,
Rob. -
Can I use bind variable instaed of writing static COLUMN Name
Hi , I am having a table containing id and column names, the data is stored against that id in other tables. Now I wish to update data into another table so that it goes into apppropriate column without using decode function.
I am trying to do this:
EXECUTE IMMEDIATE 'update TEST set :1 = :2
where PROJECT_ID= :3 and UNIQUE_ID= :4' using P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID;
the values P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID are populated using a cursor in PL/SQl
Is this statement valid? If not can you tell me how to do it as I am getting some error I am unable to comprehend.
thanks
RishabhColumn names cannot be substituted at run-time as bind variables. If you need to specify the column name at run-time, you'd need to construct a new string and execute that string dynamically, i.e.
EXECUTE IMMEDIATE 'UPDATE test SET ' || p_dest_column || ' = :1 ' || ...From a data model standpoint, storing column names as data elements in another table is generally a rather poor idea. It's likely to make ad-hoc reporting nearly impossible and to cause a lot more parsing than would otherwise be required.
Justin -
How to use variable in :old. variable instead of :old.column name.
My requirement is to update the audit_update table with the old value and new value when an update statement gets executed. If i use :old.columnname the purpose is getting resolved.
My requirement is to loop through the columns taken dynamically and update the audit_update_details table. The updation is taking place in a function that called.
The first cursor holds the column name of a given table.
I have to use a statement like :old.variablename . where the variable holds the column name .
Is their an alternative?
CREATE OR REPLACE TRIGGER INSERT_EMP1
AFTER INSERT OR UPDATE OR DELETE
ON EMP FOR EACH ROW
declare
v_seq number(5);
v_result boolean;
v_col_name varchar2(20);
CURSOR FIRSTCURSOR IS
select COLUMN_NAME from user_tab_columns where table_name like 'EMP';
begin
if inserting then
INSERT INTO aud_details VALUES(seq_aud_log_id.nextval,'Emp','I','eno',:NEW.ENO);
end if;
if DELETING then
INSERT INTO aud_details VALUES(seq_aud_log_id.nextval,'Emp','D','eno',:OLD.ENO);
end if;
IF UPDATING THEN
INSERT INTO aud_details VALUES(seq_aud_log_id.nextval,'Emp','U','eno',:OLD.ENO);
select seq_aud_log_id.currval into v_seq from dual;
open FIRSTCURSOR;
LOOP
FETCH FIRSTCURSOR INTO v_col_name;
EXIT WHEN FIRSTCURSOR%NOTFOUND;
BEGIN
-- How to make the code to work successfully.
if (:old.v_col_name != :new.v_col_name) then
v_result := insert_fn('emp',:old.eno, v_col_name , :old.v_col_name, :new.v_col_name, v_seq );
end if;
end;
end loop;
THe below is an example that uses the column name .Instead of column name i need to use the variable. So that the trigger functions for any given table.
/* IF (:old.ename != :new.ename) THEN
v_result := insert_fn('emp',:old.eno, 'ename' , :old.ename, :new.ename, v_seq );
END IF;
IF (:old.dno != :new.dno) THEN
v_result := insert_fn('emp',:old.eno, 'dno' , :old.dno, :new.dno,v_seq );
END IF;
IF (:old.salary != :new.salary) THEN
v_result := insert_fn('emp',:old.eno, 'salary' , :old.salary, :new.salary, v_seq );
END IF;
END IF;
END INSERT_EMP1;
thanks,
vinodhAs Solomon said, it's not possible, but you could write a procedure that would generate the code to do it for each individual column. You could then execute the code generator procedure any time the tables DDL changed in order to update the triggers code.
-
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to use column name as variable in select statement
hi,
i want to make a sql query where in select statement using variable as a column name. but its not working plz guide me how can i do this.
select :m1 from table1;
regardsHi,
Is this what you want..
SQL> select &m1 from dept;
Enter value for m1: deptno
old 1: select &m1 from dept
new 1: select deptno from dept
DEPTNO
10
20
30
40
SQL> select &m1 from dept;
Enter value for m1: dname
old 1: select &m1 from dept
new 1: select dname from dept
DNAME
ACCOUNTING
RESEARCH
SALES
OPERATIONS
SQL> select &&m1 from dept;
Enter value for m1: loc
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTON
SQL> select &&m1 from dept;
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTONIf you use single '&' then each time you fire the query, It will ask for the new value..
But if you will use double '&&' the value of m1 will be persistent across the session..
Twinkle -
How to put the column name and variable value in the alert message.
Dear,
how can i put the column name and variable value in the alert message text. i want to display an alert which tell the user about the empty textboxes. that these textboxes must be filled.
Regards:
Muhammad Nadeem
CHIMERA PVT. LTD.
LAHORE
[email protected]Hello,
The name of the item that fires the current trigger is stored in the :SYSTEM.TRIGGER_ITEM system variable.
The value contained in this item can be retrived with the Name_In() built-in
value := Name_In( 'SYSTEM.TRIGGER_ITEM') ;
LC$Msg := 'The item ' || :SYSTEM.TRIGGER_ITEM || ' must be entered' ;
Set_Alert_Property('my_alert_box', ALERT_MESSAGE_TEXT, LC$Msg ) ;
Ok := Show_Alert( 'my_alert_box' ) ;
...Francois -
Use variable in SQL for column name
Hi All,
We want to use a user input as a column name in APEX.
For e.g user will enter "ALLOWABLE_AMOUNT" then the query will be as follows :
select Rule,rule_name,rule_desc,"User Input" from rule_dim
where "User_input" > 100
So here the User_input will be substitued with Allowable_amount. Is this doable using any bind/substitution variables ? I tried ":P2_USER_VARIABLE" and "&P2_USER_VARIABLE." but did not work.
Please advice.Hi Andy,
You do that with an Interactive Report and a Dynamic Action.
I'll assume that you're using APEX 4.2
Here's how:
Create Page 2 with an Interactive Report
Create New Page > Report > Interactive Report > Next > Next
Enter a SQL Select statement: select Rule,rule_name,rule_desc from rule_dim
Next > Create > Edit Page
Create the item P2_USER_VARIABLE
Add Item > Number Field > Next
Item Name: P2_USER_VARIABLE
Next > Next > Next
Source Used: Always, replacing any existing value in session state
Source Type: Static Assignment (value equals source attribute)
Create Item
Create a Dynamic Action to refresh the Interactive Report when P2_USER_VARIABLE is changed
Add Dynamic Action
Name: Refresh IRR
Next >
Event: Lose Focus
Selection Type: Item(s)
Item(s): P2_USER_VARIABLE
Next >
Action: Refresh
Next >
Selection Type: Region
Region: Report 1 (10)
Create Dynamic Action
Add the ALLOWABLE_AMOUNT to the Interactive Report
Report 1
Region Source: SELECT * FROM (select Rule,rule_name,rule_desc, :P2_USER_VARIABLE AS ALLOWABLE_AMOUNT from rule_dim) WHERE ALLOWABLE_AMOUNT > 100
Apply Changes > Apply Changes
Get the Interactive Report to submit P2_USER_VARIABLE
Report 1
Page Items to Submit: P2_USER_VARIABLE
Apply Changes
Change the Heading for ALLOWABLE_AMOUNT in the Interactive Report
Interactive Report
Change the Heading of ALLOWABLE_AMOUNT to &P2_USER_VARIABLE.
Apply Changes
Run
Enter something into the USER VARIABLE field and select something else on the page. Watch the last column update to that value.
Tim. -
hi All,
please I would like to write a query such that the column names is to be variables.
"select &C1, &C2 from T1 ;" it's working in sql developer but it's not working on apex region.
thanks a lot.Actually, the ADF Faces demo site from Oracle looks (potentially) really cool. I have no idea how it works in the background though so it could be a nightmare. I'd appreciate it if you would post back here once you've given it a try. I'd be genuinely interested to know what it's like to work with.
Its a bit funny because APEX seems to be coming on leaps and bounds but Oracle don't advertise it much (probably because it's free). That could well be a view that is tainted by being an active member of the community though so it would be intriguing to see what people 'from the outside, looking in' feel about it. You got many people there that have opinions about APEX? The java boys at the place I'm contracting at seem to look down on us with disdain!
Cheers
Ben -
If variable name is the same as the column name in procedure ?
If variable name is the same as the column name in procedure , What should i do?
For Example :
CREATE OR REPLACE PROCEDURE "TEST_PROC" (MIN_SALARY in UMBER)
as
begin
INSERT INTO TEST SELECT JOB_ID,MIN_SALARY FROM JOBS WHERE MIN_SALARY = MIN_SALARY;
end;You could follow a better naming convention and have the parameters to the procedures named in a way so as not to be confused with column names.
You could prefix the variable names with the name of the procedure they appear in but then what if your have procedure names same as table names?
SQL> create or replace procedure test_proc(sal in number) is
2 cnt number ;
3 begin
4 select count(*) into cnt from scott.emp where scott.emp.sal = test_proc.sal ;
5 dbms_output.put_line('cnt='||cnt) ;
6 end ;
7 /
Procedure created.
SQL> set serveroutput on
SQL> exec test_proc(800) ;
cnt=1
PL/SQL procedure successfully completed.
SQL>If you search you can find several posts here itself on naming convention to avoid such issues in first place. -
Having a column name as a variable within a query,Problem!!!!
I have a problem with a simple query shown below
SELECT * FROM DisneyWHERE Upper(COLNAME) LIKE UPPER('%' || SEARCHSTRING || '%');SELECT * FROM Disney
WHERE Upper(COLNAME) LIKE UPPER('%' || SEARCHSTRING || '%');
My problem, The colname variable is not being recognised as a column name for example
A user can select to view a set of characters from the DB by username, movies, etc etc (they select this from a combobox) They then enter a search string(textbox)
colname = username
Searchstring = pluto
SELECT * FROM Disney
WHERE Upper(COLNAME) LIKE UPPER('%' || SEARCHSTRING || '%');
The problem is orac;e does not seem to be picking up that colname is a column name and seems to be doing a simple comparison. To make this clearer
it' seems to be trying to match username = pluto
rather than finding pluto in the username column.
Has anyone got any ideas how i can get around this. I have a strange feeling it is something to do with dynamic pl/sql but i am new to oracle so i have no idea how to write dynamic queries. Any help would be muchly appreciated
I am using oracle 11g and visual studio .net 2005user10372910 wrote:
If you can refer me to any material you think i would find helpful to read or experiment with pls let me knowThe online documentation is a good place to look...
http://www.oracle.com/pls/db102/homepage?remark=tahiti
Start with the concepts guide which gives a good background to the Oracle database.
Look up "bind variables", "hard parsing"/"soft parsing" of queries
In light of what boneist highlighted, you may also want to do a search for "function based indexes".
Those topics should give you some insight into the performance issues around queries and why it is better to write SQL that uses bind variables and get's soft parsed (re-usable SQL) rather than writing dynamic queries that become hard parsed (non-reusable SQL).
Maybe you are looking for
-
IPhone webclips can't be deleted? [HELP]
I have a bit of an annoying problem. I upgraded my original phone to the 2.0 software and started getting rid of webclips I don't need anymore. Unfortunately, a few of the clips wouldn't go away. They disappear when you touch the "X", but reappear an
-
Controlling the size of You-tube links
Is there a way to control the size of the graphic from an You-Tube link? I have embedded a link to the clip in an HTML snippet but don't seem to be able to affect the size of the initial image without truncating some of the image. Anyway to expand or
-
Concur (Third Party Tool to enter expenses) integration with Oracle Payables
Hi Gurus, My client is replacing Oracle iExpenses with Concur (Third Party Tool to enter expenses). I need to work on the inbound and outbound interfaces from Concur to Oracle Payables and vice versa. Here my concern is: how to deal with the Credit c
-
First Do we need to download a browser for internet search in i3???
First Do we need to download a browser for internet search in i3???
-
Remove Mail IMAP option?
Hey, Small issue but its annoying me! How do I get rid of this under the sync Mail section? Thanks!