SQL STATEMENT OF A QUERY
Hi all
Can we see the SQL statement of a BEx query, if so , where and how?
Thanks in advance.
Yes, you can do that in transaction RSRT. Enter the query name, click the button "Execute & Debug" and click the checkbox for SQL code.
Similar Messages
-
Changing sql-statement before executing query
I want to change the sql-statement of a query just before it is executed.
I have tried it with a query redirector/sessionevent listener, but I could get it to work.
Do you have any examples.
I want to change the tablename in a sql-statement like this:
before
select id from emp
after
select id from emp_v
Any examples out there to do this?... I am using SAP NetWeaver BI 7.0
Monique -
Can I change sql statement for some query runtime?
Hi All!
The problem that I have to implement report with query like this: select * from a where b in (?,?,?). The number of parameters depends on user choice. On the client side it will be a list of check boxes. Is there any way to implement such report? I can see just one way so far - to modify sql statement runtime.
Thanks!hello,
create a user-parameter myListe or myWhere (wee examples below) and change your query to
select ... from ... where b in (&<myList>)
or even better
select ... from ... &<myWhere>
now you can pass in the constructed list or where clause. you can also construct the values in the afterParameterform-Trigger
regards,
philipp -
How to get SQL statement from (Collection) query.execute();
We have a JDO Persistence class ClassName that execute query using following code. After this statement get executed, record does not get updated in the DB. Is there a way to check what SQL statement got submitted in the (Collection) query.execute(); ??? <br><br>
Extent extent = pm.getExtent(ClassName.class, false); <br>
Query query = null; <br>
try { <br>
query = pm.newQuery(extent, filter); <br>
Collection results = (Collection) query.execute();<br>
Iterator i = results.iterator();<br>
if (i.hasNext()) {<br>
...<br>
}<br>You can always find out the names of tables that are views, using java.sql.DatabaseMetaData and its getTables() method.
This tends to be a nice source of examples:
javaalmanac.com
However, if you're asking for the underlying SQL used to CREATE VIEW, I don't see anything in the API that will give you that. After all, JDBC shouldn't have to know if it's dealing with an ordinary table or a view. I think you'd have to ask your DBA for the underlying SQL.
Once you have it, what do you plan to do with it?
% -
SQL Statement needed for Query Generator
Dear Experts,
My view has the following three columns.
1, Start Date
2. End Date
3. Balance.
I need an SQL statement to write in query generator, which has to check if EndDate is less than the Current date and balance is above zero. If so, it assumes the last date of the job is already over, outstanding materials not yet been returned. Hence it has to return 'Pending'. If EndDate is greater than current date, it means final date for completion of the process is yet to come. So the task is in progress, hence it has to return 'Progress'. If the balance is Zero, all materials connected with the task have been received either as a FG or as Raw Materials. So it has to return, 'Completed'. I need a singe SQL Statement for this.
Please help me.
Thanks in advance.
Regards
AnandDear Anand,
Try this one:
CASE balance WHEN 0 THEN 'Completed' ELSE CASE WHEN DATEDIFF(DD, EndDate, GetDate()) >= 0 THEN 'Progress' ELSE 'Pending' END END
I have assumed you don't have negative balance. It that is not true, give me the complete case.
Thanks,
Gordon
Thanks,
Gordon -
is there any chance to get the sql statement (not program) from any abap query created via SQ01?
I can get the code of program that generated by system, but I cannot get pure sql statement.
any answer will be appreciatedI see no parameters, and in the abstract that SQL ought to work.
However, I halfway suspect that either User, Users, Password, or pass is a reserved word and somebody is getting confused. Try renaming your columns and table... -
SQL statement running balance query with previous balance taken into account
Hi Guys
I have a SQL statement which caclulates the running balance
for a list of transactions in a transactions table. This SQL
statement is as follows:
SELECT transID, debit, credit,
(SELECT SUM(debit-credit)
FROM transactions as D1
WHERE D1.transID <= D0.transID) AS balance
FROM transactions AS D0
The only problem I'm having is that I have to display
transactions between a particular date range. I have for eg.
transID, transDate, debit, credit fields in my db.
However the problem I'm having is that when the transaction
records are pulled out for the specified date range the balances
are only calculated for those records. I need someway of having a
balance b/f (brought forward) so that the selected records use that
as a 'starting' balance and then calculate the running balance as
normal.
Any easy solutions?
Many, many thanks for your help in advance.
All the best
WesleyYou'd need to determine the b/f then apply it against the
transaction records when they are pulled for a date range. So if
the date range is
Feb 1st, 2009 -> Feb 28th, 2009
You'd need to also get the previous balance in a separate
query, then use it to correctly display the running balance when
you output the date range.
I suppose a simpler way involving a little more DB work (and
possibly lots of coding) is to store the current balance as well
with each transaction; then when performing a date range you'd have
the balance as well and not have to calculate it on the fly. -
Powershell - SQL statement for WMI query
Need to input / update sql database, two main tables: server and diskDrive
The Primary key for server table is server_id which is also a foreign key in diskDrive table.
There is no primary key set in the diskDrive table.
I am able to insert all of the basic data in the server table no problem.
What I need help creating/understanding is how to account for the servers with multiple drives.
Here is my command for accounting for all drive information:
$diskDrive = gwmi -query "select * from Win32_Volume where DriveType='3' AND DriveLetter IS NOT NULL" | Select @{Name="Device";Expression={$_.DriveLetter}},`
@{Name="Capacity";Expression={[math]::round(($($_.Capacity)/1GB),2)}},`
@{Name="FreeSpace";Expression={[math]::round(($($_.FreeSpace)/1GB),2)}},`
@{Name="UsedSpace";Expression={[math]::round((($_.Capacity - $_.FreeSpace)/1GB),2)}},`
@{Name="PercentFree";Expression={[math]::round(($($_.FreeSpace)/$($_.Capacity)*100),2)}}
My thought is to create an exist statement to determine if I need to insert or update the Database:
$ServerExist = "Select server_id from server where server_name = '$ServerInfo.csname'"
if ($ServerExist) {
update statement
} else {
#Create SQL Insert Statement with your values
$insert_stmt = "INSERT INTO Server(server_name, domain_name, Manufacturer, Model, Memory)
VALUES ('$($Output.Name)','$($Output.Domain)','$($Output.Manufacturer)','$($Output.Model)','$($Output.TotalPhysicalMemory)')" -replace "\s+"," "
$cmd.CommandText = $insert_stmt
## Invoke the Insert statement
$cmd.ExecuteNonQuery()
I have tested the insert statement and that works fine. However I have not implemented the $diskDrive aspect of the insert.
Although there will be a slight difference between the insert and update statement for the diskDrive table, still need to work out the iteration aspect for sql statement.
Items that will need to be inserted/updated per drive:
Server_id
DriverLetter
Capacity
FreeSpace
UsedSpace
PercentFree
Given my $diskDrive query, I think there needs to be While($diskDrive) statement that will iterate through the drive info and then insert/update until While is finished.
However I’m not sure how that is accomplished and hoping to get some help.
Please let me know if any other information is needed.
Thanks,
Jr. AdminHello jrv,
The problem is my limited experience in powershell and how to iterate through the $diskDrive variable and pull the specific drive information including the server_id and inserting or updating the diskDrive table accordingly.
I was able to figure out how to do the insert for one specific wmi entry but in regards to the disk drive, i'm not sure how to work the scripting to run through each drive, insert/update and continue until all drives have been accounted for.
Please let me know if you need any other information. I will consider posting later on SQL forum.
Thanks,
Jr. Admin -
Help needed in SQL performance - Using CASE in SQL statement versus 2 query
Hi,
I have a requirement to find count from a bunch of tables.
The SQL I have gives the count of all members.
I have created 2 queries to find count of active and inactive members.
The key difference is only the active dates.
Each query takes 20 seconds to execute.
I modified the SQL to use CASE statement in the SELECT.
So after the data is fetched the CASE statement will evaluate the active date and gives 2 counts (active and inactive)
Is it advisable to use this approach. Will CASE improve SQL performance ? I have to justify this.
Please let me know your thoughts.
Thanks,
JHi,
If it can be done in single SQL do it in single SQL.
You said:
Will CASE improve SQL performance There can be both cases to prove if the performance is better or worse.
In your case you should tell us how it is.
Regards,
Bhushan -
Hiding SQL statement in Query Result Window
Hi everyone,
Is it possible to hide the SQL statement from a query result window? This can usually be done by click the orange triangle that is positioned to the left of the SQL string box (to expand and collapse it). The System Queries have this box collapsed per default, is it possible to have this setup as default for all queries, including the custom? If so, please let me know where this can be done.
CheersYou should do this only with SDK programming - dont allow to show the syntax. The next, but problematic way, is the code you have do inside stored procedure and call only this sp inside the query generator window - if you have there some input parameters, you should use filling variables before executing sp and get it as input parameters to sp.
-
Execute Stored Procedure SQL Statement with Parameter from Cell
I would like to know if there is a way to pass the parameters to SQL Statement of Power Query. For example, I have a SQL Statement as follows:
EXEC [dbo].[spReportBuilder]
@Report = N'Revenue Summary',
@Year = N'2014',
@Period = N'11'
I would like to know if it is possible to pass the @Report, @Year, @Period values from cells in the workbook, preferably without vba.
Thanksrtisserand,
Here is the M code:
let
IDValue = Excel.CurrentWorkbook(){[Name="YearTable"]}[Content],
Source = Sql.Database("localhost", "AdventureWorks2012", [Query="EXEC [dbo].[spReportBuilder] @Report = N'Revenue Summary', @Year = N'" & Number.ToText(IDValue[ID]{0}) & "', @Period = N'11'"])
in
Source
Some notes:
You have to reference the excel query from another step in the query or you will get the following error:
Formula.Firewall: Query <>something<> references other queries or steps and so may not directly access a data source. Please rebuild this data combination.
I only did the parameter for one value.
Hope this helps.
Reeves
Denver, CO -
JDBC Sender update SQL Statement Question.
I was wondering if there is a way to have the update SQL statement line in the JDBC sender update by time stamp, this would be very helpful. Does anyone know a method of doing this?
In the SAP documentation of the adapter it has this example for using the update SQL statement after the query statement:
SQL statement for query: SELECT * FROM table WHERE processed = 0;
SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
What I want is to be able to put processed = (the current date) instead of processed =1 in the update statement, like this example:
SQL statement for query: SELECT * FROM table WHERE processed = 0;
SQL statement for update: UPDATE table SET processed = (the current date) WHERE processed = ' ';
I seems like you can only use a fixed value for the update statements in the JDBC Sender though, I would like to know if you can use a time stamp or variable there. -
SQL Statement in Webi 3.x and Webi 4.x
Hello experts,
I am facing with a problem regarding an SQL Statement written in Query Panel as a Custom SQL. The bellow statement is executed in Webi 3.x but not in Webi 4.x.. Webi 4.x does not recognize the statement from line 4 (SELECT within a SELECT), but in Webi 3.x everything is OK.
Have you faced with a similar problem ?
Thank's a lot for your answers.
1 SELECT
2 a.doc_id,
3 a.doc_type,
4 (SELECT b.doc_date FROM test b WHERE b.doc_type = 'I' and b.doc_id = a.doc_ref_id)
5 FROM
6 test a
7 WHERE
8 a.doc_type = 'F'Thank you very much for your answer. Very very interesting these links. I will read because I am very curious to find out the answer.
In the meanwhile, I solved the problem in the following manner:
SELECT
a.doc_id,
a.doc_type,
b.doc_date
FROM
test a,
(SELECT * FROM test WHERE doc_type = 'I') b
WHERE
a.doc_ref_id = b.doc_id and a.doc_type = 'F'
All the best,
Marius -
Need help for the sql statement !!!!!
hi all,
i need a sql statement for a query, how can i get the result from the rownum between 100 and 150?
plz helpuse a scrollable statement:
PreparedStatement stat = Connection.prepareStement("select * from blah", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stat.executeQuery();
rs.absolute(100);
while (rs.next()) {
String something = rs.get(1);
Look into the JDK API reference for ResultSet to get an expalantion of scrollable statements. -
The number of reloads for the SQL statements
Hi,
in 10g R2, how to see the number of reloads for the SQL statements ? Any query ? Which value is high ? Which valu is low ?
Thanks.thanks all.
It was a test question for 1Z0-042 exam as follows :
The users on your SALESDB are complaining of slow response to their queries. Using the SQL Tuning Advisor, you determine
that the SQL statements are using the best optimization plan. Querying the dynamic views, you see that the number of reloads
for the SQL statements is high, which can cause performance degradation.
Which component of the SGA should you resize to reduce the number of reloads of the SQL statements?
Answer :
shared poolThen I wonder how to see the number of reloads for the SQL ?
Maybe you are looking for
-
Also got posted in '10.3 or earlier' community, where other posts are regarding this issue ... I get "digital signature on the update is missing or invalid" trying to install 10.6.8 combo on MacBook currently using 10.6.3. Have used Disk Utility, Re
-
in old firefox (3.6) when clicking the right click on a link , the " open link in new tab" was the second option. but now in the new firefox (4.0) it is the first option. is there is a way to make it the second option because this annoying me a lot .
-
Re: Error by installation of Windows 7 64bit on Satellite A200 1AS
Hello, I get an error by installing Win 7 on my Satellite A200 1AS: Status: 0xc000035a Info: Attempting to load a 64-bit application, however this CPU is not compatible with 64-bit mode But by searching on Toshiba Webpages for compatibility of Win7 o
-
In order to accept a single character from the keyboard System.in.read() is used. However what do you use if you want to accept a String. e.g To accept one character I would say char n = (char)System.in.read(); How then can I accept a String?
-
Hi. I'm having an earphone problem with my C6-01 since Belle update. The phone doesn't recognise them and there is not even a message about that. I've been searching for a long time, I know there already exist a lot of discussions but none of them h