Queries Script

Dear Experts,
Now i want to know that in queries Manager or Generator can use function as below :
If condition then
statements
elseif condition then
statements
endif
when i test my code or script
if $[$38.18.0]='P07' then
SELECT $[$38.21.NUMBER] / 1.07
end if
it can do. but i have problem on condition, i selected "X1" it still do it .
if u don't understandard, pls let me knonw i  will explain u more...
thanks for ur help
sivhour.
Edited by: Prasan Pongsila on Feb 23, 2010 6:59 AM
Edited by: Prasan Pongsila on Feb 23, 2010 7:02 AM

Thanks..,
I have tried to check and test with Query Code in SAPB1 for a long time . but it still can not do..
What i want is,
-- have to use 2 condition..
1 condition i have one combo box (Exclude & Include).
If i select "Include", i will work with condition 2 i have one combo box  ('P07' ,'P07S' ,'P00' ,'X1' ).
my purpose is, i select "Include" --> it will go to condition 2 --> i select "P07" -> i will calculate my total.
Below is my test code:
' it can work.
SELECT CASE rtrim($[$38.18.0])
WHEN 'P07' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
WHEN 'P07S' THEN  (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.02)
WHEN 'P00' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]))
WHEN 'X1' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]))
END
SELECT CASE rtrim($[$38.U_Choose.0])
WHEN 'Exclude' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) )
WHEN 'Include' THEN   (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
END'
' it can not work
IF rtrim($[$38.18.0])='P07'
BEGIN
  (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]/1.07))
END
ELSE
   IF rtrim($[$38.18.0])='P07S'
BEGIN
(SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]/1.02))
END
SELECT CASE rtrim($[$38.U_Choose.0])
WHEN 'Exclude' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) )
WHEN 'Include' THEN 
SELECT CASE rtrim($[$38.18.0])
WHEN 'P07' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
WHEN 'P07S' THEN  (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
WHEN 'P00' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]))
END
END
IF rtrim($[$38.U_Choose.0]) = 'Include VAT'
Begin
SELECT CASE rtrim($[$38.18.0])
WHEN 'P07' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
WHEN 'P07S' THEN  (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]) / 1.07)
WHEN 'P00' THEN    (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]))
END
ELSE
     IF rtrim($[$38.U_Choose.0]) = 'Exclude VAT'
     BEGIN
                 (SELECT ($[$38.11.NUMBER] * $[$38.14.NUMBER]))
     END
END
i still can not use "IF Function".. pls show a way for me.
Thanks for ur help ,
Regards,
Sivhour.

