Storing Column-Name into variable? Possible?
Hello from germany
I got stuck with following:
How is it possible to store the name of a column into a variable or is it possible to put an index "on" a column?
The reason for this: I need to fill and check a complete column!
Thanks for Your help!
Best regards
Marlon
Your question is not clear. Howver, this is what I guess you want to do.
Example, Check that the Emplyee Number I enter is KING. Check and Print message accordingly.
Here i user PL/SQL run in SQLPlus
SET VERIFY OFF
SET SERVEROUTPUT ON
DECLARE
EMP_NAME VARCHAR(30);
BEGIN
SELECT ENAME
INTO EMP_NAME
FROM EMP
WHERE EMPNO = &EMP_NUMBER;
IF EMP_NAME = 'KING'
THEN
DBMS_OUTPUT.PUT_LINE('The Emplyee Name is: '||EMP_Name);
ELSIF EMP_NAME != 'KING'
THEN
DBMS_OUTPUT.PUT_LINE('The Emplyee is not KING but: '||EMP_Name);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE('The Employee Number Entered is Invalid');
END;
/
Similar Messages
-
Store Column-Name into variable
Hello from germany
I got stuck with following:
How is it possible to store the name of a column into a variable or is it possible to put an index "on" a column?
The reason for this: I need to fill and check a complete column!
Thanks for Your help!
Best regards
MarlonThose sure are unrelated questions. Lets say we have a table like this:
SQL> CREATE TABLE t (
2 a number,
3 b varchar2(8),
4 c date );
Table created.You can get a column name like this:
SQL> set serveroutput on
SQL> DECLARE
2 second_col VARCHAR2 (30);
3 BEGIN
4 SELECT column_name
5 INTO second_col
6 FROM user_tab_columns
7 WHERE table_name = 'T'
8 AND column_id = 2;
9 DBMS_OUTPUT.PUT_line(second_col);
10 END;
11 /
B
PL/SQL procedure successfully completed.
SQL> You can put an index on a column like this:
SQL> CREATE INDEX t_n1 ON t(b);
Index created.And you can add data to the table like this:
SQL> insert into t(a, b) values (4, 'asdf');
1 row created.
SQL> select * from t;
A B C
4 asdf
SQL> -
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 -
WRAP JTable Column Name into 2 lines
I have a JTable with a long column Name. Can I wrap the Column Name into multiple (2) lines.
baskaraninfo wrote:> set the following to a table column,<html><body>Employee<br>Name</body></html>>The break tag got lost cos you didnt use the code tags
<html><body>Employee<br>Name</body></html> -
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 -
Sharepoint Workflow : how to get document full path + file name into variable?
Hi,
Anybody knows how to get document full path + file name into a variable in Sharepoint 2010 workflow?
Example http://sp1:80/InvoiceQueue/Shared Documents/123.pdf
I am using List Workflow which links to a document library.Hi SAMSUNG,
According to your description, my understanding is that you want to get the full path of a document in a list workflow.
You can set the variable to the Enconded Absolute URL of the document. The screenshot is my testing. In my testing (in the red area), when the title of a document was equal to the tile of the current item, set a variable to the Enconded Absolute URL of the
document. I used ‘Log to history list’ to check the value of the variable in Workflow History .
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Adding column name into tables.
Hi guys,
i have a panel which consist of a scroll table which i am not sure how to i add column names tru this type of coding. and some more i have to retrieve info from the database and display into this table. can someone pls guide me how to i add in the column names and how do i retrieve info out from db and displying it onto the table? a million thanks! :)
* This method initializes jScrollPane_viewLogTable
* @return javax.swing.JScrollPane
private JScrollPane getJScrollPane_viewLogTable() {
if (jScrollPane_viewLogTable == null) {
jScrollPane_viewLogTable = new JScrollPane();
jScrollPane_viewLogTable.setBounds(new java.awt.Rectangle(27,30,460, 200));
jScrollPane_viewLogTable.setViewportView(getJTable_viewLogTable());
return jScrollPane_viewLogTable;
* This method initializes jTable_viewLogTable
* @return javax.swing.JTable
private JTable getJTable_viewLogTable() {
if (jTable_viewLogTable == null) {
jTable_viewLogTable = new JTable();
return jTable_viewLogTable;
}TitusIt's not my code, it's just Java.
C'mon, read the javadocs.
Or look at this:
http://www.exampledepot.com/egs/java.sql/GetRsColCount.html
% -
UIX get EO column names into a messageChoice
I'm working on building a search function into my form which will allow the user to enter an arbitrary search string into a text box and then provides a list of columns in the table to be searched on. Is there any way to populate that list box (messageChoice) with the column names from the database dynamically? And if so, could I have the value set to those and the label set to the 'human readable' label text used on my forms?
NickTry looking at the section "Apply a filter to the Lov Window" here:
http://otn.oracle.com/products/jdev/howtos/10g/adf_uix_lov_ht/index.html -
Get column names into a VB program, for an SQL query that joins tables
use [mydatabase]
select * from InvNum inum
left join _btblInvoiceLines ilin
on inum.autoindex = ilin.iinvoiceid
left join stkitem s
on ilin.istockcodeid = s.stocklink where InvNumber = 'IVQ0834' or InvNumber = 'IVQ0835'
I need to get out the column names in a VB program in the same order they would appear in the SQL query above...
I want to use something like:
select column_name from information_schema.columns where TABLE_NAME = ....
except there are several tables involved above so I dont know the format!If you execute the query in your program using the SqlDataReader.ExecuteReader method, the column names will be available via the GetName method of the returned reader. But note that your query may return multiple columns with the same name.
Dim reader As SqlDataReader = command.ExecuteReader()
For x = 0 To reader.FieldCount - 1
Console.WriteLine(reader.GetName(x))
Next x
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
How to call the column names into the prompt and display values dynamically
Hi,
i have a typical requirement where I have to call 3 columns into the AGE Prompt (I know we can use the Column Selector to call the columns) .Below is the Screen Shot.
!http://i46.tinypic.com/2qjfukh.jpg!
2nd Requirement)
The three columns I have are order Date, Ship Date and Entry Date.
Whenever I click on Orderdate from the Prompt, It should dynamically show its values in the report.
and When I click on the Ship Date from the Prompt, it should display the corresponding values in the report.
and so on with the Entry Date.
Can anybody help me how to acheive this.
Thanks a ton.Ok so then you can use a fake column prompt. Here's one quick approach (nicer and cleaner with LOV tables but I don't if you have any of those).
- Create a fresh prompt using any column you want.
- Open the column formula using the fx button and replace the formula with 'abc'.
- Use "SqL Results" as the "Show" option.
- SQL:
select case when 1=0 the Markets.Region else 'Order Date' from Paint.Markets UNION ALL
select case when 1=0 the Markets.Region else 'Ship Date' from Paint.Markets UNION ALL
select case when 1=0 the Markets.Region else 'Entry Date' from Paint.Markets
- Set Variable = Presentation Variable = @{vPresVarSelectedDate}{Order Date}
- Label = Date
Then in the request, you change the column formula for the date. I'm going to make it short and just assume you called your time dimension alias(es) like the lowest grain:
"@{vPresVarSelectedDate}{Order Date}"."@{vPresVarSelectedDate}{Order Date}"
Cheers,
C. -
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 -
Hi all,
In an interface, I've got a column which has the same name as a variable.
When I execute it in ODI 10g all is fine.
With ODI 11g, it replace the column name by the variable one. If the variable has no value, I've got an SQLException.
I believe it comes from the colon.
In the execution code, I have
INSERT ... VALUES PROJECT.NAME instead of NAME.
I assume that ODI interprets the NAME with the variable name instead of the column name.
Has anyone experienced it ?
Thanks.Hi,
I just tried to reproduce your issue, I didn't experience the case where ODI takes variable name instead of column name. ODI should be able to differentiate between column name and variable name with '#' Symbol prefixed to it. Any name prefixed with #, ODI thinks thats a variable and, it need to be declared in a package.
In your case, looks like issue is not with the NAME, its with variable having no value. May be that ODI 10g has a default value. However, if a variable has no value, its definitely going to fail the process.
Regards,
K -
Presentation variable in column name
Is there any way to add in column name presentation variable?
Example
*2007* =tmp_2ybefore
*2008* =tmp_ybefore
This variables are defined in prompt
Sale *2007* -- Sale *2008*
1,22------------2,86
4,44------------3,29
Edited by: Micek on 2009.04.10 09:15hi
check this...
http://oraclebizint.wordpress.com/2008/01/25/oracle-bi-ee-101332-dynamic-column-headers-using-presentation-variables-sets-and-conditional-formatting/
but it has its own disadvantages.... see -
What is the order of Column Names in Sqlite query results?
I am writing an application using Adobe Air, Sqlite, and Javascript.
After writing the following select statement:
SELECT field1, field 2, field 3, field 4 FROM TableA;
I would like to get the columnName/data combination from each row -- which I do successfully with a loop:
var columnName="";
for (columnName in selResults.data[i]) {
output+=columnName + ":" + selResultsdata[i][columnName] + ";";
My issue is that the column names come out in a different order every time I run the query and never once have they come out in the desired order -- field 1, field 2, field 3, field 4. If I run the query in Firefox's Sqlite Manager, the columns come out in the "proper" order. When I run them in Adobe Air, the order will be the same if I run the query mulitple times without closing the app. If I make a change such as declaring the columnName variable with "" before the for column, or declare it as (var = columnName in selResults.data) , then the order changes. If I shut down my app and re-open after lunch and run query, it comes out in another order. At this time, I'm not interested in the order of the rows, just the order of the columns in each output row. I've even tried assiging an index to columnName which seems to just pick up a single letter of the columnName.
I'm in the process of changing my HTML presentation of the data to assign a precise columnName to an HTML table title, but I'm reluctant to let go of the above concept as I think my separation of HTML/presentation and Javascript would be better if I could use the solution described above.
So, does anybody know how to force the order of the columnNames in my output -- or what I'm doing to cause it to come out in a different order?
JeaneTechnically there isn't any "order" for the return columns. They aren't returned as an Array -- they're just properties on an Object instance (a "generic object"). The random order you're seeing is the behavior of the for..in loop iterating over the properties of the object. Unfortunately, with a for..in loop there is no guaranteed order for iterating over properties (and, as you've seen, it tends to vary wildly).
The only solution is to create your own list of the column names and sort it the way you want to, then use that to create your output. For example, use the for..in loop to loop over the properties, but rather than actually get the values, just dump the column names into an Array:
var columnName="";
var columns = [];
for (columnName in selResults.data[i]) {
columns.push(columnName);
columns = columns.sort(); // just uses the default alphabetical sort -- you would customize this if desired
var j = 0;
for (j = 0; j < columns.length; j++) {
columnName = columns[j];
output+=columnName + ":" + selResultsdata[i][columnName] + ";"; -
Alias name for the column name in Prompt
Hi,
I have a scenario where I am taking column names into prompt. I have used the following SQL in the SQL results under "Show" option of the Prompt.
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' END FROM " Real Time"
UNION ALL
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' END FROM "Real Time"
My problem here is I am getting the column names into the Prompt as "Orders"."By OrderDate" and "Orders"."By ShipDate", which is not acceptable and readable for mat for the user. Is there any way that I can assign an alias name for the column name such as OrderDate and ShipDate in the above SQL.
Your quick respose is appreciated.
Thanks,
Ramahi,
try an alternative one....in your administrator make new columns with alias to ones you want...so you wiil be able to show whatever you want.
Otherwise,is it possible to show
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' as "xxxxxxxxxxxxx"END FROM " Real Time"
UNION ALL
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' as "yyyyyyyyyyyyyyyy"END FROM "Real Time"
Ending,you want the data from your columns?or just the name??
hope i helped...
http://greekoraclebi.blogspot.com/
Maybe you are looking for
-
Urgent - Not able to Print back page for Last Page in SAP Script.
Hello All, I need to Print back page in SAP Script, I am able to do it by setting print mode as D, but now the problem is, it does not print back page for last page. For eg. if there are 3 pages it prints back page for first two. If there is only one
-
The location function in Reminders doesn't work at iphone 3gs and ipad?
Hello, how can I use the Location feature in the new Reminder app? If I add a new reminder there is no function to put in the location, just the day and the clocktime? Icloud is already installt and worked! It doesn't work at Iphone 3GS and also not
-
How to remove history on ipod when i no longer have the ipod
Hi so i recently gave my nephew my ipod touch while after thinking about it i really dont want him to be able to download anything with my credit card number is there any way i can remove it even though its no longer in my possen?
-
In some folders I get duplicates (or even multiple) copies of the same photograph. How do I stop this happening or when it does how do I delete the extra copies I don't want. Plus from time to time the photos in one folder will appear in another?
-
Good Helping material for Java Embedding Activity
I want some good tutotial on Java Embedding activity and their use. And how to get the values inside Java Embedding activity and see logs at which location ? Is there anyway to print System.out statement in Java Embedding activity ? Where to see the