Pound/Number sign in Column Name + Custom SQL
Has anyone gotten a custom sql partner link to work when a column name being referenced has a # sign in it?
For the sake of simplifying the example to make it clear:
select field1, field2
from table1
where
field_# = #variableName
Is there a way to edit the WSDL to tell it to look for say the $ sign for variable replacement as opposed to the # sign?
Thanks in advance
I don't believe so as this is a toplink requirement.
A workaround would be to create a view renaming the column field_#.
cheers
James
Similar Messages
-
Using column number inplace of column name in SQL Select statement
Is there a way to run sql select statements with column numbers in
place of column names?
Current SQL
select AddressId,Name,City from AddressIs this possible
select 1,2,5 from AddressThanks in Advanceuser10962462 wrote:
well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_rowcount NUMBER := 0;
BEGIN
-- create a cursor
c := DBMS_SQL.OPEN_CURSOR;
-- parse the SQL statement into the cursor
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
-- execute the cursor
d := DBMS_SQL.EXECUTE(c);
-- Describe the columns returned by the SQL statement
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
-- Bind local return variables to the various columns based on their types
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); -- Number
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); -- Date
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Any other type return as varchar2
END CASE;
END LOOP;
-- Display what columns are being returned...
DBMS_OUTPUT.PUT_LINE('-- Columns --');
FOR j in 1..col_cnt
LOOP
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
when 2 then 'NUMBER'
when 12 then 'DATE'
else 'Other' end);
END LOOP;
DBMS_OUTPUT.PUT_LINE('-------------');
-- This part outputs the DATA
LOOP
-- Fetch a row of data through the cursor
v_ret := DBMS_SQL.FETCH_ROWS(c);
-- Exit when no more rows
EXIT WHEN v_ret = 0;
v_rowcount := v_rowcount + 1;
DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
DBMS_OUTPUT.PUT_LINE('--------------');
-- Fetch the value of each column from the row
FOR j in 1..col_cnt
LOOP
-- Fetch each column into the correct data type based on the description of the column
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
ELSE
DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
END CASE;
END LOOP;
DBMS_OUTPUT.PUT_LINE('--------------');
END LOOP;
-- Close the cursor now we have finished with it
DBMS_SQL.CLOSE_CURSOR(c);
END;
SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
DEPTNO - NUMBER
SAL - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
DEPTNO : 10
SAL : 2450
Row: 2
EMPNO : 7839
ENAME : KING
DEPTNO : 10
SAL : 5000
Row: 3
EMPNO : 7934
ENAME : MILLER
DEPTNO : 10
SAL : 1300
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
JOB - VARCHAR2
MGR - NUMBER
HIREDATE - DATE
SAL - NUMBER
COMM - NUMBER
DEPTNO - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
JOB : MANAGER
MGR : 7839
HIREDATE : 09/06/1981 00:00:00
SAL : 2450
COMM :
DEPTNO : 10
Row: 2
EMPNO : 7839
ENAME : KING
JOB : PRESIDENT
MGR :
HIREDATE : 17/11/1981 00:00:00
SAL : 5000
COMM :
DEPTNO : 10
Row: 3
EMPNO : 7934
ENAME : MILLER
JOB : CLERK
MGR : 7782
HIREDATE : 23/01/1982 00:00:00
SAL : 1300
COMM :
DEPTNO : 10
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from dept where deptno = 10');
-- Columns --
DEPTNO - NUMBER
DNAME - VARCHAR2
LOC - VARCHAR2
Row: 1
DEPTNO : 10
DNAME : ACCOUNTING
LOC : NEW YORK
PL/SQL procedure successfully completed.
SQL> -
Display column name in sql*plus
Hi,
How to display full column name?
there are n no of tables, i have to query the tables but i want the column name to be displayed fully. for example
SQL> desc control
Name Null? Type
CODE NOT NULL VARCHAR2(255)
LOAD_PERIOD_START_DATETIME DATE
SQL> select code,load_period_start_datetime from control;
CODE
LOAD_PERIOD
AAA
01-AUG-2007
SQL> col load_period_start_datetime format a30
SQL> /
CODE
LOAD_PERIOD_START_DATETIME
AAA
01-AUG-2007
SQL>
As it is only one column i can set with 'col <column_name> format a 30'
if there are n no of coumns from n no tables then how do i get the full column name?
Please help me.
ThanksHi,
you can get all the column's for a TABLE from all_tab_columns this VIEW, why dont you write as script which will generate the commands.
Could you please tell us why do you want to display the compete COLUMN NAME in SQL plus.
Thanks -
Selection criteria based on non-primary key columns in Custom-SQL
Hi all,
Could anybody please tell me how to perform a search using non-primary key columns, The query is written in Workbench under Custom Sql --> Read Object. The Query goes something like this
select * from Employee where firstName like #name
where firstName is a Non-primary key column.
The Java Code goes like this
Employee empm = new Employee();
empm.setFirstName("John");
Employee employees = (Employee) session.readObject(empm);
This does not fetch me any values . I dont want the queries to be written in any java class. Is there Any other way to do it ??Hi all,
Could anybody please tell me how to perform a
search using non-primary key columns, The query is
written in Workbench under Custom Sql --> Read
Object. The Query goes something like this
select * from Employee where firstName like #name
where firstName is a Non-primary key column.
The Java Code goes like this
Employee empm = new Employee();
empm.setFirstName("John");
Employee employees = (Employee)
session.readObject(empm);
This does not fetch me any values . I dont want the
queries to be written in any java class. Is there Any
other way to do it ??I dont think you have set it up the right way to do what you want to do. You need to click on "Queries" on the Employee Descriptor and then Named Queries and then give a name for a named query and then choose ReadObjectQuery under type and then choose SQL under Format. Enter the custom SQL and then export the project xml file.
Then in your application logic you have to call this named query the usual way.
Employee employee = (Employee)session.executeQuery("findEmployeeByName,Employee.class,args);
where args is a vector containing the name of the Employee. -
How to suppress column names in SQL-report
What I want is just the data, without any column names.
COLUMN LDATE OFF;
SELECT SYSDATE LDATE
FROM DUAL;
LDATE
07.11.11
This example doesn't work. There is still LDATE above column. Any idea?user5116754 wrote:
Great, it's so simple. Im sure there is a way to omit this result statement: "531 rows selected" at the end of report!There is, and it's also in the documentation...
SQL> set feedback off
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
SQL> -
Input column name in sql?
hi All,
it is possible to create sql command where column name will be input by user.
let say: Select column1(input by user), column2(input by user)......from table1.
so, count of column depends on user's input.
thanks.hi All,
it is possible to create sql command where column
name will be input by user.
let say: Select column1(input by user), column2(input
by user)......from table1.
so, count of column depends on user's input.
thanks.ofcourse it is possible
String qText="select "+ colVariable +"from tablename" -
Using select list value as column name in SQL
Folks,
Thanks in advance for any help with this
I have a select list with two values (Instance and Username) created by
STATIC2:Username;USERNAME,Instance;INSTANCE
I am trying to pass the value of this (:P2_SELECT) and use it as a column name in a SQL query as below
select USERNAME,
INSTANCE
from table_name
where :P2_SELECT like '%'||:P2_TEXTSEARCH||'%'
When I substitue the :P2_SELECT for one of the values (either instance or username) this works fine
I suspect it is due to how Application Express interprets the value of :P2_SELECT
Any help would be much appreciated!
GarethThanks Munky that worked a treat!
The next hurdle I have now is that because I have changed the region type to "PL/SQL Function(returning SQL Query)" there is no longer the option to add sorting to the columns as I have had to change the Source option to "Use Generic Column Names (parse query at runtime only)"
I will have a scout around and see how I can get around this
Gareth -
Special Column names in SQL Server
Hi,
I am trying to use ODI to load data from SQL Server to Oracle. My problem is having special column names in the old SQL Server database. The columns have names such as 9500Column1. I tried enclosing the names with square barckets in the model definition but it did not work.
Any ideas? Any modifications I might make to the LKM?
NimrodTry enclosing the special fields in double quotes instead of [ and ]. Yes, that isn't the T-SQL standard, but it works, even in SS Studio.
I had a SELECT statement in a Procedure that died when it hit a space in the column name. After hours of unsuccessful attempts to escape [ and ] it occurred to me that maybe " and " would do the trick as that is the PL/SQL standard. I think the proverbial feather could have knocked me over. Or was that me kicking my self in the rear?
Regards,
Cameron Lackpour -
Getting Column names from SQL report
I have a SQL report as follows:
select ename, dept, manager
from emp;
I need to be able to dynamically access the column names being displayed inside APEX so I can use in a List of Values. I can't use all_tab_columns. Is there an internal APEX table/view that I can accxess that will give me all of the columns that are eing displayed in a SQL report?Hi Bob,
Try this -
1) Give your report region a static id
2) Use the following query -
select
heading d,
column_alias r
from
apex_application_page_rpt_cols
where region_id = 'FOO';Obviously change 'FOO' to match your region id, and look at the different columns available in the apex_application_page_rpt_cols view to see what best suits you.
The APEX dictionary rocks ;)
Hope this helps,
John.
http://jes.blogs.shellprompt.net
http://apex-evangelists.com -
List column names of sql table
I know it is basics, just slipped out of my mind, How do we list or print the columns names of table in sql server 2000.
thanks,Code Snippet
SELECT C.Table_Catalog DB,C.Table_Schema, C.Table_Name, Column_Name, Data_Type
FROM Information_Schema.Columns C JOIN Information_Schema.Tables T
ON C.table_name = T.table_name
WHERE Table_Type = 'BASE TABLE'
AND DB = 'DatabaseName' -
Schema/database name, custom sql folders
We have created a single EUL for all business areas and when you create a simple or complex folder you can set the database attribute to default. Is there any way to do this with custom sql folders?
Thanks, Jenniferoops, I don't think I gave enough information. In the custom folder the code is
select c1, c2, c3 from schema_name.some_table
(Discoverer refers to 'schema_name' as a 'database attribute' in simple & complex folders). We want to run a report, based on the custom folder, as a different user, attached to a different schema eg schema_b and get the results from schema_b. We can do this with simpe & complex folders by setting the 'database attribute' to <default> but can't find a way with custom folders.
Thx Jennifer -
How to Update a particular column with custom SQL in JHeadstart
Hi Friends,
I was trying to keep an update SQL statement in VO (missing right Parenthesis exception is thrown)
Please to let you know about my Requirement.
I have a column in Sales_Person Table "TARGET' and in Sales_Admin Table "INCENTIVE"
So Admin will allot a particular Amount in Incentive column for all the sales. (i.e globally for one and all)
When a Sales_Person enter a target of some number say 80 in the Target field.
while saving i want to deduct the target from incentive and the result must be update in Incentive column.
can you please suggest me where should i keep this functionality
Can you please help me out in solving this issue.
Thanks in advance.
RahulRahul,
You can do this in the doDMl method of your Entity Object.
See this white paper:
http://www.oracle.com/technology/products/jdev/collateral/papers/10131/businessrulesinadfbctechnicalwp.pdf
If you have follow-up questions, please use the JDeveloper forum, since your question is not related to JHeadstart.
Steven Davelaar,
JHeadstart Team. -
+ sign before column name - what does it mean?
Hi all,
I found a query in the software package I work on today that I don't quite understand. Below is that basic form of the query:
SELECT * FROM table1 t1, table2 t2 WHERE + t1.id = t2.id;
I expected this query to fail, but it did not. What does the '+' in front of t1.id indicate?
Thanks in advance.Hi.
>
Thanks for your help. I should have mentioned earlier (and I'm apologize for not doing so), is that that id columns are varchar, not number values, so I think that is why the '-' test did not work for me.
>
Is still working for me.
CREATE TABLE aux1
id VARCHAR2(2)
INSERT INTO aux1
SELECT '-1' id FROM DUAL UNION
SELECT '-2' id FROM DUAL UNION
SELECT '-3' id FROM DUAL UNION
SELECT '-4' id FROM DUAL UNION
SELECT '-5' id FROM DUAL;
CREATE TABLE aux2
id VARCHAR2(1)
INSERT INTO aux2
SELECT '1' id FROM DUAL UNION
SELECT '2' id FROM DUAL UNION
SELECT '3' id FROM DUAL;
COMMIT;
SELECT * FROM aux1,aux2
WHERE -aux1.id=aux2.id;
ID ID_1
-1 1
-2 2
-3 3OK, If you use values like 'A' or 'B' it will not work.
Regards.
Edited by: sKr on 14-jul-2011 15:34 -
Elementary: what is the dollar-sign ($) in a column name mean?
I periodically see dollar signs in column names in Oracle tables. For example, when I create a LOB, often times the LOB segment will end in a dollar-sign (or two). Sometimes when one of the developers creates an object, I see some of the field namess have dollar-signs at the end of them.
What does the dollar-sign mean?
What does two dollar-signs mean?
Just curious...they seem to function as normal characters.They are just normal characters. But Oracle (and other vendors) will frequently use characters like $ that normal developers don't normally use in order to create conventions around table names.
For example, Oracle provides a number of data dictionary tables that use x$, v$, and gv$ as prefixes. There is nothing inherently special about those prefixes. But they convey meaningful information to the users of those systems (x$ views are undocumented views, v$ views provide information about activity on the local instance, gv$ views provide information about activity on all the instances of a RAC cluster). And using those sorts of prefixes prevents confusion between application tables and Oracle tables. Lots of applications, for example, have a SESSION table. Having the V$ prefix for the Oracle-delivered V$SESSION table makes it easy to avoid confusion from having two identically named tables.
Justin -
EA 2.1 - SQL autoformat does not capitalize some column names
Hi,
If I put this bit of SQL into the worksheet, select it, and click the A->a formatting button to cycle through the options:
SeLecT Id, NaMe, MY_SpecIal_Column, yEAr fROm DuAl;
turns into
INITCAP - Select Id, Name, My_special_column, Year From Dual;
UPPER - SELECT ID, NAME, MY_SPECIAL_COLUMN, YEAR FROM DUAL;
LOWER - select id, name, my_special_column, year from dual;
UPPER_KW - SELECT ID, NAME, my_special_column, YEAR FROM dual;;
LOWER_KW_UPPER_ID - select id, name, MY_SPECIAL_COLUMN, year from DUAL;
You can see in the last two cases that ID, NAME, and YEAR are treated as keywords instead of column names.Hi,
I think it is due to Oracle keywords which can be used as column names.
SQL Dev thinks the column given is a keyword instead of column name.
In my opinion, it works just fine.
In the first place, we should avoid using keywords as column name.
However, as in your case, when we need the column to be formatted as desire,
Perhaps the developer should give some handling over the keywords themselves.
SELECT <to be treated as column> FROM <to be treated> WHERE <to be treated>
UPDATE <to be treated> SET <to be treated> WHERE <to be treated>
CREATE TABLE / VIEW <to be treated>
Wow... that would be a long list of handling.
And it would turn out to be double time efforts on the case conversion though.
Regards,
Buntoro
Maybe you are looking for
-
G5 won't boot from Install Disc or Hard Drive
After 2.5 years of perfect service my G5 2.0 suddenly won't boot from the HD or Install Disc that came with it. My G5 only shows the grey screen with the apple logo, the spinning gears and the circle with the line through it. I haven't added any hard
-
Just curious but I went to get an iPhone 5 for an upgrade I really wanted a black iphone 5 but they only had white ones in stock, I was wondering (because my screens cracked) will they possibly send me a refurbished black iPhone 5?!
-
Canon 5D MrkII & Photoshop CS3
I cannot believe that Adobe has abandoned users of CS3 and new Canon cameras!! I just found out that to convert RAW files from the Canon 5d MrkII, we need Camera Raw 5 or later. Camera Raw 5 or later WILL NOT work with CS3!! So if you purchase a C
-
ECATT: Parameterise the ID of a guielement
I want to parameterise the ID of a guielement. At the last position of the ID is defined which element will be use. But it doesen't work. I think, the problem is the length of string, it contains more than 160 characters. ID = 'wnd[0]/usr/subSUBST:/V
-
Poture Validation of anti-virus products
Hi all I have recently setup set up NAC framework to support dot1x for wireless and wired clients. My ACS appliance is successfully authentication users via eap-fast using personal and machine certs and it successfully posture checks that the users a