Using Quotes in a Query
I am running CF MX7 Enterprise, and using a Sybase driver as
the datasource. I can run this query just fine:
select my_field from my_table
where my_key = '1234'
but I get an error when I replace the single quotes with
double quotes (shift-quote on the keyboard), like this:
select my_field from my_table
where my_key = "1234"
If I switch to an ODBC socket either one will work. It's just
the Sybase driver that throws the error. Does anyone have any
expeience with this?
gmtjr wrote:
> I am running CF MX7 Enterprise, and using a Sybase
driver as the datasource. I
> can run this query just fine:
>
> select my_field from my_table
> where my_key = '1234'
>
> but I get an error when I replace the single quotes with
double quotes
> (shift-quote on the keyboard), like this:
>
> select my_field from my_table
> where my_key = "1234"
>
> If I switch to an ODBC socket either one will work. It's
just the Sybase
> driver that throws the error.
Every proper database server will throw an error because the
SQL
standard says that you are not supposed to do that.
Convert your queries to use cfqueryparam to solve the
problem.
Jochem
Jochem van Dieten
Adobe Community Expert for ColdFusion
Similar Messages
-
How to use the same POWL query for multiple users
Hello,
I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
"Query 'ABC' is already open in another session."
where 'ABC' is the query name.
Can you please tell me how to use the same POWL query for multiple users ?
A fast reply would be highly appreciated.
Thanks and Regards,
SandhyaBatch processing usually involves using actions you have recorded. In Action you can insert Path that can be used during processing documents. Path have some size so you may want to only process document that have the same size. Look in the Actions Palette fly-out menu for insert path. It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..
-
Powershell use Connection String to query Database and write to Excel
Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
$excel = New-Object -Com Excel.Application
$excel.Visible = $True
$wb = $Excel.Workbooks.Add()
$ws = $wb.Worksheets.Item(1)
$ws.name = "GUP Download Activity"
$qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
if ($qt.Refresh()){
$ws.Activate()
$ws.Select()
$excel.Rows.Item(1).HorizontalAlignment = $xlCenter
$excel.Rows.Item(1).VerticalAlignment = $xlTop
$excel.Rows.Item("1:1").Font.Name = "Calibri"
$excel.Rows.Item("1:1").Font.Size = 11
$excel.Rows.Item("1:1").Font.Bold = $true
$filename = "D:\Script\Reports\Status_$a.xlsx"
if (test-path $filename ) { rm $filename }
$wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
$wb.Saved = $True #flag it as being saved
$wb.Close() #close the document
$Excel.Quit() #and the instance of Excel
$wb = $Null #set all variables that point to Excel objects to null
$ws = $Null #makes sure Excel deflates
$Excel=$Null #let the air out
I would like to use connection string to query the database and write results to EXCEL, i.e.
$SQL_Statement = "SELECT ..."
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
$conn.Open()
$cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
do{
try{
$rdr = $cmd.ExecuteReader()
while ($rdr.read()){
$sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
$transactionComplete = $true
catch{
$transactionComplete = $false
}until ($transactionComplete)
$conn.Close()
How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?Hi Q.P.Waverly,
If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
$sql_output=@()
do{
try{
$rdr = $cmd.ExecuteReader()
while ($rdr.read()){
$sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
$transactionComplete = $true
catch{
$transactionComplete = $false
}until ($transactionComplete)
$conn.Close()
Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
$sql_output | Export-Csv d:\data.csv
Or you can export to worksheet like:
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$workbook = $excel.Workbooks.Add()
$sheet = $workbook.ActiveSheet
$counter = 0
$sql_output | ForEach-Object {
$counter++
$sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
Refer to:
PowerShell and Excel: Fast, Safe, and Reliable
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang -
How to use Results from Another Query for SAP BW universes
Hi Everyone,
I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding Sales doc no in first data provider.
I want to place all these fileds into a single report like as shown.
(Datarpovider1) (Datarpovider1) (Datarpovider2)
*Sales Doc No* Orderqty BillQty
Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
I tried it but it was giving the follwing error:
A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
All this I am doing in Webi Rich Client.
Appreciate your help
Thanks &in Advance
Kiran SakaHi Kiran,
I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
Regards,
Neeraj -
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 -
How can I remove ASCII text from a field when I use it in a query
How can I remove ASCII text from a field when I use it in a query?
I am running a select statement on a table that appears to have ASCII text in some of the fields. If I use these fields in the where statement like the code below nothing returns:
SELECT FIELD1 FROM TABLE1 WHERE FIELD1 IS NULL
But the field looks empty if I do a straight select without the where clause. Additionally, one of the fields has text but appears to be padded out with ASCII text, which I need to strip out before I can use this field in a where or join statement. I have tried using a trim, ltrim, rtrim, to_char, nvl, decode and nothing works. When I use excel to run the same query it looks as if these ASCII fields are boxes.
I have asked our DBA team to see what they can do to prevent these from going into the table, but in the mean time I still need to run this report.
Do you have any suggestions?Can you provide an example? I've been trying (for
example) "select translate(' test one', ascii(' '),
'X') from dual" with no luck.
Thank you.To replace space, you should query like this:
select translate(' test one', chr(32), 'X') from dual instead of select translate(' test one', ascii(' '), 'X') from dual Thanks,
Dharmesh Patel -
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. -
Hello all,
I just tried to use variable in a query and dont know how to
output the content in the query. As you can see from what i am
trying, i would only get the name of the query and the field name
not the output. Please tell me the idiotic thing that i am over
looking.
MattMike,
Thanks, ...if you were to output the url.fieldused, then you
would get the name of the field, not the value of the field. The
getfield[ ] is not something that i am familier with and cant seem
to find documentation on this...I need to output the value of the
field and this is where i am stuck.
Matt -
Can we use Result from another query in Webi using Bex uery universe?
Hi,
Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
Has anyone run into the same issue and if this is possible and what should be the solution?
Thanks in advance!
Edited by: BO_Haiyan on Oct 6, 2010 3:47 PMIn that situation:
Create two queries : Oracle and BW query.
@ Report:
As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
Hope it helps you.
Thank You!! -
Imagine an invoice was created for a customer on the 1st of January 2008 for £1000
On the 1st of Feb, he paid $300, owing $700
On the 1st of Mar, he paid $450, owing $250
On the 1st of Apr, he paid $250.
If I run an AR report today the 10th of Aug, I would see he owes nothing. What I want to do is to run the report today based on the 2nd of March and see a debt of £250. I dont want to use the posting date in the selection criteria henceI think this is the case when you use a key date but Im not sure how to use this in the query properties of BI7. What Characteristic do I need to specify as time dependant? Is there anything else I should consider?hi,
Key Date setting is for the 'time dependent' master data.
Lets say u have a Characteristic MATERIAL with a time dependent attribute MATERIAL GROUP as follows.
MATERIAL FROM TO MATERIAL GROUP
ABD 01/01/1995 12/31/2003 X
ABD 01/01/2004 12/31/9999 Y
Depending on what you have for the Keydate, the Material group is selected.
If your key date is, ex, 06/12/2001 there material group is X. Or if key date is 02/15/2005, material group is Y.
If you do not enter any value for keydate, system automatically assumes today' date.
hope it helps.. -
How to find out query name using Elements of the query builder.
Hi SDNers,
how to find out query name using Elements of the query .
thanks,
satyaaHi,
For having a look at the relation between BEx tables,check the link below:
http://wiki.sdn.sap.com/wiki/display/BI/ExploretherelationbetweenBEx+Tables
-Vikram -
SSMS 2012: Using CTE in a query - Invalid column name 'EmployeeID' !!??
Hi all,
From Page 88 of the Book "SQL Programming & Database Design Using Microsoft SQL Server 2012" written by Kalman Toth, I copied the following code of Using CTE in a query:
-- CTETest2.sql /// saved in C:\My Documents\SQL Server Management Studio\
----Page 88 of Book by Toth === Using CTE in a query ----- 13 March 2015
--Using CTE in a query
;WITH CTE (SalesPersonID, NumberOfOrders, MostRecentOrderDate)
AS (SELECT SalesPersonID, COUNT(*), CONVERT(date, MAX(OrderDate))
FROM Sales.SalesOrderHeader GROUP BY SalesPersonID )
--Start of outer (main) query
SELECT E.EmployeeID,
OE.NumberOfOrders AS EmpOrders,
OE.MostRecentOrderDate AS EmpLastOrder,
E.ManagerID,
OM.NumberOfOrders AS MgrOrders,
OM.MostRecentOrderDate AS MgrLastOrder
FROM HumanResources.Employee AS E
INNER JOIN CTE AS OE ON E.EmployeeID = OE.SalesPersonID
LEFT OUTER JOIN CTE AS OM ON E.ManagerID = OM.SalesPersonID
In my SQL Server 2012 Management Studio, I executed this set of code and I got the following fatal error:
Msg 207, Level 16, State 1, Line 16
Invalid column name 'EmployeeID'.
I have no clues why I got this error message in this .sql trial of my second practice in doing CTE. Please kindly help and let me know where I made mistake and how to resolve this problem.
Thanks in advance,
Scott ChangHi scott_morris-ga, Thanks for your nice response.
I changed EmployeeID to BusinessEntityID as you pointed out and executed the revised code:
-- CTETest2.sql /// saved in C:\My Documents\SQL Server Management Studio\
----Page 88 of Book by Toth === Using CTE in a query ----- 13 March 2015
--Using CTE in a query
;WITH CTE (SalesPersonID, NumberOfOrders, MostRecentOrderDate)
AS (SELECT SalesPersonID, COUNT(*), CONVERT(date, MAX(OrderDate))
FROM Sales.SalesOrderHeader GROUP BY SalesPersonID )
--Start of outer (main) query
SELECT E.BusinessEntityID,
OE.NumberOfOrders AS EmpOrders,
OE.MostRecentOrderDate AS EmpLastOrder,
E.ManagerID,
OM.NumberOfOrders AS MgrOrders,
OM.MostRecentOrderDate AS MgrLastOrder
FROM HumanResources.Employee AS E
INNER JOIN CTE AS OE ON E.BusinessEntityID = OE.SalesPersonID
LEFT OUTER JOIN CTE AS OM ON E.ManagerID = OM.SalesPersonID
I got 2 new error messages:
Msg 207, Level 16, State 1, Line 17
Invalid column name 'ManagerID'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'ManagerID'.
I have no ideas what should be used to replace 'ManagerID' in my revised code. Could you please help again and give me the right thing to replace the 'ManagerID'? By the way, where in the AdventureWorks do you find the right things? Please enlighten
me in this matter.
Many Thanks again, Scott Chang -
From scorecard Pass parameter to be used as Measure in query of analytic grid report in PPS
Any idea of how we can pass this parameter while connecting scorecard and report
any use of MDX in connection formula ?
Parameter needs to be assigned on click of scorecard cellHi,
That API has restrictions on its usage. Please see http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_util.htm#CHDICGDA
The lines to be referred to are Also, this method requires that the parameters that describe the BLOB to be listed as the format of a valid item within the application. That item is then referenced by the function.Regards,
PS: Your report must be on Page 98 , so it is able to reference the item P98_NAV_IMAGE. List being a Shared Component it may not be able reference that Item.
Edited by: Prabodh on May 28, 2012 3:16 PM -
How can i know which index will be used when executing the query ?
1 ) I have query in which i have 3-4 tables but there multiple index on one column .
so how can i know which index will be used when executing the query ?
2) I have a query which ia taking too much time . how can i know which table is taking too much time ?
3) Please Provide me some document of EXplain plan ?Hi Jimmy,
Consider the below example
/* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
CREATE TABLE FIRST AS
SELECT * FROM all_objects;
UPDATE FIRST
SET object_name = 'TEST'
WHERE owner != 'SCOTT';
CREATE INDEX idx_first ON FIRST(object_name);
SELECT *
FROM FIRST
WHERE object_name = 'TEST';
It has not used index
Execution Plan
Plan hash value: 2265626682
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 58678 | 7334K| 163 (4)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| FIRST | 58678 | 7334K| 163 (4)| 00:00:02 |
/* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
SELECT *
FROM FIRST
WHERE object_name = 'emp';
This has used the index
Execution Plan
Plan hash value: 1184810458
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 128 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| FIRST | 1 | 128 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_FIRST | 1 | | 1 (0)| 00:00:01 |
From this we can come to the conclusion that, whether to use one index or not by oracle
would also depend on the data which is present in the table. This has to be this way as
we see in the bind peeking, if oracle sticks to only one plan, say only use the full table
scan, it would be a performance hit when it searches for the second query ie where object_name
='emp';
2.
If we have a query like below.
select * from emp
where upper(ename) = upper(:p_ename);
Evenif we have the index on ename column, oracle wouldn't be able to use the index, as there is a function in the predicate column. If you need oracle to use the index, we need to create a function based index as below.
Create index idx_ename on emp(upper(ename));
Regards,
Cool -
Using attributes in a Query, doesnu00B4t work!
I have implemented an infocube 0SD_C03, and i have my material attributes filled in the 0MATERIAL characteristic, but when i use them in the query, the don't appear.
Can somebody help me?
Thank YouHi Dirk,
I'have done everything ok, create the new objects, for our material classifications, create the transfer rules, update roles, infosources, adding the 0material characteristics, put the new attributes as navigational, and filled all with the data necessary, but i have now idea that the master data have to be activated just in the end!!!!
thanks a lot, i have my problem solved!!!!
Maybe you are looking for
-
Check on PO Creation for vendor Open Advances
Hi : There is a requirement from the client . They want to put a check on PO creation against vendor . It is if for example vendor has open advances exceeding 5 million then system should check it at the time of PO creation and should stop or warn th
-
Renewed Cert on ASA, Upgraded from AnyConnect 2.5 to 3.1
We had been running AnyConnect 2.5 against our ASA and the Cert on our ASA Expired. the 2.5 Client (and all of the iPad Clients) had a way of saying, its cool, connect anyway if the Cert is not valid. I finially got around to renewing the cert on th
-
New Intel Mini makes a slight whirring noise
Hi I have just replaced my old G4 Mac Mini with a entry level Intel Mini. I noticed the new one maked a slight whirring noise constantly. Its only minor but noticable in the background The old Mini just used to have a slight fan noise which was more
-
How do you stop automatic import into iPhoto?
I am a photoshop user, a pro, but new to the mac. iPhoto is installed and everytime I insert a compact flash card into the system, iPhoto starts up and attempts to import the photos. How do I stop this? I don't want iPhoto. I want Photoshop or nothin
-
Cisco Ironport c160 licence upgrade
hi all, What i need to do to upgrade expired license for ironport c160, Where can I read about product number for this type of license?