Convert SQL to take advantage of the Bind Variables

Hi all

Is it possible to convert the SQL below so I can enjoy variable Bind?  It's just my personal way of followed by the name of the script that I use on a daily basis... the file is passed to a point that its about 2K lines long, and whenever I run this specific file to get a script name, it creates a new SQL in the database pool shared... I tried to change this option to use bind variables , but it doesn't seem to work properly and I wanted what suggestion of the community...

ACCEPT script_name_like prompt 'ENTER SCRIPT NAME OR HIT ENTER TO GET ALL SCRIPT NAME OR PUT PART OF THE SCRIPT NAME : ' 
WITH help_script AS
( SELECT 'top_seg_tab_obj_ash'                    AS Script_Name,
                    'top segment by tot wait time' AS Description,
                    '# of mins to go back'            AS INPUT
   FROM dual  
  UNION ALL SELECT 'v$_tab'                    AS Script_Name,
                    'shows list v$ views' AS Description,
                    'view name like'            AS INPUT
   FROM dual
  UNION ALL SELECT 'dba_tab'                    AS Script_Name,
                    'shows list dba views' AS Description,
                    'view name like'            AS INPUT
   FROM dual
  UNION ALL SELECT 'nls_params'                    AS Script_Name,
                    'shows list of current NLS setting for DB/INST/SESS' AS Description,
                    'no Input Needed'            AS INPUT )
SELECT upper(script_name) AS "MY SCRIPT NAME",
       upper(description) AS description,
       upper(INPUT) AS INPUT
FROM help_script
WHERE script_name LIKE nvl('%&script_name_like%', script_name) ;

Hello

user13454469 wrote:

Hi all

Is it possible to convert the SQL below so I can enjoy variable Bind?  It's just my personal way of followed by the name of the script that I use on a daily basis... the file is passed to a point that its about 2K lines long, and whenever I run this specific file to get a script name, it creates a new SQL in the database pool shared... I tried to change this option to use bind variables , but it doesn't seem to work properly and I wanted what suggestion of the community...

  1. ACCEPT script_name_like invites ' ENTER NAME or HIT ENTER to GET ALL THE SCRIPT NAME or PART OF THE SCRIPT the SCRIPT NAME: '
  2. WITH help_script AS
  3. (SELECT "top_seg_tab_obj_ash" AS Script_Name,
  4. "upper segment by tot queue time" AS Description,.
  5. "# of minutes to go back" AS INPUT
  6. OF the double
  7. UNION ALL SELECT ' v$ _tab "AS Script_Name,.
  8. "Show list views$ v ' AS Description,.
  9. 'show the name as' AS ENTRY
  10. OF the double
  11. UNION ALL SELECT 'dba_tab' AS Script_Name,
  12. "Show list views dba" AS Description,.
  13. 'show the name as' AS ENTRY
  14. OF the double
  15. UNION ALL SELECT 'nls_params' AS Script_Name,
  16. 'displays the list of current NLS parameter for DB/INST/SESS' AS Description,.
  17. ("No input is necessary" IN ENTRY)
  18. SELECT upper (script_name) AS "MY SCRIPT NAME",
  19. Upper (Description) as a description,
  20. Upper (Input) AS INPUT
  21. OF help_script
  22. WHERE script_name AS nvl (script_name ' % & script_name_like %',);)

The WHERE clause (last line) of is the only place where you are using the proxy & script_name_like?  If so:

-ACCEPT command is exactly the same as before

ACCEPT script_name_like invites ' ENTER NAME or HIT ENTER to GET ALL THE SCRIPT NAME or PART OF THE SCRIPT the SCRIPT NAME: '

VARIABLE script_name_like_b VARCHAR2 (30)

EXEC: script_name_like_b: = '% & script_name_like;

WITH the help _script AS

...

WHERE script_name AS NVL (: script_name_like_b, script_name);

Tags: Database

