Sql query not executed using recordset
Hi All,
I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
Dim AltProc as string
AltProc = " USE [DB_name]" & Environment.NewLine
AltProc = AltProc & " GO " & Environment.NewLine
AltProc = AltProc & " ALTER proc [proc_name] " & Environment.NewLine
'---------------------and so on
Orec.DoQuery(AltProc)
this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error. strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
any one has any idea?
thanks in advance,
Binita
HI Binita
The reason:
GO is the "command" delimiter of MS Query Editor.
It is not working with RecordSet Object.
In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
IN SQL 2008 use the Fully Qualified name instead of GO:
Dim AltProc as string
AltProc = " ALTER proc [DB_name].[dbo].[proc_name] " + vbcrlf
'---------------------and so on
Orec.DoQuery(AltProc)
it is not working on MS SQL 2008 i have tried.
'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
Regards,
J.
Edited by: Janos Nagy on Jun 22, 2009 2:55 PM
Similar Messages
-
Hi Forum
i made an application which run on JRun server.
In many of my jsps i used sql query like this:
" select id, name, rollno from student where add = 'jj';"
and retrieve the record from resultset like this:
rs.getString("id");
rs.getString("name");
rs.getString("rollno");
I got no error.
BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
rs.getString("name");
rs.getString("id");
rs.getString("rollno");
i got the error:
java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
I can not understand what is the problem ?
all the datatypes are correct.
all coding is correct.
and everything is correct.
pls help me & suggest a solution.
is there any problem of jdbc API OR of JRUN SERVER SETTINGS?
thanks
mail me at [email protected]
Arvind GoelI would advise against ever using SELECT * - the order of the columns is undetermined so you're bound to hit this problem sooner or later. Besides, it assumes the column names and you know what happens when you assume things...
I would recommend retrieving only the columns you need, in the order you want them and to call ResultSet.getXXX for each of the columns, in order. -
URGENT (sql query not execute)
Hi Forum
i made an application which run on JRun server.
In many of my jsps i used sql query like this:
" select id, name, rollno from student where add = 'jj';"
and retrieve the record from resultset like this:
rs.getString("id");
rs.getString("name");
rs.getString("rollno");
I got no error.
BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
rs.getString("name");
rs.getString("id");
rs.getString("rollno");
i got the error:
java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
I can not understand what is the problem ?
all the datatypes are correct.
all coding is correct.
and everything is correct.
pls help me & suggest a solution.
is there any problem of jdbc API OR of JRUN SERVER SETTINGS?
thanks
mail me at [email protected]
Arvind Goel" select id, name, rollno from student where add =
'jj';"
BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
rs.getString("name");
rs.getString("id");
rs.getString("rollno");
You are retrieving the fields in a different order than what is specified in the select statement.
Some drivers don't allow that (I don't believe it matters what version of the driver you have.) -
XML sql query not displayed using SQLPLUS
Have a registered schema and 1 xml document successfully inserted using Oracle 10.2.0.3.0
I then run the following query:
select extract(object_value,'/warehouse/warehousename')from xwarehouses;
Expecting 1 record to be returned in SQLPLUS but get the following result:
EXTRACT(OBJECT_VALUE,'/WAREHOUSE/WAREHOUSENAME')
1 row selected.
Can anyone shed any light?Thanks A-non.
I checked the long and longchunksize settings and they are the same as yours.
Your sample code runs perfectly but still my original problem remains. -
Concatenate results SQL query and CASE use Report Builder Reporting Services
I need to concatenate the results from a SQL query that is using CASE. The query is listed below. I do not need permitsubtype but I need to concatenate the results from the permittype.
I tried deleting the permitsubtype query and it would not run correctly. Please see the query and diagram below. Any help is appreciated.
select PERMIT_NO
,(case when
ISNULL(PERMITTYPE,'') = ''
then 'Unassigned'
else (select LTRIM(RTRIM(PERMITTYPE)))
END) AS PERMITTYPE
,(case when
ISNULL(PERMITSUBTYPE,'') = ''
then 'Unassigned'
else (select LTRIM(RTRIM(PERMITSUBTYPE)))
END) AS PERMITSUBTYPE
,ISSUED
,APPLIED
,STATUS
,SITE_ADDR
,SITE_APN
,SITE_SUBDIVISION
,OWNER_NAME
,CONTRACTOR_NAME
,ISNULL(JOBVALUE,0) AS JOBVALUE
,FEES_CHARGED
,FEES_PAID
,BLDG_SF
from Permit_Main
where ISSUED between @FromDate and @ToDateHi KittyCat101,
As per my understanding, you used case when statement in the query, you do not need to display permitsubtype in the report, but when you tried to delete permitsubtype from the query, it could not run correctly. In order to improve the efficiency of troubleshooting,
I need to ask several questions:
“I tried deleting the permitsubtype query and it would not run correctly.” As we can see, it has no effect to delete permitsubtype from the query you provided, could you please provide complete sql query for the report?
Could you please provide detailed information about the report? I would be appreciated it if you could provide sample data and screenshot of the report.
Please provide some more detailed information of your requirements.
This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
Thanks,
Wendy Fu -
SQL query not calculating
gross_amount is giving the value of extended_amount and the gross_price_rc is giving the value of unit_selling_price
select customer_trx_line_id,
( extended_amount / 1- (decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) GROSS_AMOUNT,
( unit_selling_price /1-(decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) gross_price_rc
from ra_customer_trx_lines_all
where attribute6 is not null or attribute7 is not null or attribute8 is not null or attribute9 is not null
whats the isuue here??
Thanksdecode(attribute7,null,0)Looking at it again, this always returns 0 or NULL, so it not really surprising
DECODE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions040.htm#i1017437
CASE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions004.htm#i1033392 -
SQL Query not using Composite Index
Hi,
Please look at the below query:
SELECT pde.participant_uid
,pde.award_code
,pde.award_type
,SUM(decode(pde.distribution_type
,'FORFEITURE'
,pde.forfeited_quantity *
pde.sold_price * cc.rate
,pde.distributed_quantity *
pde.sold_price * cc.rate)) AS gross_Amt_pref_Curr
FROM part_distribution_exec pde
,currency_conversion cc
,currency off_curr
WHERE pde.participant_uid = 4105
AND off_curr.currency_iso_code =
pde.offering_currency_iso_code
AND cc.from_currency_uid = off_curr.currency_uid
AND cc.to_currency_uid = 1
AND cc.latest_flag = 'Y'
GROUP BY pde.participant_uid
,pde.award_code
,pde.award_type
In oracle 9i, i"ve executed this above query, it takes 6 seconds and the cost is 616, this is due to non usage of the composite index, Currency_conversion_idx(From_currency_uid, To_currency_uid, Latest_flag). I wonder why this index is not used while executing the above query. So, I've dropped the index and recreated it. Now, the query is using this index. After inserting many rows or say in 1 days time, if the same query is executed, again the query is not using the index. So everyday, the index should be dropped and recreated.
I don't want this drop and recreation of index daily, I need a permanent solution for this.
Can anyone tell me, Why this index goes stale after a period of time???? Please take some time and Solve this issue.
-SankarHi David,
This is Sankar here. Thankyou for your reply.
I've got the plan table output for this problematic query, please go thro' it and help me out why the index CURRENCY_CONVERSION_IDX is used now and why it's not using while executing the query after a day or inserting some records...
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 26 | 15678 | 147 |
| 1 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 89 | 2 |
|* 2 | INDEX UNIQUE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 61097 | | 1 |
| 3 | SORT AGGREGATE | | 1 | 67 | |
|* 4 | FILTER | | | | |
|* 5 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | 67 | 2 |
| 6 | SORT AGGREGATE | | 1 | 94 | |
|* 7 | FILTER | | | | |
|* 8 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 94 | 3 |
|* 9 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | | 2 |
|* 10 | FILTER | | | | |
|* 11 | HASH JOIN | | 26 | 15678 | 95 |
|* 12 | HASH JOIN OUTER | | 26 | 11596 | 91 |
|* 13 | HASH JOIN | | 26 | 10218 | 86 |
| 14 | VIEW | | 1 | 82 | 4 |
| 15 | SORT GROUP BY | | 1 | 116 | 4 |
|* 16 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_LEDGER | 1 | 116 | 2 |
|* 17 | INDEX RANGE SCAN | PARTICIPANT_UID_IDX | 1 | | 1 |
|* 18 | HASH JOIN OUTER | | 26 | 8086 | 82 |
|* 19 | HASH JOIN | | 26 | 6006 | 71 |
| 20 | NESTED LOOPS | | 36 | 5904 | 66 |
| 21 | NESTED LOOPS | | 1 | 115 | 65 |
| 22 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 18 | 756 | 2 |
|* 23 | INDEX RANGE SCAN | KLS_IDX_CURRENCY_CONV | 3 | | 1 |
| 24 | VIEW | | 1 | 73 | 4 |
| 25 | SORT GROUP BY | | 1 | 71 | 4 |
| 26 | TABLE ACCESS BY INDEX ROWID| PART_AWARD_VALUE | 1 | 71 | 2 |
|* 27 | INDEX RANGE SCAN | PAV_PARTICIPANT_UID_IDX | 1 | | 1 |
| 28 | TABLE ACCESS BY INDEX ROWID | PARTICIPANT_AWARD | 199 | 9751 | 1 |
|* 29 | INDEX UNIQUE SCAN | PARTICIPANT_AWARD_PK1 | 100 | | |
|* 30 | INDEX FAST FULL SCAN | PARTICIPANT_AWARD_TYPE_PK1 | 147 | 9849 | 4 |
| 31 | VIEW | | 1 | 80 | 10 |
| 32 | SORT GROUP BY | | 1 | 198 | 10 |
|* 33 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 1 | 42 | 2 |
| 34 | NESTED LOOPS | | 1 | 198 | 8 |
| 35 | NESTED LOOPS | | 2 | 312 | 4 |
| 36 | TABLE ACCESS BY INDEX ROWID| PART_DISTRIBUTION_EXEC | 2 | 276 | 2 |
|* 37 | INDEX RANGE SCAN | IND_PARTICIPANT_UID | 1 | | 1 |
| 38 | TABLE ACCESS BY INDEX ROWID| CURRENCY | 1 | 18 | 1 |
|* 39 | INDEX UNIQUE SCAN | CURRENCY_AK | 1 | | |
|* 40 | INDEX RANGE SCAN | CURRENCY_CONVERSION_AK | 2 | | 1 |
| 41 | VIEW | | 1 | 53 | 4 |
| 42 | SORT GROUP BY | | 1 | 62 | 4 |
|* 43 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_VESTING | 1 | 62 | 2 |
|* 44 | INDEX RANGE SCAN | PAVES_PARTICIPANT_UID_IDX | 1 | | 1 |
| 45 | TABLE ACCESS FULL | AWARD | 1062 | 162K| 3 |
| 46 | TABLE ACCESS BY INDEX ROWID | CURRENCY | 1 | 18 | 2 |
|* 47 | INDEX UNIQUE SCAN | CURRENCY_AK | 102 | | 1 |
Predicate Information (identified by operation id):
2 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2
"PAPS"."INSTALLMENT_NUM"=1)
4 - filter(4105=:B1)
5 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
7 - filter(4105=:B1)
8 - filter("PAPS"."STATUS"='OPEN')
9 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
10 - filter("CC_A_P_CURR"."FROM_CURRENCY_UID"= (SELECT /*+ */ "CURRENCY"."CURRENCY_UID" FROM
"EWAPDBO"."CURRENCY" "CURRENCY" WHERE "CURRENCY"."CURRENCY_ISO_CODE"=:B1))
11 - access("SYS_ALIAS_7"."AWARD_CODE"="A"."AWARD_CODE")
12 - access("SYS_ALIAS_7"."AWARD_CODE"="PVS"."AWARD_CODE"(+))
13 - access("SYS_ALIAS_8"."AWARD_CODE"="PALS"."AWARD_CODE" AND
"SYS_ALIAS_8"."AWARD_TYPE"="PALS"."AWARD_TYPE")
16 - filter(TRUNC("PAL1"."LEDGER_ENTRY_DATE")<=TRUNC(SYSDATE@!) AND "PAL1"."ALLOC_TYPE"='IPU')
17 - access("PAL1"."PARTICIPANT_UID"=4105)
filter("PAL1"."PARTICIPANT_UID"=4105)
18 - access("SYS_ALIAS_8"."AWARD_CODE"="PDES"."AWARD_CODE"(+) AND
"SYS_ALIAS_8"."AWARD_TYPE"="PDES"."AWARD_TYPE"(+))
19 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_8"."AWARD_CODE")
23 - access("CC_A_P_CURR"."TO_CURRENCY_UID"=1 AND "CC_A_P_CURR"."LATEST_FLAG"='Y')
27 - access("PAV"."PARTICIPANT_UID"=4105)
filter("PAV"."PARTICIPANT_UID"=4105)
29 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_9"."AWARD_CODE" AND
"SYS_ALIAS_7"."PARTICIPANT_UID"=4105)
30 - filter("SYS_ALIAS_8"."PARTICIPANT_UID"=4105)
33 - filter("CC"."LATEST_FLAG"='Y')
37 - access("PDE"."PARTICIPANT_UID"=4105)
filter("PDE"."PARTICIPANT_UID"=4105)
39 - access("OFF_CURR"."CURRENCY_ISO_CODE"="PDE"."OFFERING_CURRENCY_ISO_CODE")
40 - access("CC"."FROM_CURRENCY_UID"="OFF_CURR"."CURRENCY_UID" AND "CC"."TO_CURRENCY_UID"=1)
43 - filter("PV"."VESTING_DATE"<=SYSDATE@!)
44 - access("PV"."PARTICIPANT_UID"=4105)
filter("PV"."PARTICIPANT_UID"=4105)
47 - access("CURRENCY"."CURRENCY_ISO_CODE"=:B1)
Note: cpu costing is off
93 rows selected.
Please help me out...
-Sankar -
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. -
Executing sql query(not through sqlfile) from batchfile
Hi,
I have written a batchfile below which should execute the sql query. Can someone please help me in modifying the below code. I know we can make use of sql file ,but wanted it to be more robust and hence everything in a single batch file instead of having combination of sqlfile and batchfile.
@echo off
set ORACLE_HOME=%RAMBOH%
set ORACLE_SID=%RAMBSID%
set path=%RAMBOH%\bin;%RAMBOH%\admin\Ramb_Scripts;%path%
sqlplus sys/XXX as sysdba
@echo SET SERVEROUTPUT ON;
@echo DECLARE
@echo v1 DATE;
@echo BEGIN
@echo SELECT SYSDATE INTO V1 FROM DUAL;
@echo DBMS_OUTPUT.PUT_LINE(v1);
@echo END;
@echo /I used the below syntax to execute a procedure
set ORACLE_SID=orcl
echo exec MyProcedure;
echo exit
)|sqlplus system/manager >MyProcedure.log
Try making modifications to this and see if this helps you in executing the SQL from the batch file -
Hi All,
Please help with the error ORA-00923: FROM keyword not found where expected.
I am trying to execute the following SQL query.
SELECT
CASE
WHEN (Grouping("PRICECATEGORY"."PriceCategoryName")=1) THEN "PriceCatTotal"
ELSE "PRICECATEGORY"."PriceCategoryName"
END AS "PRICECATEGORY"."PriceCategoryName",
CASE
WHEN (Grouping("LINEITEM"."LineDescription")=1) THEN "LineTotal"
ELSE "LINEITEM"."LineDescription"
END AS "LINEITEM"."LineDescription" ,
*"INVOICE"."InvoiceDate",*
Sum("TRANSACTION"."TotalPrice") as "TotalPrice",
Sum("INVOICE_CHILD"."QUANTITY") as "Quantity"
FROM "LINEITEM","INVOICE","TRANSACTION","PRICECATEGORY", "INVOICE_CHILD"
WHERE "TRANSACTION"."InvoiceID"="INVOICE"."InvoiceNumber"
and "TRANSACTION"."PriceCategoryID"="PRICECATEGORY"."PriceCategoryID"
and "INVOICE_CHILD"."INVOICEID"="INVOICE"."InvoiceID"
and "PRICECATEGORY"."PriceCategoryID"="TRANSACTION"."PriceCategoryID"
and "TRANSACTION"."PriceCategoryID"="PRICECATEGORY"."PriceCategoryID"
and "PRICECATEGORY"."PriceCategoryID"="TRANSACTION"."PriceCategoryID"
and "LINEITEM"."LINEITEMID"="TRANSACTION"."LineItemID"
and "LINEITEM"."PRICECATEGORYID"="PRICECATEGORY"."PriceCategoryID"
and "INVOICE"."InvoiceDate" >= :STARTDATE and "INVOICE"."InvoiceDate" <= to_date(:ENDDATE,'DD-MON-YY')+1
GROUP BY "PRICECATEGORY"."PriceCategoryName", "LINEITEM"."LineDescription" WITH ROLLUP
I am using a from keyword at the right place and all the aliases are properly used.
Please advice.
Regards,
Sandeep ReddyJaydip and Jeff are correct:
<li>Jaydip points out that <tt>"PRICECATEGORY"."PriceCategoryName"</tt> and <tt>"LINEITEM"."LineDescription"</tt> are not valid column alias names. They must be unqualified, nonquoted/quoted identifiers.
<li>Jeff indicates that <tt>WITH ROLLUP</tt> is not Oracle SQL syntax, and provides a sample of the required ROLLUP/CUBE clauseOracle SQL <tt>ROLLUP/CUBE clause</tt>.
Additionally, <tt>TRANSACTION</tt> is an Oracle keyword and therefore a poor choice as a database identifier: change the name of this table as soon as possible.
You're having this problem because not all "SQL" is created equal. Your OdeToCode source appears to be a site dealing with Microsoft technologies (SQL Server in this case). Unless you are very familiar with Oracle and SQL Server and the inherent differences between them you'd be advised to stick to purely Oracle resources (I know I do). There are plenty of good Oracle resources out there.
You'll also find it a lot easier to write, read and spot problems in SQL and PL/SQL code if you avoid using quoted identifiers (please tell us the database objects don't have case-sensitive names?) and use short table aliases rather than full table names. And we'll find it easier to help you on this forum if you post code samples wrapped in \...\wrapped in <tt>\...\</tt> tags. -
Kodo 3.4.1: how to limit # of sql query params when using collection param
Hi,
We have a problem when using Kodo 3.4.1 against SQL Server 2005, when we execute query:
Query query = pm.newQuery( extent, "IdList.contains( this )" );
query.declareParameters( "Collection IdList" );
query.declareImports( "import java.util.Collection;" );
return (List) query.execute( list );
We got:
com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:354)
at com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.executeQuery(PoolConnection.java:341)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1106)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
at kodo.jdbc.runtime.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1730)
at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:339)
at kodo.jdbc.sql.Select.execute(Select.java:1581)
at kodo.jdbc.sql.Select.execute(Select.java:1533)
at kodo.jdbc.runtime.SelectResultObjectProvider.open(SelectResultObjectProvider.java:102)
at com.solarmetric.rop.EagerResultList.<init>(EagerResultList.java:22)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:1081)
at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:836)
at kodo.query.AbstractQuery.execute(AbstractQuery.java:799)
It seems that there're too many ids in the list, and Kodo didn't limit the # of sql parameters when craft the sql query. Is there a way to ask Kodo to use multiple queries with smaller # of sql parameters instead of using one big sql query?
ThanksHi,
Sadly, there is no way to do that in Kodo currently. The closest is the inClauseLimit DBDictionary setting, but that setting just breaks things up into multiple IN statements put together with an OR clause. In your case, it looks like the network transport, not the SQL parser, is complaining about size limits.
You could force the query to run in-memory, but that would probably be prohibitively slow, unless the data set that you're querying against is relatively small.
-Patrick -
Trigger query not executed and havenot any exception
Hello all,
I am using oracle 10g lite database, and i m firing a create trigger query, but it is not executed on console, when i try at console at this trigger query after that no one query will fire,
Plzzzzzzzzzzzzzzzzzzz help me
my used table is
1. create table t1 ( c1 int, c2 int);
2. create table t2 (c1 int, c2 int);
3. Create trigger System.check after insert on system.t1 For each Row begin Insert Into system.t2 ( c1,c2 ) Values (1,1) ;end ;
Thankx in advance
PankajTriggers are supported on the client side in newer versions:
11.2.1 Creating Java Stored Procedures
To create a stored procedure, perform the following:
1.
Create the class that you want to store in Oracle Database Lite. You can use any Java IDE to write the procedure, or you can simply reuse an existing procedure that meets your needs.
When creating the class, consider the following restrictions on calling Java stored procedures from SQL DML statements:
When called from an INSERT, UPDATE, or DELETE statement, the method cannot query or modify any database tables modified by that statement.
When called from a SELECT, INSERT, UPDATE, or DELETE statement, the method cannot execute SQL transaction control statements, such as COMMIT or ROLLBACK.
Note:
Any SQL statement in a stored procedure that violates a restriction produces an error at run time.
2.
Provide your class with a unique name for its deployment environment, since only one Java Virtual Machine is loaded for each Oracle Database Lite application. If the application executes methods from multiple databases, then the Java classes from these databases are loaded into the same Java Virtual Machine. We recommend that you prefix the Java class name with the database name to ensure that the Java class names are unique across multiple databases.
3.
If you are executing any DML statements in your Java stored procedure, then—in order for these statements to exist within the same transaction—you must pass an argument of type java.sql.Connection as the first argument in the method. You must have the Connection object in order to prepare and execute any statements. Oracle Database Lite supplies the appropriate argument value of the Oracle Lite database Connection object for you; the application executing the method does not need to provide a value for this parameter. -
Inline transform for Sql Query not working in SAP MII 12.1 Version 12.1.8 B
Hi All,
I applied an xslt for an sql query which returns an xml file.
I used inline transform icon in sql query to load an xsl file which has to return me a string
Any idea why is not working for me..?
My Sample XML file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/XMII/CM/BatchDisposition/BatchQueueManagement/StyleSheets/ProductXsl.xsl"?>
<Rowsets DateCreated="2011-05-05T07:27:45" EndDate="2011-05-05T07:27:45" StartDate="2011-05-05T06:27:45" Version="12.1.8 Build(20)">
<Rowset>
<Columns>
<Column Description="ProductName" MaxRange="1" MinRange="0" Name="ProductName" SQLDataType="12" SourceColumn="ProductName"/>
</Columns>
<Row>
<ProductName>Asprin 100mg Tablets 12 x10 strip</ProductName>
</Row>
<Row>
<ProductName>Asprin 300mg Tablets 12 x10 strip</ProductName>
</Row>
<Row><ProductName>Ibprooven 200mg Tablets 12 x 10 strip</ProductName></Row>
<Row><ProductName>RipTide 50mg Tablets 40 x10 strip</ProductName></Row>
<Row><ProductName>Seroquel 200mg Tablets 6 x10 strip</ProductName></Row>
<Row><ProductName>Seroquel 400mg Tablets 12 x10 strip</ProductName></Row>
</Rowset>
</Rowsets>
My Sample XSl File:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:text>["</xsl:text>
<xsl:for-each select="Rowsets/Rowset/Row">
<xsl:value-of select="ProductName"/>
<xsl:if test="position() < last()">
<xsl:text>","</xsl:text>
</xsl:if>
<xsl:if test="position()=last()">
<xsl:text>"]</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Any Suggestions are Welcome:
ThanksSomething like this should work...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Rowsets DateCreated="{Rowsets/@DateCreated}" Version="{Rowsets/@Version}" StartDate="{Rowsets/@StartDate}" EndDate="{Rowsets/@EndDate}">
<xsl:copy-of select="/Rowsets/FatalError"/>
<xsl:copy-of select="/Rowsets/Messages"/>
<Rowset>
<Columns>
<Column Description="Mycol1" MaxRange="1" MinRange="0" Name="Mycol1" SQLDataType="12" SourceColumn="Mycol1" />
</Columns>
<Row>
<Mycol1>
<xsl:text>["</xsl:text>
<xsl:for-each select="/Rowsets/Rowset/Row">
<xsl:value-of select="." />
<xsl:choose>
<xsl:when test="position() < last()"><xsl:text>","</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>"]</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</Mycol1>
</Row>
</Rowset>
</Rowsets>
</xsl:template>
</xsl:stylesheet> -
Sql query slow while using poc *C, OCI
Sql query is taking long time while using fetching records from RAC using Pro *C, OCI. Same query working fine while using JDBC connection.what could be the issue.Please help
Thanks,
SamPro*C is not part of Oracle Solaris Studio (formerly Sun Studio). Studio has no special support for database programming. You are more likely to get a helpful answer in a database programming forum. Start here:
https://forums.oracle.com/forums/category.jspa?categoryID=18 -
SQL Statement not works using functions or subqueries-MAXDB
Hello All,
I created an ABAP program to select information about country(table: T005) with the country names (Table: T005T). I tried to create a sql query with a sql subquery to select everything but for some reason that I don't know it doesn't work. Please find the query below.
DATA:
resu TYPE REF TO cl_sql_result_set ,
stmt TYPE REF TO cl_sql_statement ,
qury TYPE string .
qury = `SELECT land1, spras, `
&& `(SELECT landx `
&& `FROM SAPNSP.T005T `
&& `WHERE mandt = '` && sy-mandt && `' `
&& `AND spras = 'EN' `
&& `AND land1 = ? ), `
&& `(SELECT natio `
&& `FROM SAPNSP.T005T `
&& `WHERE mandt = '` && sy-mandt && `' `
&& `AND spras = 'EN' `
&& `AND land1 = ? ) `
&& `FROM SAPNSP.T005 `
&& `WHERE mandt = '` && sy-mandt && `' `
&& `AND land1 = ? `
&& `GROUP BY land1, spras` .
resu = stmt->execute_query( qury ) .
Well, the query above works but the fields LANDX and NATIO are in blank in ALL THE CASES, even with information registred in table T005T.
So, exploring the SDN forum and after read some documents regarding ADBC, I create a function to handle this sql select and get the correctly the missing informations, but, still don't work. Please find the function below:
CREATE FUNCTION select_landx (land1 CHAR(3)) RETURNS CHAR(15)
AS
VAR landx CHAR(15);
DECLARE functionresult CURSOR FOR
SELECT spras, land1, landx
FROM SAPNSP.t005t
WHERE spras = 'EN'
AND land1 = :land1;
IF $count IS NULL THEN <- | $count is always 0, my SELECT
BEGIN it's not work but I don't know why
CLOSE functionresult;
RETURN NULL;
END
ELSE
SET $rc = 0;
WHILE $rc = 0 DO
BEGIN
FETCH functionresult INTO :landx;
END;
CLOSE functionresult;
RETURN landx;
Calling the function in a SQL statement:
DATA:
resu TYPE REF TO cl_sql_result_set ,
stmt TYPE REF TO cl_sql_statement ,
qury TYPE string .
qury = `SELECT land1, spras, select_landx(?) landx `
&& `FROM SAPNSP.T005 `
&& `WHERE mandt = '` && sy-mandt && `' `
&& `AND land1 = ? `
&& `GROUP BY land1, spras` .
resu = stmt->execute_query( qury ) .
Any comments ?
Best regards,
Arthur SilvaHello,
Thank's a lot, it works. It's funny because the given solution works using only abap codes.
It may be happens because the abap interpretor send the sql statement to the db interface that handle the code in the another way.
Thanks again, it was driving me crazy.
Best regards,
Arthur Silva
Maybe you are looking for
-
Does R3 have a report or function module to process payments requests?
HI All, I want R3 report or function module which will receive payment requests from vendor or customer and then procees it depending on the data. Does R3 have such a report or function module to process payments requests? Please help me. Thanks.
-
How to download graph output into word document?
Hello experts! I have plotted graphs using some data. The graph is actually output of a function module into a container. Can anybody tell me , how can i download this graphs into a word document? I am able to download text data into word documents,
-
RFC to JDBC ( Ms Access )
Hi I am working on RFC to JDBC scenario. I have done the configuration as per http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417700)ID2063057750DB01438375578713251689End?blog=/pub/wlg/2590 I am getting the following error message "com.sap.ai
-
I have gone to the developers page on facebook. Grabbed the code in the first box and placed the HTML box at the top of my home page. Then grabbed the second/plugin code and placed it on my home page. When I preview the feed doesn't show up, nor does
-
AD provisioning - Prepopulate Attributes
Hi everyone, In OIM 11g R2, I want to provision to AD. I can this operation. But I can not pre-populate attributes. In AD user form, some pre-populate attributes is defined. In AD provisioning process definition, auto-prepopulate is selected. What el