Bug when using alias in sql query?
I don't know if this is a problem related to the getString function of the MetaData class, or if it is something else. I'm having problems when sending a select query containing a specification for column alias to the execute function of the Statement class. Whenever the alias is more than 11 characters it crashes, saying the heap may be corrupt. When the alias is <=11 or there is no alias specified, there are no problems to get the name.
After executing a query I am looping through the vector of MetaData objects retrieved from the ResultSet and its getColumnListMetaData to get information about each column, among other things the column name. The crash occurs when it comes to the execution of getString(MetaData::ATTR_NAME). As I said, this does not happen when no alias is set, it will pass by without any errors.
I am using visual studio 2005, oracle 10g release 2 and the downloaded debug versions of occi for visual studio 2005.
Hi,
Is this what you are trying:
try {
Statement *stmt = conn->createStatement("SELECT ename AS aaaaaaaaaaaaaaa FROM emp");
ResultSet *rs = stmt->executeQuery ();
vector<MetaData> md = rs->getColumnListMetaData ();
int numCols = md.size ();
cout<< "Number of columns :" << numCols << endl;
string *colName = new string [numCols];
int type = (int ) malloc (numCols);
for (int i = 0; i < numCols; i++ ) {
int ptype = md [ i ].getInt (MetaData::ATTR_PTYPE);
if ( ptype == MetaData::PTYPE_COL ) {
colName[ i ] = md[ i ].getString (MetaData::ATTR_NAME);
cout<<"Column Name :" << colName[ i ] << endl;
delete[] colName;
stmt->closeResultSet (rs);
conn->terminateStatement (stmt);
catch (SQLException &ex) {
cout<<ex.getMessage()<<endl;
}The above snippet works correctly for me.
Rgds.
Amogh
Similar Messages
-
XSQL bug when using CURSOR in xsql:query SELECT statement?
Hi there,
When I tested with different XSQL pages, I found out that if I
did not involve any XSQL pages that contain "CURSOR", I received
data correctly and when I shut down Tomcat, Oracle DB server did
NOT create any dump file (???). However, as long as I involve a
XSQL page which contains "CURSOR", even I received data
correctly, but when I shut down my Tomcat, Oracle DB server
created a dump file (???).
for example, if I involve xsql:query like:
<xsql:query>
SELECT emp_name,
emp_id
CURSOR( SELECT emp_address
from address a
where a.emp_id = b.emp_id)
FROM employee b
</xsql:query>
Once, I involve this xsql page, when I shut down Tomcat, Oracle
dB will create a dump file on the server.
Even when I run this xsql page from
oracle.xml.xsqlXSQLCommandLine, Oracle dB server still create a
dump file on the server.
Any idea for help ?
Thanks,Hi,
Is this what you are trying:
try {
Statement *stmt = conn->createStatement("SELECT ename AS aaaaaaaaaaaaaaa FROM emp");
ResultSet *rs = stmt->executeQuery ();
vector<MetaData> md = rs->getColumnListMetaData ();
int numCols = md.size ();
cout<< "Number of columns :" << numCols << endl;
string *colName = new string [numCols];
int type = (int ) malloc (numCols);
for (int i = 0; i < numCols; i++ ) {
int ptype = md [ i ].getInt (MetaData::ATTR_PTYPE);
if ( ptype == MetaData::PTYPE_COL ) {
colName[ i ] = md[ i ].getString (MetaData::ATTR_NAME);
cout<<"Column Name :" << colName[ i ] << endl;
delete[] colName;
stmt->closeResultSet (rs);
conn->terminateStatement (stmt);
catch (SQLException &ex) {
cout<<ex.getMessage()<<endl;
}The above snippet works correctly for me.
Rgds.
Amogh -
When using TODATE function MDX query is not correctly generated
Essbase 9.3.1.2 and OBIEE 10.1.3.4.1.
When using TODATE function MDX query is not correctly generated.
This leads to unexpected values not only on cumulative columns in report (generated with TODATE), but also other columns (calculated with AGO function or directly read from cube) have incorrect values.
The problem occurs when you filter on a column that is not in the select list. If you filter on just one level of dimension, results are fine. You can filter on multiple dimensions as long as you filter on just one level of each dimension.
If you filter on two or more levels of one dimension, than results are not correct. In some cases results for TODATE column are all zeros, in some cases it is a random value returned by Essbase (same random value for all rows of that column), and in some cases BI Server returns an error:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. Essbase Error: Network error [10054]: Cannot Send Data (HY000).
Here is generated MDX code:
With
set [Grupe proizvoda2] as '{[Grupe proizvoda].[N4]}'
set [Grupe proizvoda4] as 'Generate([Grupe proizvoda2], Descendants([Grupe proizvoda].currentmember, [Grupe proizvoda].Generations(4), leaves))'
set [Segmentacija2] as '{[Segmentacija].[RETAIL]}'
set [Segmentacija4] as 'Filter(Generate({[Segmentacija2]}, Descendants([Segmentacija].currentmember, [Segmentacija].Generations(4),SELF), ALL), ([Segmentacija].CurrentMember IS [Segmentacija].[AFFLUENT]))'
set [Vrijeme3] as '{[Vrijeme].[MJESEC_4_2009]}'
member [Segmentacija].[SegmentacijaCustomGroup]as 'Sum([Segmentacija4])', SOLVE_ORDER = AGGREGATION_SOLVEORDER
member [Accounts].[MS1] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],2,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
member [Accounts].[MS2] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],1,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
member [Accounts].[MS3] as 'AGGREGATE({PeriodsToDate([Vrijeme].[Gen2,Vrijeme],[Vrijeme].currentmember)}, [Accounts].[Trosak kapitala])'
select
{ [Accounts].[Trosak kapitala],
[Accounts].[MS1],
[Accounts].[MS2],
[Accounts].[MS3]
} on columns,
NON EMPTY {crossjoin ({[Grupe proizvoda4]},{[Vrijeme3]})} properties ANCESTOR_NAMES, GEN_NUMBER on rows
from [NISE.NISE]
where ([Segmentacija].[SegmentacijaCustomGroup])
If you remove part with TODATE function, the results are fine. If you leave TODATE function, OBIEE returns an error mentioned above. If you manually modify variable SOLVE_ORDER and set value to, for example, 100 instead of AGGREGATION_SOLVEORDER, results are OK.
In all cases when this variable was modified in generated MDX, and query manually executed on Essabse, results were OK. This variable seems to be the possible problem.Hi,
Version is
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
Sorry, in my last post i forgot to mention that i already created a function based index but still it is not using because, there is a UNIQUE constraint on that column.
Thanks -
Using Parameters in SQL-Query not only in where clauses
Hi,
I try to use Publisher parameters in the SQL Query from a Data Set.
All of them have default values.
So far, this is no problem, unless I try to use such a parameter value as an ordinary attribute value:
>
select
case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."BETR_TEIL"
else :pv_some_Text end as Betr_Teil,
case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM"
else :pv_some_Text end as Suva_Nr,
case when (:pv_Group = 'no') then "DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH"
else sum("DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") end as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in (:pv_nim100)
fetch first 65001 rows ONLY
>
The parameters 'pv_Group' and 'pv_nim100' are working fine. (when or where clauses)
The parameter 'pv_some_Text' unfortunately not. (simple literals)
When I try to validate the above SQL, I get the following Error:
<font color="red">
java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46033] Datatype: 25 is not supported.
</font>
After use a cast function:
>
else CAST(:pv_some_Text AS CHARACTER)
>
I get this ERROR:
<font color="red">
java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 19002] Incorrect use of parameters. The parameters used in CAST cannot be resolved without ambiguity.
</font>
We use OBIEE 11.1.1.6.4 on a Win64-System.
Thank's for any help.Hi Alex,
let's leave away any unnecessary details.
This is the SQL, inserted in the window 'Edit Data Set' of BIP Data Model:
>
select
'--1' as Betr_Teil,
'--2' as Suva_Nr,
sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
fetch first 65001 rows ONLY
>
Everything is fine when I click OK, the script goes back to the metadata.
Let's try this script with bind values in ORACLE SQL Developer.
This SQL is the physical part, found in the OBIEE-Log (Log level 5), except the bind values. Therefore we find, in the where clause, the join. In the logical sql, we don't have to join, because it's handled in the Common Enterprise Information Model (CEIM)
>
with
sawith0 as
select
sum(t39617.ris_vollbesch) as c1
from
dm15d_betriebsteil t39455,
dm15k_ris_fakten_pro_btt_jhr t39617
where
t39455.id_betriebsteil = t39617.id_betriebsteil
and t39455.suva_nr_form = '122-4.4'
select
d1.c1 as c1,
d1.c2 as c2,
d1.c3 as c3
from
select
:pv_some_text as c1,
:pv_some_text as c2,
sum(d1.c1) as c3
from
sawith0 d1
d1
where
rownum <= 65001
>
This SQL works fine, even with bind values for 'pv_some_text'.
But, when using the following SQL in the BIP Data Model:
>
select
:pv_Text as Betr_Teil,
:pv_Text as Suva_Nr,
sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
fetch first 65001 rows ONLY
>
The following ERROR occurs:
<font color="red">java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46008] Internal error: File server\Query\Optimizer\ServiceInterfaceMgr\Utility\Src\SQOIUTypeVisitor.cpp, line 643.</font>
In my opinion, either I use a wrong syntax, or BIP has a problem with parsing the script.
Thank you for your most welcome help. -
Correct Way to use Bind variables when using an MS SQL server backend
Hey,
I'm having some trouble figuring out how to use bind variables in a view when using an MS SQL server backend. For some reason when I'm using an ApplicationModule that has a MS SQL Server JDBC library loaded and I attempt to click OK when editing the following query:
SELECT kit_status, component_id
FROM numbered_inv
WHERE trialname = :1
I get an error stating that "SQL Query Error Message Incorrect Syntax near ':'". Is JDeveloper compatible with SQL server for bind variables because this query runs just fine if I replace the :1 with a say "Testing testing".
Thanks in advance
Edited by: NullCheck on Dec 15, 2010 2:06 PMGotcha. I had tried %1% %0% ?0 and ?1 and various other permutations none of which worked. Got it working by setting the query to:
SELECT kit_status, component_id
FROM numbered_inv
WHERE trialname = ?
ORDER BY kit_status
And then adding a bind variable with "Bind position" set to 0.
Thanks again Shay! -
Memory problems when using alias channel strips (3.0.2)
I'm having memory issues when using alias channel strips. What is happening is I create one instance of the plugin, say Massive. Then make a bunch of other alias on different patches. When looking at the memory usage everytime I add and alais it increases the memory usage by an amount the same as the origional plugin. ie. add 3 alias and you have 3 times more memory usage. See attached photos.
Original plugin instance ~80mb memory usage
Adding 3 Alias channel strips. ~330mb memory usage
By comparison here is the usage by adding 3 brand new instance of the plugins. ~160mb memory usage
By comparison it is using less memory by having 4 seperate instances of the plugin compared to using 3 alias's of the origional. This doesn't make sense since the whole point of an alias is to save memory by only loading one instance of the plugin.
Anyone have any thoughts?
JonWhat's interesting is that if I, starting with a blank concert, add a Massive to a patch and then make an alias the memory is as you say. But if I make a duplicate of the inital patch and then make alias's of that the memory is lower.
Are you seeing the same with the built-in plug-ins? -
Use a manual SQL query in an interface
Hello,
I would like to know if I can use a manual SQL query in an interface.
Here is what I need.
I have two tables.
T1 with 4 fields :
idT1, LibC, val, lib_val
An example of a line from T1
1, field1, 33 , value 33
2, field2, 44 , value 44
And table T2 with fields such as:
idT2, ... , field1, field2
There is no key to join T1 and T1, but I should retrieve the value of field lin_val from T2 which corresponds to the value of field1.
In SQL, the query looks like this:
SELECT t2.lib_val
FROM t2 , t1
WHERE T2.LibC = "Column_name"
AND T2.val = T1.Column_name
AND t1.idT1 = xyzYou should go for yellow interface.It will solve your problem. Here you go
http://odiexperts.com/how-to-create-a-temp-table-in-odi-interface/
https://blogs.oracle.com/warehousebuilder/entry/odi_11g_simple_flexible_powerful
Thanks. -
How to hide system tables when using the Oracle SQL Developer?
Hi,
I would like to know how can I show only the tables that I created under the Tables tree? I didnt find a way to create a separate database using the Oracle Sql Developer. I see all the tables together, and would like to differentiate between different databases.
Can anyone explain to me how to do these things?
Thanks,Hi,
I would like to know how can I show only the tables that I created under the Tables tree? Your posting is not clear,again tell something more on tables tree,what u want to achieve with it.
How to hide system tables when using the Oracle SQL Developer? if u connected with sys, system or user with dba role then u have a privilege to see these tables,so revoke the privilege/role from ur user to view this tables if ur connected other then sys,system,
I didnt find a way to create a separate database using the Oracle Sql Developer. DBCA is a tool for creating the new database.
Kuljeet -
ExecuteNonQuery doesnt return number of rows affected when used with PL/SQL
ExecuteNonQuery doesn't return number of rows affected when used with PL/SQL but returns -1. The documentation says ExecuteNonQuery method of OracleCommand returns the number of raws affected but when used with PL/SQL, it returns -1 even the update statement successfully executes and affects multiple records with no exeptions thrown.
However, if ExecuteNonQuery is used with update sql statement in the asp.net code it returns number of rows affected correctly. Does anybody know why ExecuteNonQuery behaves like this?
I am using ODP.NET that comes with Oracle Client 11g. The version is 2.111.6.20 of ODP.NET, Oracle database server is 10g.
MaratYou can get the rowcount in the stored procedure via SQL%ROWCOUNT and then pass it out as a parameter.
For example:
SQL> create or replace procedure updatesal(v_deptno in number, v_rowsaff out number) as
2 begin
3 update emp set sal = sal * 5 where deptno = v_deptno;
4 v_rowsaff := SQL%ROWCOUNT;
5 end;
6 /
Procedure created.Cheers -
Bug with readonly view (through sql query)
HI , I'm using JDEV11.1.1.2
I found the following problem which I consider a bug:
When you create a readonly view object based on sql query the first attribute gets type: VARCHAR2(255) although it is VARCHAR2(10) in the database. All other attributes get the correct type and length only the first one is not correct.
Can you confirm this behavior to be a bug ?
Thanks
agruevHi,
of other string attributes show the correct length then this indeed sounds like a bug. However, a bug is a bug when it is getting filed.
Frank -
Possible bugs when adjusting column width in Query Builder
Good morning,
we use Oracle SQL Developer 3.2.20.09 with included JDK on Windows 7 32 bit.
When we open a sql file, in the Query Builder the criteria columns don't auto-adjust accordingly with the length of text present in the columns.
Also, if we modify or type a new criteria in a column, and immediately after drag the column header to widen the cell, the cell content is erased (if we click first in another cell the problem doesn't occur).
Thanks for reading and best regards.
Marco - ItalyHi Marco,
Please note that SQL Developer has included a Query Builder from a third-party since the 3.0 release. I will ping the developer that acts as liaison; perhaps you will get a more definitive response. I can only assume any UI bugs would have to be fixed by the third-party company at his request.
Regards,
Gary
SQL Developer Team -
Getting zero-sized reply error when running report from SQL query
Hi,
I have a Report from SQL Query in Portal. When I select Excel in Output Format and then run the report, it works properly, but when I select HTML in Output Format, the report works if the rows returned are not so many (I've been able to display the report for up to 701 rows), but when I try selecting a value from the LOV that selects many rows, I get the following error:
ERROR
The requested URL could not be retrieved
While trying to retrieve the URL: <data suppressed>
The following error was encountered:
Zero Sized Reply
Squid did not receive any data for this request.
Any ideas on how to fix this? Why does the number of rows returned affect the report this way?
Thanks,
LorenaProblem comes when any of the filter is applied in any one of the cases selected from the GUI.Do you mean that the problems only shows when you run the report in your browser via 9iAS?
Which version are you using?
Can you post the before report trigger? -
Post Author: wleonetti
CA Forum: Crystal Reports
Hello!
I have acquired a report from our regional headquarters, and have been asked locally to add a prompt to one that already exists in the report.
The report currently uses an SQL query, which in turn uses a single prompt to limit the data reported. However, the name of the parameter in the Field Explorer in Parameter Fields is "Facility", but, when I use the Database Expert and select edit for the query (under Selected Tables, right-click on "Command" under the database and click on "Edit Command"--is Command a default name?), under the Parameter List, the name of the parameter there is "Facility1" (?). The SQL references the parameter "Facility1" (...like '{?Facility1}'), but I cannot find any link/interface between the Parameter List "Facility1" to the Parameter Field "Facility", and I cannot find any other references to "Facility1" anywhere else in the report (sorry, I'm very new at CR, and am not sure how to do a global search of a desired text string in the reports).
I have asked the author for an explanation, but he would only offer, after indicating that he ... was not obligated to help me in any way .., the following bone: "I just simply rename the parameter in Command from Facility1 to Facility which bears the same name as the parameter interface and it just works fine." This only served to confuse me more, since the parameter name currently in Command is "Facility1" (and the report works the way it is)--when I change the name of the parameter in Parameter List (and the parameter name in the SQL query) to "Facility" (to match the Parameter Field's "Facility"?) ... the parameter in the Parameter Fields ... disappears?
Can someone please instruct me how to, in whatever steps are necessary, add a parameter to the Parameter Fields and edit the SQL code to use that parameter? or point me to some documentation that will help me with this?
Thanks in advance for any help offered.
wleonettiHi Eric,
Try expressing the source as this:
begin
return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
end;That works fine for me, and if I take out the begin-end and the trailing semicolon from the return statement I get the same behavior as you.
It does mention in the help for the source (only during the wizard though) that this source type has to be expressed that way, but I agree it would be helpful if the tool would validate for this format when 'Function Returning SQL Query' is used or give some sort of indication of the trouble. Anyway, this should get you going again.
Hope this helps,
John
If you find this information useful, please remember to mark the post "helpful" or "correct" so that others may benefit as well. -
Using 'Function Returning SQL Query' with Flash charts
I have created a pl/sql function that returns a SQL query as a varchar2 of this form:
select null link
<x value> value
<Series1 y value> Series 1 Label
<Series2 y value> Series 2 Label
<Series3 y value> Series 3 Label
from tablea a
join tableb b
on a.col = b.col
order by <x value>
If I now call the function from a Flash Chart Series SQL box with the Query Source Type set to 'Function Returning SQL Query' like this:
return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'))
it parses correctly and the page is saved; however, when I run the page I don't get any output - nor any error messages or other indication of a problem.
Now, if I call the function in a SQL client, capture the SQL query output using dbms_output and paste that into the Flash Chart Series SQL box - changing the Query Source Type to SQL Query - and save the page it works fine when I run it and returns a multi-series flash chart.
Can anyone suggest either;
1. What have I might have missed or done wrong?
2. Any way to usefully diagnose the problem...
I have tried using the Apex debugger - which is very nice, by the way - but it doesn't provide any info on what my problem might be. I even tried writing my own debug messages from my function using the apex_debug_message package - got nothing...
Thanks,
EricHi Eric,
Try expressing the source as this:
begin
return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
end;That works fine for me, and if I take out the begin-end and the trailing semicolon from the return statement I get the same behavior as you.
It does mention in the help for the source (only during the wizard though) that this source type has to be expressed that way, but I agree it would be helpful if the tool would validate for this format when 'Function Returning SQL Query' is used or give some sort of indication of the trouble. Anyway, this should get you going again.
Hope this helps,
John
If you find this information useful, please remember to mark the post "helpful" or "correct" so that others may benefit as well. -
Getting session hang When calling Function from SQL query
Hi All,
I am using Oracle 8.1.7.4.0. I have a fucntion in a Package and I am calling it from the SQL query. When I am firing the query my oracle session is going to hang position and I am not able to any thing. I have to kill the session.
But this same thing is working fine in Oracle 9.i.
There are no out parameter and no DML, DDL and DCL statement in this fucntion.
Could you please get back me what is the problem on it.
Regards
SUNCheck why your session hangs.
Just a few ideas:
* Blocking locks?
* Endless loop?
* Performance (maybe it is just slow in orac8i and you have to wait a bit longer). Check the execution plans of the SQL statements in your function.
* Don't use a function, but direct SQL, it is faster in both versions.
Maybe you are looking for
-
I changed everything and i signed out then i sign in again but still my. apple id is disabled plz solve this problem!!!!!????
-
Excise Base Amount Not Populated in J1IEX / MIGO in Imports
I have completed all following steps for Import process with CVD. CenVAT is to be taken on CVD. Configuration 1. Maintain Import Pricing procedure with Conditions CVD, Cess and Ecess (JCV1, JECV, J1CV) 2. Create Nil Tax code in FTXP and assign to Com
-
External hard drive constantly dropping USB connection
Last week I bought a 1 TB drive from Hitachi to use for video storage and rendering, but it seems that every 15 minutes or so, the USB connection drops itself and then immediately reconnects. This of course proves to be a problem when it happens whil
-
ITunes won't launch after update
Automatic Updates installed ITunes 11.1.3 and now my ITunes won't launch
-
Multiple EANs per article in Basic Data Maintenance (Retail Master Data)
Hi, Does anyone know how to prevent users from entering an EAN twice for an article? Example: EAN 123456789 for article AAA with unit of measure PC <i><u>cannot be used</u></i> for the same article AAA with unit of measure CS. Thanks.