Similar Questions

  • I tried to take advantage of the XBox Live 2 months for $2, but he says that my account is blocked.

    my account is blocked

    I tried to take advantage of the XBox Live 2 months for $2, but he says that my account is blocked.  I followed the instructions and asked for the code to be sent to my other account that several times, but I have not received.  I talked to a CSR and the reference number was 1178333571.  I have my account unlocked and to a subscription xbox live gold.

    respectfully,.

    Isidoro

    Hi isidorolaude,

    For help on XBOX, go on the Forums of Xbox Live.

  • I previously registered for upgrade offer and received the coupon code but has failed can I take advantage of the offer now

    I previously registered for upgrade offer and received the coupon code but has failed can I take advantage of the offer now

    If you don't have the product key, then sorry, too late, you can simply buy it now.

    http://www.Windows.com/buy

  • Camera raw Adobe gives me 8-bit and 16-bit option for files to open, but my camera works with 14 bit (canon 6 d), what to do? If I get 8-bit option I don't take advantage of the 14 bits on the other hand if I leave for 16-bit and like m

    Camera raw Adobe gives me 8-bit and 16-bit option for files to open, but my camera works with 14 bit (canon 6 d), what to do? If I get 8-bit option that I don't take advantage of the 14 bits on the other hand if I go for the option of 16 bits (as says that my files are 14) what's happening?

    Photoshop will work with the 14bpc data in the raw file, don't worry about this. The options that you mention "workflow" and apply to the final rendered file opened in Photoshop (bit depth, color profile, pixel dimensions and the value of the PPI). "16bpc" of Photoshop (15 + 1) is the only option if you need more output 8bpc ACR.

  • I'm a new student in my second semester. How can I take advantage of the student price?

    When I installed everything first Creative Cloud I wasn't a student, so I had to pay full price. Recently, I am majoring in graphic design at my local community college and would like to take advantage of the student discount. How can I switch to student price so I can get all the desktop applications that I need?

    Hello

    Please contact Adobe customer support. Make sure you have a certificate of validation that you're a student. They can ask to send it.

    Contact the customer service

  • Hello!  I want to take advantage of the Black Friday for student agreement. However, I already have a plan that ends in a few months. Can I cancel this plan and then use the agreement of Black Friday? Thank you!

    Hello!  I want to take advantage of the Black Friday for student agreement. However, I already have a plan that ends in a few months. Can I cancel this plan and then use the agreement of Black Friday? Thank you!

    Hello

    You will need to speak with sales of Adobe for the same thing.

    Contact us | Adobe

    Kind regards

    Sheena

  • If Im pretty well shut down all my freelance work now that my job is very time consuming so I need is no longer the creative suite on my laptop, but my wife who is a teacher, he needs. We want to take advantage of the lower prices for teachers and studen

    If Im pretty well shut down all my freelance work now that my job is very time consuming so I need is no longer the creative suite on my laptop, but my wife who is a teacher, he needs. We want to take advantage of the lower prices for students and teachers are so I remove all and close my account and start a new account etc. under my married name?

    Hi Jason,

    You can contact Adobe sales.

    Contact us | Adobe

    It could be useful!

    Rayyan

  • PS and LR no Serviço more every time I get on a screen that me says log in, what I do, then the window ^ next tre says said: CCP is now under licennce...@yahoo.fr. Continue to take advantage of the software. I continue to click on and (drum roll)

    PS and LR no Serviço more every time I get on a screen that me says log in, what I do, then the window ^ next tre says said: CCP is now under [email protected]. Continue to take advantage of the software. I continue to click on and (drum roll) it sends me on the screen asking me to connect. PFFFF... qqun have a solution? Thank you. I already spent on the site in English. I got a response, but none of the normal staff works. Since they are absent. They might have more consideration pour those who are their subscription 50% more expensive Saitor USA. The European competition commission should look at the problem. Some North American cmpagnies were fined not sad. That it was my rant. But hey it of still 5 days and there are with that work.

    Hello

    Please see Re: loop "Sign in required" and https://forums.adobe.com/thread/1094836

    Hope that helps!

    Kind regards

    Sheena

  • LR6 can take advantage of the graphics card more advanced in the new iMac 5K (end of 2015)? [AMD Radeon M395X with video memory 4 GB dedicated GDDR5 R9]

    Considering the upgrade to a new iMac 5K. LR6 would be able to take advantage of the advanced graphics card? I do not play video games, and currently do not edit 4K video.

    Hi jonathanl,

    Please click the link for information on using GPUS in Lightroom CC or Lightroom 6 below

    Notes for Lightroom CC GPU (2015)

    I hope this helps.

    ~ UL

  • I would like to take advantage of the special CreativeCloud of prices that ends today 8/28, but my new computer will not happen for a few days. What is the path of least resistance?

    I would like to take advantage of the special CreativeCloud of prices that ends today 8/28, but my new computer will not happen for a few days. What is the path of least resistance?

    Just a random adobe employee, but it is probably best to sign up today for the service and then just wait for happen to install and download the software from the computer.  Trying to get the discount retroactively applied sounds quite a bit more difficult, and you can set the account from any computer without installing anything.

  • Hello, I would like to take advantage of the promotions on Adobe Photoshop for a single user (valid until tomorrow), but I have two questions.  First of all, I intend to buy a new computer for a month and for the moment, I don't know if it will be

    Hello, I would like to take advantage of the promotions on Adobe Photoshop for a single user (valid until tomorrow), but I have two questions.  First of all, I intend to buy a new computer for a month and for the moment, I don't know if it will be a pc or a mac. Do I have to decide at the time of the purchase, what system I'll use?  Secondly, I also have a plan for about a month to open an individual company. If I buy the program as a person, could I then use it as a business?

    Creative cloud is cross-platform. Licensing is not serious. By definition, an "enterprise" might as well be a single person. It is totally irrelevant, as long as you purchase a full license appropriate regardless of any promotion.

    Mylenium

  • I am currently creative Member Cloud using the Plan of photography (paid annually).  I would like to take advantage of the upgrade promotion to the full level for $29.99.  Can I take advantage of the promo before it expires may 29?

    I am currently creative Member Cloud using the Plan of photography (paid annually).  I would like to take advantage of the upgrade promotion to the full level for $29.99.  Can I take advantage of the promo before it expires may 29?

    Contact Adobe Support by chat or phone to see what can be done...

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html ( http://adobe.ly/19llvMN )

    Phone support | Orders, returns, exchanges

    http://helpx.Adobe.com/x-productkb/global/phone-support-orders.html

  • We currently have a membership HERE until August 2014 and ID subscription until December 2014. I wish now to subscribe to the complete creative cloud and take advantage of the offer of $29.99 / month.  I understand that full creative cloud would replace t

    We currently have a membership HERE until August 2014 and ID subscription until December 2014. now, I want to subscribe to full creative cloud and take advantage of the offer of the month $29.99. I understand that full creative cloud would replace the unique demands. How many simultaneous connections are possible?

    An identification code Adobe supports two activation of CC regardless of the type (single/fill/Team). If you buy the full CC with the same Adobe ID, it will activate twice if you you will be assigned space app unique cc + the full CC.

    You can buy the full CC with a different Adobe ID.

    Concerning

    Baudier

  • Get the bind variables name string SQL or the cursor

    Hello

    Is there way to get of the bind variables name string SQL or the cursor?

    Example of
    DECLARE
      l_sql VARCHAR2(2000);
      desctab DBMS_SQL.DESC_TAB;
      curid   PLS_INTEGER;
    BEGIN
    
      l_sql := 'SELECT * FROM emp WHERE mgr = :X and deptno = :Y';
    
      curid := dbms_sql.open_cursor;
      dbms_sql.parse(curid, l_sql, dbms_sql.NATIVE);
      ....
    END;
    What I mean with the SQL string:
    I love to get using some functions from above code variable l_sql all the bind variable.
    In this case the function should return array where is for example: X and: Y

    Back to bind the cursor variable names, I mean same but rather string I pass number of cursor.

    Y at - it sucks ready function or some may share a code customized for this purpose?

    Thanks

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0Regards,

    Published by: jarola December 19, 2011 02:44

    I found there are wwv_flow_utilities.get_binds of the function not documented in APEX packages that do what I want.
    Usage example
    set serveroutput on
    DECLARE
      binds DBMS_SQL.varchar2_table;
    BEGIN
      binds := wwv_flow_utilities.get_binds('select :P1_TEST from dual');
      FOR i IN 1 .. binds.count
      LOOP
        dbms_output.put_line(binds(i));
      END LOOP;
    END;
    /
    
    anonymous block completed
    :P1_TEST
    But I would not use these functions without papers as those who can change or there is no future versions APEX.
    Is there a documented function or the custom function that do the same thing as wwv_flow_utilities.get_binds?

    Some old basic example code of my friends. Also the media getting the bind variable of PL/SQL code blocks anon.

    SQL> create or replace function GetBindVariables( statement varchar2 ) return TStrings is
      2          --// bind variables names are terminated by one the following special chars
      3          SPECIAL_CHAR    constant TStrings := TStrings(' ',')','+','-','>','<','*',',','=',';',CHR(10),CHR(13));
      4
      5          --// max size of a bind var name
      6          MAX_VARSIZE     constant integer := 100;
      7
      8          pos     integer;
      9          pos1    integer;
     10          occur   integer;
     11          varName varchar2(100);
     12          varList TStrings;
     13  begin
     14          varList := new TStrings();
     15
     16          --// looking for the 1st occurance of a bind variable
     17          occur := 1;
     18
     19          loop
     20                  pos := InStr( statement, ':', 1, occur );
     21                  exit when pos = 0;
     22
     23                  varName := SubStr( statement, pos, 100 );
     24
     25                  --// find the terminating char trailing the
     26                  --// bind variable name
     27                  pos1 := Length( varName );
     28                  for i in 1..SPECIAL_CHAR.Count
     29                  loop
     30                          pos := InStr( varName, SPECIAL_CHAR(i) ) - 1;
     31                          if (pos > 0) and (pos < pos1) then
     32                                  pos1 := pos;
     33                          end if;
     34                  end loop;
     35
     36                  --// extract the actual bind var name (without
     37                  --// colon char prefix)
     38                  varName := SubStr( varName, 2, pos1-1 );
     39
     40                  --// maintain a unique list of var names
     41                  if not varName member of varList then
     42                          varList.Extend(1);
     43                          varList( varList.Count ) := varName;
     44                  end if;
     45
     46                  --// look for the next occurance
     47                  occur := occur + 1;
     48          end loop;
     49
     50          return( varList );
     51  end;
     52  /
    
    Function created.
    
    SQL>
    SQL> select
      2          column_value as BIND_VAR
      3  from TABLE(
      4          GetBindVariables('select * from foo where col=:BIND1 and day = to_date(:B2,''yyyy/mm/dd'')')
      5  );
    
    BIND_VAR
    ------------------------------
    BIND1
    B2
    
    SQL> 
    

    PS. just realize this code is case-sensitive, while variable bind is not. Should throw a upper() or lower() by adding the name of the var to the list - never really a problem for me because I'm pretty tense when it use cases correctly in the code. ;-)

    Published by: Billy Verreynne, December 19, 2011 06:19

  • Procedure with an unknown name or the amounts of the bind variable.

    Hey gurus,

    I hope someone out there can point me in the right direction.

    I write a PL/SQL function that receives an unknown number of bind variables in the client.
    I use Apex 1.1 earpiece to set up a model of RESTful resource for a x-www-formulaires-urlencoded body POSITION.

    If the client publishes the following body: * "title = M. & fname = John & lname = Smith" * "

    My PL/SQL procedure automatically receives the bind variables which is placed by the following:
    : title: = "M";
    : fname: = "John";
    : lname: = 'Smith ';.

    Now my limit is that the required design uses the metadata to define the structure of data of the end-user.
    So in reality the body of MESSAGE I get more like this: * "M. = 120 & 121 = John & 122 = Smith" * "

    So my PL/SQL procedure receives:
    : 120: = "M";
    : 121: = "John";
    : 122: = 'Smith ';.

    I can query the metadata tables to anticipate what bind variables can be present at the execution,
    but this can change depending on the resource ID with the body of the MESSAGE at the time of the request.

    My first attempt was to be a loop expected elements and run an EXECUTE IMMEDIATE likes:

    for c_record_items in
    (select field_id in the tfields where record_id =: id) loop
    EXECUTE IMMEDIATE ' begin update_item ('|: field_id |', :'|| field_id |'); end;';
    end loop;

    But unfortunately the EXECUTE IMMEDIATE fails because the binding variable is not declared; It requires the USING clause.
    Which I can't think I can code the amount or value in...

    I started dabbling in the DBMS_SQL package but I still have to think of a way I can fix this problem.

    There are experts out there who can direct me in the right direction?
    Very much appreciated.

    Published by: Codes on March 5, 2013 17:11

    Published by: Codes on March 5, 2013 17:13

    I have a lot of procedures where I accumulate the number of bind variables.

    My approach has been to load each variable binding in an associative array and maintain a counter of the number of bind variables.

    Finally, there is a great if then elsif endif block which is actually

    if v_binds = 0
    then
         execute immediate ;
    elsif v_binds = 1
    then
         execute immediate  using bind_array(1);
    elsif v_binds = 2
         execute immediate  using bind_array(1), bind_array(2);
    elsif ...
    end if;
    

    Here is a link:
    Re: USING Dynamic Clause?

    Later, I discovered that you could do something like the following:
    (Asktom)
    http://www.Oracle.com/technetwork/issue-archive/2009/09-Jul/o49asktom-090487.html

    Either of these approaches to solve your problem.

    Added link: Keith Jamieson on 6 March 2013 09:26

Maybe you are looking for