Similar Messages

  • Paralell queries/scripts

    I have 2 SQL Worksheets open on one db (it uses only one session). So there is clear problem to come - I start long time running script in one window (e.g. some testing reports generator) and when I try to post some simple sql statement from the 2nd window (to get report progress) iraptor "freezes" until the script finish.
    Is there any workaround to force new session? it should warn user to prevent these "locks"...

    Yeah, this would be great to have the ability to have multiple sessions open or running two queries at once. The frustration I always have is having a table open and running a long SQL in a worksheet. If I click back to the table and accidently do something that will refresh the data or click a tab to see indexes I get frozen until the long query finishes since I have no way of stopping that second SQL from running and I can't change to the SQL worksheet to kill the long running SQL. It's something I can work around, but is frustrating at times.

  • Right way to preserve all parent table entries in a join with many tables!!

    This problem is quite interesting to me. I have asked this question to others but no body is able to provide me with proper answers.
    The problem is: How do I join a huge parent table with many child tables (more than 5 child tables) preserving all of the parent table entries. Lets say there is the parent table parentTable and three child tables childTable1, childTable2, childTable3. In order to get the data after joining these tables the query that I have been using was:
    select parent.field1, parent.field2, parent.field3, child1.field4, child1.field5, child2.field6, child3.field7 from ParentTable parent, childTable1 child1, childTable1 child2, childTable3 child3 where parent.fielda = child1.fieldb and parent.fieldc = child.fieldd and parent.fielde = child.fieldf.
    Although the tables are huge (more than 100,000 entries), this query is very fast, however those parent table entries which do not have child entries are lost. I know that I can left join a parent table with a child table and then with the next child table and then with the next child table and continue. Isn't there a simple solution for this commonly happening problem?
    Please provide suggestions please...

    Hello Lakshmi,
    Although I do not know exactly how to achieve what you want to achieve but I have seen DBAs/ABAPers in my experience can run queries/scripts using the COUNT function to give the actual number of line items per table for all your 100 or odd tables.
    Rgds
    CONMJI

  • How many Management agents can you have running simultaneously on a host?

    Hi all,
    I've scoured the Oracle documentation and not been able to find a definitive answer to this question, how many Oracle management agents can you have on a single managed host target? Can you for example run an 11g agent and a 12c agent simultaneously (whilst migrating to 12c without upgrading the present OEM instance) If so can you run two 12c agents, each pointing to a different OMS? I’ve seen examples of an agent for each database instance on a host managed target, so a host with three Oracle database instances has three Oracle Management agents all pointing to the same OMS with each agent is monitoring just one of the database instances. There must be resource considerations here for memory, cpu and network traffic etc? I’ve always understood it to be one Oracle Management Agent per managed host
    Thanks

    I don't think there's any data on impact or performance since it's not a recommended configuration. If you have host/configuration monitoring enabled on both agents, they will be running the same queries/scripts against the host/inventory, etc. so they will likely have contention at some point. If you monitor the same databases, you will definitely see contention and increased overhead as there will be multiple agents running the same queries. You might also see problems w/ any of the server generated alerts (tablespace, etc) if you change thresholds as the agents send that to the database, and then the database will be out of sync with the other agents.
    What exactly is the goal for having multiple agents? Is it short term or long term?

  • Dynamic SQL in table vauled function or CLR

    So I have a query that gives me some analysis on the values in a column, in a table.  It reurns a small data set.
    It gives me the max, min, stdev, avg and some other stats grouped by another column.
    I wanted to create a table valued function from the query, so I could do the same analysis on any numeric column, in any table.  I would just pass in the column name and the table name as paramters to my table-valued function and it would return the
    data set.  Then I could join to it and use in other queries.
    I thought I would build my query using dynamic SQL and execute it within the function, but I got an error and learn that you can not use execute in a function.
    I have never created a CLR function, would this be possible to do it this way?  This would be a decent sized step for me, but am willing to learn if possible.  Or does anyone know how to solve this problem?
    Problem: Pass column name and table name into function and have it reurn a dataset.  Use the dataset as a table in other queries, scripts or procedures like a table valued function.
    Thanks,
    Mike

    Milke
    Take a look into READ only table variable parameter
    Create a user-defined data type with a single column.
    Develop a procedure with a table variable as an input parameter.
    Declare a table variable of the type of the user defined data type.
    Loading 10 records into the table variable and pass the table 
    variable to the stored procedure.
    create type tt_example AS TABLE
     (spid int)
    go
    create procedure usp_example
     @spids tt_example READONLY
    AS
     SELECT *
     FROM @spids
    GO
    declare @spids tt_example
    insert into @spids
    select top 10 spid
    from sys.sysprocesses
    exec usp_example @spids=@spids
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How HANA handle NULL values

    Hi frzz,
    Can any one explain me how exactly HANA handles NULL values??
    Best Regards,
    Krishna.

    Hi Krishna,
    You can use IFNULL for the SQL queries/script instead of ISNULL . Since ISNULL is binary function and will be mostly used for the CE Functions based Calc views.
    Try using the same queries with IFNULL instead of ISNULL, it should work
    Best Regards
    Rahul Jha

  • To get performance through Oracle Grid.

    I recently installed Oracle 10 g Grid and evaluating the performance of my Oracle Servers. Is it possible to integrate database monitoring scripts/queries developed by us into the Grid manager. I wanted to reduce the manual effort of executing individual queries/scripts by logging on the servers. If so Can someone help me how do I achieve this .Please help!!!!
    Thanks in advance

    From Grid just create a job for this and schedule as per your need

  • Dynamic Update Queries - SQL Script

    Hi All,
    I have a table Account_info where columns are ACCT_NO and flag with other information (columns). We are receving a file which contains ACCT_NO and FLAG. Now i need to compare ACCT_NO for Table and file and based on it need to update FLAG column in table.
    To automate this process, i can develop a shell script, which load data from file to temp table and then update statement to update Account_info table. For batch process, i can write a for loop, which commit data after every 10,000 update.
    but client does not want this way. We have to send file to Production team, where they will load data manually into temp table.
    Once done, i have to write a update statement which will take 10000 records to update on every run and then commit it, so there will not be space/memory issue.
    For example, if table has 50,000 records, i have to create 5 update statement. and then i have to send all 5 queries as sql script and send it to Production support.
    It is difficult for me to do it daily.
    Is there any other way, where SQL script is dynamic and based on number of rows/10000 , it create UPDATE statement and run it daily.
    Regards,
    ACE

    ace_friends22 wrote:
    Hi All,
    I have a table Account_info where columns are ACCT_NO and flag with other information (columns). We are receving a file which contains ACCT_NO and FLAG. Now i need to compare ACCT_NO for Table and file and based on it need to update FLAG column in table.
    To automate this process, i can develop a shell script, which load data from file to temp table and then update statement to update Account_info table. For batch process, i can write a for loop, which commit data after every 10,000 update.Why not simply use an external table pointing at the file and use a single update statement? If you write a loop with intermittent commits, this is one of the worst known ways of processing data.
    but client does not want this way.And the client knows how to technically implement a solution then? Why aren't they doing it themselves then?
    We have to send file to Production team, where they will load data manually into temp table.Unnecessary. Use an External table
    Once done, i have to write a update statement which will take 10000 records to update on every run and then commit it, so there will not be space/memory issue.Oracle is an enterprise level database engine capable of processing millions of rows without space/memory issues. If you've encountered shuch an issue you should be trying to identify the cause of it rather than suppress the symptoms.
    For example, if table has 50,000 records, i have to create 5 update statement. and then i have to send all 5 queries as sql script and send it to Production support.Bad Idea ^tm^

  • Changing many queries with a "script"

    A SAP-BI newbee here. I would like to add a characteristic to a cube and have all existing queries filter on this characteristic. Is there a way to create some sort of script to update all queries and automatically insert this filter so that the users don't need to manually touch each query?

    Hi Robert,
    You can find some sample code and tables here:
    Re: Query-InfoObject - Tables
    I think there are some more threads out here that have programs modifying the RSZ* tables.
    Hope this helps...

  • Script for running multiple find/change queries

    Working on a large ID book document (*.indb), I have saved several dozens of Find/Change Queries (named "col01", "col02" etc.) that I run on "All documents". For a particular reason I have to run these queries several times a day.
    So I was wondering whether there is, or whether anybody out there would write, a script that runs these queries one after the other. Given the size of the book, it might be necessary to provide for the script to pause after each query is run (before it goes on with the next), but I am just guessing.
    Any help is much appreciated!

    There are a couple of others:
    http://forums.adobe.com/message/5173943#5173943
    this is more at code level rather than a GUI, but the actual queries are made using the Find/Change dialog box.
    Also
    http://www.kahrel.plus.com/indesign/grep_query_manager.html
    This is good too, but only does GREP searches (no text, glyph or object find/replaces) that were written by the user - does not use the ones installed with InDesign. Does allow changes by selection, story, document or folder.
    Did try the Doquerylist suggested by Kasyan. This allows GREP/text changes by the user/installed with InDesign, but only applies to a selection or text-thread.
    Always good to have more than one way of accomplishing a task though!

  • Script to logout users from a specific group, when queries are long

    Hi,
    I have a requirement that users from a specific group need to be logged out, when they are running queries for more than say 20 mins.
    I could get the list of users from that group and could get the list of active sessions on the application, but I get too many info there like connection IP request state etc. and if I spool it to a file, output is not very easy to format to select what's required, rather I have to write lot of shell scripting to format the file.
    So my question here is to know if there's a MAXL script or any other method through which I can just get only couple of columns from the "display session on application <app name>" that I require for my work like username, session ID, DB connect time, and request time.
    Thanks!!

    There are a number of ways to accomplish this, but AFAIK none of them is straightforward like writing a script to accomplish the task.
    This could be accomplished quite readily with the Essbase API.
    Unfortunately, when Maxl outputs tabular data such as what comes out after DISPLAY SESSION ALL; - it comes out as all one big string with lots of spaces.
    So to parse that output you would need to use a language that can tokenize the text into a collection and parse that for the users.
    Then you need to do the same sort of thing after running DISPLAY USER IN GROUP ALL; (or instead of all, use a specific group name);
    Then run ALTER SYSTEM LOGOUT SESSION BY USER <parsed_username>;
    What would be ideal (hello Oracle... <wink> ) is a MAXL command ALTER SYSTEM LOGOUT SESSION BY GROUP <GroupName>;
    The way I would approach this would be to write a little utility that does exaclty what you seek:
    - Scan the current session periodically (say, once every 5 mins)
    - for each user that belongs to group(s) <group>(<group>...)
    - if user has an open query running longer than n minutes, kill the user request.
    This way you're not kicking people, your just taking back resources. Of course you can be more aggressive and code it to kick the user by forcefully ending (invalidating) his session too.
    I can give you a hand with this offline if you want.
    Robb

  • How exit for a script having set of pl/sql blocks and sql queries

    HI,
    I have set of blocks and sql queries in a script.
    In some cases I want to stop the excution of next statements and blocks.
    As in pl/sql block We can use return , in case of loop we can use exit, so what is to be use in case if sql script which contain set of blocks and sql queries.
    Thanks and Regards in Advance,

    Hi,
    how to exit from the script if confirm_to_continue is set to 'N'.
    i.e in this case I want the preceding statements not to be excuted.
    Please suggest.
    script:
    declare /*BLOCK NO1*/
    begin
    IF &&confirm_to_continue = 'N'
    THEN
    ---exit from from whole script
    RETURN; -- this will only exit from this block
    END IF;
    end;
    host IF EXIST &file_name (del &file_name) ELSE (echo missing)
    declare /*BLOCK NO 2*/
    begin
    end;
    /

  • Data Refesh does not support script only queries

    I created a Power Query transformation that does not contain any data source because it generates a fixed table (imagine a Date Table, with certain columns marked based on current day value). I receive this alert trying to create the data source:
    Discover data sources - You can only use a connection string that has SQL Server or Oracle data sources. Also, the data sources cannot include native queries. Tracing ID: 040eda49-bcf9-4c82-af1c-69f6efb26cd0 - ‎07‎.‎55‎.‎44
    The refresh fails with this error:
    Failure
    Correlation ID:
    10225488-17be-4256-b03e-be975b87a281
    OnPremise error: Sorry, we can't refresh connections to this kind of data source in Power Query yet.
    I am wondering whether I can workaround the check by creating a SQL Query that returns an empty table that will be ignored in a following join, but is that really necessary? Why not refreshing a transformation that doesn't access to any data source?
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

    I tried to workaround the issue using the script below. However, even if creating the Data Source in Data Management Gateway worked well, without raising any error, I had this error (script follows).
    Is the Table.Combine limited? Or what is the issue in this case?
    Thanks!
    Marco
    Scheduled start   time: 5/3/2014 1:58 PM
    Actual start time:   5/3/2014 2:31 PM
    Failure time:   5/3/2014 2:31 PM
    Status:
    Failure
      Correlation ID: 3abb39be-05df-40e5-8366-45bdf58ccdc3
    Data connections status:
    Power Query - DimProductCategory
    OnPremise error: Sorry, we can't refresh connections to this     kind of data source in Power Query yet.
    Report owner: Marco   Russo
    let
      Tab1 = #table( {"Number"}, { {1}, {2}, {3}, {4}, {5} } ),
      Source = Sql.Database("servername", "AdventureWorksDW2012"),
      dbo_DimProductCategory = Source{[Schema="dbo",Item="DimProductCategory"]}[Data],
      FilteredRows = Table.SelectRows(dbo_DimProductCategory, each [ProductCategoryKey] = 0),
      InsertedCustom = Table.AddColumn(FilteredRows, "Number", each 0),
      RemovedColumns = Table.RemoveColumns(InsertedCustom,{"ProductCategoryKey", "ProductCategoryAlternateKey", "EnglishProductCategoryName", "SpanishProductCategoryName", "FrenchProductCategoryName", "DimProductSubcategory"}),
      Append = Table.Combine({RemovedColumns,Tab1 })
    in
      Append
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • How to combine several regex queries into a script?

    Hi there,
    is it possible to combine several regex queries into a javascipt? I export the text from a database with custom tags and the regex queries perform text AND character style replacements.
    example
    Let's say my exported text is the following
    "I have a <tag_bold>very big text</tag_bold> that includes a lot of different character styles, such as <tag_bold>bold</tag_bold>, <tag_italic>italic</tag_italic>, <tag_bold>bold with some <tag_bold_underline>underlined words</tag_bold_underline></tag_bold>,
    or ever words with different <tag_size-2>text size</tag_size-2>"
    The result I want is
    "I have a very big text that includes a lot of different character styles, such as bold, italic,
    bold with some underlined words, or ever words with different text size"
    Notice that all the tags open and close in the same paragraph and that there are nested tag pairs in some cases. So i execute my queries (more than 20) from the outer pair to the inner, that is:
    <tag_bold>...</tag_bold>
    <tag_italic>...</tag_italic>
    <tag_size-2>...</tag_size-2>
    <tag_bold_underline>...</tag_bold_underline>
    Thanks in advance for your help
    dps

    Hi Shonky,
    thank you for your answer. It seems that it is very close to the solution.
    1) I see now that my question was not clear enough.
    In the text that is included between the tags, I want to apply a Character Style I have define in the character style palette of InDesign CS3.
    That style can contain a lot of options, such as font family, size, style or color changes and is different for each tag.
    2) I tested the function with my tags:
    function my_replace (tag_bold)
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = '<' + 'tag_bold' + '>' + '(.+?)</' + 'tag_bold' + '>';                     // here is the name i use in the regex tag
    app.changeGrepPreferences.changeTo = '$1';
    app.changeGrepPreferences.fontStyle = 'tag_bold';                                //here is the name of the Character Style I have define in InDesign
    app.activeDocument.changeGrep();
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences = NothingEnum.nothing;
    result: nothing happens
    3) Using in the script only the body of the function and running it, it highlights the right words with that pink color and shows that the Style of the text is "tag_bold", which is not available in the font family I use (Minion Pro).
    I think that the function needs a modification in the line "app.changeGrepPreferences.fontStyle = 'tag_bold';", especially the "fontStyle" attribute, but I don't know what it is. I'm not a javascript expert and maybe I don't know the right way to use this function with InDesign. I read some books about InDesign Scripting and Regular expressions, but  I didn't found all the answers I need as the one above or how I can run all the queries in one script (this is necessery because of the number and the order of scripts, to avoid mistakes).
    Thanks
    dps

  • How to change multi Find-Change Queries into a scripting

    I was wondering if possible transcribe multi Find-Change Queries into a scripting?
    If it is possible, can someone tell me how?

    1) Buy something and charge the rest to a credit card.
    2) Ask Apple to keep the balance.
    iTunes Customer Service Contact - http://www.apple.com/support/itunes/contact.html

Maybe you are looking for