Querying MSAccess with # in column name
What is the proper syntax for a JDBC sql statement to query a MSAccess database with "#' (the pound or number sign) in a column name?
Thanks.
-John
Thanks all for the speedy replies. This forum should be extremely helpful in the future.
The double quotes did the job. I thought I had tried using quotes, but I must have used single quotes instead.
I do not have a say in the database design, and therefore, am stuck using whatever is thrown at me. Otherwise, I agree that staying away from using column names that may not conform to accepted standards is a good idea.
Thanks again.
-John
Similar Messages
-
Selecting from a SQL Server 2005 with long column names ( 30 chars)
Hi,
I was able to set up a db link from Oracle 11.2.0.1 to SQL Server 2005 using DG4ODBC.
My problem is that some column names in the Sql Server are longer than 30 chars and trying to select them gives me the ORA-00972: identifier is too long error.
If I omit these columns the select succeeds.
I know I can create a view in the sql server and query it instead of the original table, but I was wondering if there's a way to overcome it with sql.
My select looks like this:
select "good_column_name" from sometable@sqlserver_dblink -- this works
select "good_column_name","very_long_column_name>30 chars" from sometable@sqlserver_dblink -- ORA-00972ThanksI tried creating a view with shorter column names but selecting from the view still returns an error.
create view v_Boards as (select [9650_BoardId] as BoardId, [9651_BoardType] as BoardType, [9652_HardwareVendor] as
HardwareVendor, [9653_BoardVersion] as BoardVersion, [9654_BoardName] as BoardName, [9655_BoardDescription] as BoardDescription,
[9656_SlotNumber] as SlotNumber, [9670_SegmentId] as SegmentId, [MasterID] as MasterID, [9657_BoardHostName] as BoardHostName,
[9658_BoardManagementUsername] as BoardManagementUsername, [9659_BoardManagementPassword] as BoardManagementPassword,
[9660_BoardManagementVirtualAddress] as BoardManagementVirtualAddress, [9661_BoardManagementTelnetLoginPrompt] as
MANAGEMENTTELNETLOGINPROMPT, [9662_BoardManagementTelnetPasswordPrompt] as MANAGEMENTTELNETPASSPROMPT,
[9663_BoardManagementTelnetCommandPrompt] as MANAGEMENTTELNETCOMMANDPROMPT FROM Boards)performing a select * from this view in sqlserver works and show the short column names
this is the error i'm getting for performing a select * from v_boards@sqlserver_dblink
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Microsoft][SQL Native Client][SQL Server]Invalid column name 'BoardManagementTelnetLoginProm'. {42S22,NativeErr = 207}[Microsoft]
[SQL Native Client][SQL Server]Invalid column name 'BoardManagementTelnetPasswordP'. {42S22,NativeErr = 207}[Microsoft][SQL Native
Client][SQL Server]Invalid column name 'BoardManagementTelnetCommandPr'. {42S22,NativeErr = 207}[Microsoft][SQL Native Client][SQL
Server]Statement(s) could not be prepared. {42000,NativeErr = 8180}
ORA-02063: preceding 2 lines from sqlserver_dblinkI also tried replacing the * with specific column names but it fails on the columns that have a long name (it doesn't recognize the short names from the view)
what am I doing wrong?
Edited by: Pyrocks on Dec 22, 2010 3:58 PM -
Is it possible to create a Synonym with different column names
Hi,
I want to create a Synonym with different columns names (Columns not in original table) . I am not sure if this can be done . Any suggessions...
Thanks in advance....Synonyms are not limited to tables. Accroding to the SQL Reference, a synonym is:
an alternative name for a table, view, sequence, procedure, stored function, package, materialized view, Java class schema object, user-defined object type, or another synonym.
In fact, synonyms are not even validated until they are used:
SQL> create synonym my_synonym for table_which_does_not_exist;
Synonym created
SQL> select * from my_synonym;
select * from my_synonym
ORA-00980: synonym translation is no longer valid -
CREATE INDEX WITH DUPLICATE COLUMN NAME
Hi,
i need to interface our application with an Orale Bridge to CREATE INDEX with duplcate column Name.
For Example
CREATE index NLOT_FOURNLOT_idx ON NLOT(FOURNISSEUR ,NOLOT ,FOURNISSEUR ,NOBLFOUNISSEUR,NOLIGNEBL ,NOLOT ,QTECOLISRECUES ,CODENONQUALITE ,QTECOLISACCEPTE);
CREATE table NLOT(
FOURNISSEUR VARCHAR2(09)
,NOBLFOURNISSEUR VARCHAR2(13)
,NOLIGNEBL VARCHAR2(03)
,NOLOT VARCHAR2(20)
,QTECOLISRECUES VARCHAR2(10)
,CODENONQUALITE VARCHAR2(02)
,QTECOLISACCEPTE VARCHAR2(10)
,NOMBREDECOLISRE VARCHAR2(10)
,NOMBREDECOLISAC VARCHAR2(10)
,FILLER VARCHAR2(1)
,FILLE1 VARCHAR2(1)
,TYPEREFERENCE VARCHAR2(01)
,REFERENC1 VARCHAR2(15)
,CONTROLERECEPTI VARCHAR2(01)
,DATEDEPEREMPTIO VARCHAR2(8)
,CONTROLEPROCHAI VARCHAR2(1)
Thanks
PhilippeWell, you can't do it. ORA-957 is one of those irrevocable errors for which the solution is to remove the duplicate name from the SQL statement.
But, anyway, why do you want to do this? I would guess there's no performance benefit from having the same column indexed twice (of course it's impossible to test this, so it's just my opinion).
Cheers, APC -
How To Create Table View With Same Column name But Different Table?
Hi All,
I have the problem to create a tableview with same column name but in different table.
The Table that i have:-
Table - PAC051MPROFORMA
Column - mrn,visitid
Table - PAC051TPROFORMA
Column - mrn,visitid
Table - PAC052MTRANSBILL
Column - mrn,visitid
Then i want to create a table view to view that table. This is my SQL
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
That SQL Return this error = ORA-00957: duplicate column name
Then I modify that SQL to
CREATE VIEW pacviewproforma (mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
This time this error return = ORA-01730: invalid number of column names specified
What should i do?
Thanks...Hi,
SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
ERROR at line 1:
ORA-00957: duplicate column namePlease give different names to each column.
Something like this..
SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
_visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
View created.
SQL> DESC pacviewproforma;
Name Null? Type
MPROFORMA_MRN NUMBER
MPROFORMA_VISITID NUMBER
TPROFORMA_MRN NUMBER
TPROFORMA_VISITID NUMBER
MTRANSBILL_MRN NUMBER
MTRANSBILL_VISITID NUMBER
ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
Twinkle -
Error querying fact: -2417217900 invalid column name
Dear Xperts
while validating script logic it gives error"error querying fact: -2417217900 invalid column name P_ACCT"
P_ACCT dimension created by me.
problem has started today while creating new script logic.
as old logic created earlier was sucessfully validated
new logic was created refering document 330 for bpc,so there is no scripting error
pls guide me through this.
thanks
kashyapthanks for ur advice
i was able to validate logics previously.
i tried way you sugested but was unable to validate.
i also tried updating that dimension members but it was giving me some olap querry error while processing dimension after changing dimension members.
so finally i deleted that dimension created new one did whole process again
& was successfull
but i wanted to know why this error could have occured
thanks
kashyap -
Membership rules does not work with UDF column name having the max length
Found a bug in OIM .
Membership rules does not work with UDF column name having the maximum length
Steps to Reproduce
1.Create a UDF having max column name length for eg UDF_USR_PERSONAL_SUB_DOMAIN_CO (lable = Personal Code)
2. Create a simple Rule like Personal Code = 7000
3. Assign this Rule as a member ship rule of a Group.
4. Create a user with Personal Code = 7000.
5. User doesnot get the group membership.
Thanks
SurenYes , i verified logs as well .
If you just decrease the column name length , w/o making change to any other attributes , it starts working ..
Thanks
Suren -
Many to many join table with different column names
Hi have a joint table with different column names as foreign keys in the joining
tables...
e.g. i have a many to many reltnshp btwn Table A and Table B ..and join table
C
both have a column called pk.
and the join table C has columns call fk1 and fk2
does cmd require the same column name in the join table as in the joining table?
are there any workarounds?
thanksHI,
No, the foreign key column names in the join table do not have to match the primary
key names in the joined tables.
-thorick -
SQL Query not working for column names with spaces
Hi People..
We have a strange situation wherein, the column name in the database table has a space inbetween like "Constant Name". While we write a JDBC statement code with the select query we get an exception for invalid syntax. It will help us in a great way if you have anything to inform us on this..
Thanks
PrabzUsing case sensitive names and names with spaces in it is not a good practice.
However, I believe the SQL standard accounts for this with quoted identifiers. I believe the syntax is
. select "My Field1", "My Field2"
. from "My Table'
Have also seen the following although it might be MS Access specific.
. select [My Field1], [My Field2]
. from [My Table] -
Need a Query that Returns both Column Name with Column Data
Hi,
Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
Table: APP_INFO
COL1 - currently has the value of 10
COL2 - currently has the value of 'HELLO'
COL3 - currently has the value of 'QWERTY'
COL4 - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
COL1,10
COL2,'HELLO',
COL3,'QWERTY'
COL4,2000
Any help would be much appreciated.
Thanks.
Tony.Like this ?
SQL> select empno, ename, deptno from emp where deptno = 10;
EMPNO ENAME DEPTNO
7782 CLARK 10
7839 KING 10
7934 MILLER 10
SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
2 decode(t.id,1,to_char(empno),2,ename,3,deptno)
3 from (select emp.*, rownum rn from emp
4 where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
5 order by emp.rn, t.id
6 /
COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
EMPNO 7782
ENAME CLARK
DEPTNO 10
EMPNO 7839
ENAME KING
DEPTNO 10
EMPNO 7934
ENAME MILLER
DEPTNO 10
9 rows selected.Rgds. -
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 -
Transpose rows to columns with numeric column name
I am trying to transpose row to columns.
Here is my data having 3 columns (date, last_retry and count(*) )
Date last_retry count(*)
1/2/06 2 13
1/2/06 1 5
5/5/06 1 12
5/5/06 2 9
Desired Output with columns ( date, 1, 2)
Date 1 2
1/2/06 5 13
5/5/06 12 9
Here is my query which doesn't work
select trunc(Date),
max(Decode(last_retry,'1',count(*))) as 1,
max(Decode(last_retry,'2',count(*))) as 2
from retry_state
1st problem: How do I transpose if this is not correct?
2nd problem: 1 cannot be named as column name, how can I name the columns
3rd problem: Suppose I am selecting this data and loading into a table. Now can
the data be loaded during select as well as transposed at the same time or would I need to create a view to load the data first into table and then perform transpose?hi,
this will transpose your data and insert into the table:
INSERT INTO transposed_table
(SELECT my_date,
MAX(DECODE(last_retry,1,cnt,0)) AS "1",
MAX(DECODE(last_retry,2,cnt,0)) AS "2"
FROM retry_state
GROUP BY my_date)
note: to avoid problem and confusion, i renamed the fields DATE and COUNT(*) to MY_DATE and CNT respectively. You should avoid using reserved words as your fields such as DATE!
hope this helps. -
Strange behavior in BI Publisher with long column names from BI Answers
Hello all!
I have created a BI Answers request with few calculated columns in form of
case when <condition> then <value if true> else <value if false> end
Then in BI Publisher Desktop designed a report ttemplate based on saved BI Answers request and noticed that for calculated columns their names look strange:
CASEWHEN_<condition>THEN...ELSE..._...END__
Some of the column names are about 100 characters long.
After running the report from Word found that for these "long length named columns" there's no data in the output.
Do someone else experience the same? Any workarounds?
Regards,
mr.maverickThis is because the length for the formula is restricted in publisher. you have to either reduce the size of the column name in answers or change the formula. another workaround is completely pasting the formula directly in the word template instead of placing the formula inside the form field. you can add maximum of 300 characters i guess. you can edit the formula for the form field in the form field options formuals menu.
-
Query parameters with the same name and different values
According to HTTP, multiple query or post parameters with the
same name and different values are permitted. They are transfered
over the wire in the following format -
name1=val1&name1=val2&name1=val3
The problem is that I can't see anyway of assigning multiple
parameters with the same name and different values to the request
object of mx.rpc.http.HTTPService. I have tried using the
flash.utils.Dictionary object as it does strict key comparison but
that doesn't work too. I have tried setting an array of values to a
property of the request object but that sends the request to the
server in the following format -
name1=val1,val2,val3
The java servlet engines throw exceptions when they see this.
Any help would be greatly appreciated.If you're not on 8.1.4 move there. 8.1.3 had limitations in the wsrp
release.
wrote:
I have an html select box that contains several values, and multiple
selection is enabled. When my code runs as a remote portlet, the
following is showing up in the soap monitor when I select multiple
values and submit the form:
<urn:interactionParams>
<urn:portletStateChange>cloneBeforeWrite</urn:portletStateChange>
<urn:interactionState>_action=addEmployeesToGroup</urn:interactionState>
<urn:formParameters
name="P62005wlw-select_key:{actionForm.selectedEmployees}OldValue">
<urn:value>true</urn:value>
</urn:formParameters>
<urn:formParameters
name="P62005wlw-select_key:{actionForm.selectedEmployees}">
<urn:value>beatest1</urn:value>
</urn:formParameters>
In this case, I selected beatest1 and beatest2, but only beatest1 comes
through to the remote portlet. Is this a known bug, and, if so, is
there a patch or workaround available?
Thanks in advance,
Andy -
Where statement on two different tables with same column name
Hello,
I have 2 financial tables:
tblincome, tblexpenses
in each table I have column name "monthPayed" (have values of all the months of the year).
I would like to create a balance view table that will show me the financial status for the Q1 (for example).
I have a column totalIncome and totalExpended respectively.
I've create a view table that shows me the financial balance at the moment but I want it to be devide to Quarters of the year...
Regards
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Where is the code you already tried? Or are you so lazy, so rude or so privileged that you did not do anything for yourself?
In fact that silly “tbl-” prefix is so bad that it has a name! It is called Tibbling and Phil Factor even wrote a humor article on bad programmers that use it.
Your narrative is vague; it sounds like this is the DDL:
CREATE TABLE Incomes
(payment_month CHAR(10) NOT NULL PRIMARY KEY,
income_amt DECIMAL(12,2) NOT NULL
CHECK (income_amt > 0.00),
CREATE TABLE Expenses
(payment_month CHAR(10) NOT NULL PRIMARY KEY,
expense_amt DECIMAL(12,2) NOT NULL
CHECK (expense_amt > 0.00),
>> in each table I have column name "monthPayed" (have values of all the months of the year). <<
I hope not! 2014 has not gotten to September, November or December yet! And the ISO-11179 data element name should be “payment_month”; but it is still wrong! An expense is not a payment! An income is not a payment!
>> I would like to create a balance view table that will show me the financial status for the Q1 (for example). <<
Report Period Table
Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
The report period table gives a name to a range of dates that is common to the entire enterprise.
CREATE TABLE Something_Report_Periods
(something_report_name CHAR(10) NOT NULL PRIMARY KEY
CHECK (something_report_name LIKE <pattern>),
something_report_start_date DATE NOT NULL,
something_report_end_date DATE NOT NULL,
CONSTRAINT date_ordering
CHECK (something_report_start_date <= something_report_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
Now figure it out for yourself, show us what effort you put into this, then we will help you.
--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
Maybe you are looking for
-
Are you sure you want to remove existing photos and sync photos from this computer?
I have a 64Gb iPad running the current version of ios7 on which I store around 15,000+ photos. Every time I add a few new photos to iPhoto and then try to sync the iPad through iTunes (current version) I get the message in the title. It takes about 6
-
Error in Webi when it execute a query
Good morning. I have a problem with Webi. I make a report in BW then with Designer I make a universe and I export it . I open it with Webi. When I run a query I get an error, is this: "Se produjo un error en la base de datos. El texto de error de la
-
How to load .jar files when not specified in the .jnlp file
Hello, We are deploying an application with JWS but due to the nature of this app, we need to download additional jar file only when the user has been authenticated. The jar file(s) we need to download can hardly be predicted (in term of name) and th
-
Get Front Row to play from HVDVD_TS folder
How can I get Front Row to play content from a HVDVD_TS folder. It works great with standard VIDEO_TS folders (under Leopard/Snow Leopard) but it doesn't seem to recognise my DVD Studio Pro generated HVDVD_TS folder. Thx! Cojcolds
-
SQL Server does not exist or access denied.
Hello all, I am having a really frustrating time with our servers.... once a week, the cold fusion server can't (or won't) connect to our separate MS-SQL server. It reports back an error that the connection could not be found or is denied. Our server