Diff char in variable and procedure call

I understand the difference between Char en Varchar. What I don't understand is the different behaviour of Char when assigning a plain variable and when assigning a procedure call variable. I've created this sample code:
declare
  v char;
  procedure t (i char) as
  begin
    if i = ' ' then
      dbms_output.put_line('ok');
    else
      dbms_output.put_line('else');
    end if;
  end;
begin
  v := '';
  t('');
  t(' ');
  t(null);
  t(v);
end;
else
ok
else
ok
PL/SQL-procedure is geslaagd.The first (t('')) call and last (t(v)) call I think should result in the same answer, but apearantly, when v is assigned, a space is passed into the variable (sounds correct according to documentation), but when i is directly assigned, a null is assigned, rather than a space.
Does anyone know what the explanation is for this behaviour?
Thanx,
Lennert
ps, I'm not looking for a solution or a work around, I'm just interested in the background.
pps, I'm running O8174 on HPUX

x CHAR;
It's default length is one but if you don't assign a value, it's value is null and its length is null. The empty string ('') is not null, so the assignment x := '' will assign a value of space, since PL/SQL pads with spaces to fill the length.
PROCEDURE test is
x char;
BEGIN
dbms_output.put_line('x = >' || x || '< , the length of x is: ' || to_char(length(x)));
x := null;
dbms_output.put_line('x = >' || x || '< , the length of x is: ' || to_char(length(x)));
x := '';
dbms_output.put_line('x = >' || x || '< , the length of x is: ' || to_char(length(x)));
dbms_output.put_line(to_char(ascii(x)));
x := ' ';
dbms_output.put_line('x = >' || x || '< , the length of x is: ' || to_char(length(x)));
END test;
SQL> execute test.proc1
x = >< , the length of x is:
x = >< , the length of x is:
x = > < , the length of x is: 1
32
x = > < , the length of x is: 1

Similar Messages

  • Wrong ASCII values for control characters in Variables and Stack Call in CVI2013?

    Hi,
    I think there is an error in  "Variables and Call Stack" window if you want to look for your variables in ASCII format.
    The control characters (0 -  31) are not shown correct. They are shifted 2.
    For example:
    Character in Decimal format is 10 (LF) but when you are chancing to ASCII format it is showing \012.
    The same with 13 (CR). This character is \015 in ASCII format.
    I think that was no problem in CVI2012.
    Best regards
    Gunther
    Solved!
    Go to Solution.

    I'm not using CVI2013 yes so I cannot respond regarding this specific product, but the code you are showing are the octal equivalent of the decimal value you specified: it could be that control characters (or generally speacking non-printable ones) are replaced with their octal equivalent in string view.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Function and procedure call overhead in PL/SQL

    ( I come from a programming background - java/c++ etc and not much PL/SQL )
    Im trying to get a feel of how much extra cycles are spent if something is wrapped inside a function or procedure. I mean will it become considerably inefficient if the logic is within a function as opposed to be directly inline ?

    I did some timings a few years ago and found procedure calls to be slightly more efficient than function calls, presumably due to the fact that functions must pass values back through the function invocation and procedures don't. This may have changed in more recent releases but you can check it yourself.
    Set up a function and a procedure and use dbms_utility to get a starting and ending time marker (this will be the number of seconds from an arbitrary start point as microseconds; you will have to convert). Get a start time, loop through the calls a lot of times, get and end time, and subtract the end time from the start time.
    The prevailing though is that use functions to return values and procedures to perform actions. You can use functions in SQL if written correctly but not procedures.

  • Linking variable and procedure

    hi,
    how to assign a value to the odi variable which is returned by a sql statement which written in the source tab of odi procedure ?
    Regards,
    Sai.

    I've just done this.
    Im calling startscen.sh from ebiz via concurrant request, passing variables to the ODI procedure.
    Variables in this case are a mix of Alphanumeric and Int.
    reference variables in ODI Procedure using #variable_name.
    Drag variable to package, set to declare (dont use set!). Link to procedure. Cut scenario. Job done.
    We also have other variables with refresh SQL behind them (to get last ETL date for example) and simply use refresh variable on the package canvas, i've read good practice to declare them first in the package but from my testing this isnt strictly required.
    Hope this helps.
    Alastair

  • Variable and procedure

    hi,
    I am sure we can call a datbase procedure in a ODI procedure and we can pass odi variables as input variables to that procedure.In the same way i think it is possible to retrive the value returned by a procedure to odi variable if any one aware of how to achieve this plz help me out.
    Regards,
    Sai.

    thanks for the reply , but there is a problem with it,if we use that we need to create a package in the database which is not suitable in my case.
    So, plz help me out if u have any idea of doing it with out creating a back end package.
    Thanks,
    Sai.
    Edited by: 856950 on Sep 19, 2011 9:37 PM

  • Calling Oracle Functions and Procedures in Java

    I've looked online for a blurb on using Oracle SQL functions and
    procedures in Java, but I haven't found anything. Can someone
    either give me a quick crash course on this, or point me to the
    best source of information for this?

    From the SQLJ FAQ.
    http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#sqljplsql
    Within your SQLJ statements, you can use PL/SQL anonymous blocks
    and call PL/SQL stored procedures and stored functions, as in the
    following examples: Anonymous
    block:
    #sql {
    DECLARE
    n NUMBER;
    BEGIN
    n := 1;
    WHILE n <= 100 LOOP
    INSERT INTO emp (empno) VALUES(2000 +
    n);
    n := n + 1;
    END LOOP;
    END
    Stored procedure call (returns the maximum
    deadline as an output parameter into an output host expression):
    #sql { CALL MAX_DEADLINE(:out maxDeadline) };
    Stored function call (returns the maximum
    deadline as a function return into a result expression):
    #sql maxDeadline = { VALUES(GET_MAX_DEADLINE)
    Of course, you can also use JDBC code to achieve the same - the
    standard JDBC escape sequences for stored function and procedure
    calls are supported, using for example:
    "{? = CALL GET_MAX_DEADLINE}"
    or:
    "{call MAX_DEADLINE(?)}"
    and for the rest of the details, get that JDBC crash course...

  • Differnce b/n Var Char, Text,Formula and Hirerachies?????

    Hi bw Experts,
    I want to know the diff b/n Variables and in which scenarios they are useful?
    Can any one explain me reagarding this so that i dev reports based on these concepts.
    Any docs/step by step/or screen shots will be gr8 helpful and highly appreciated.
    possible send me links or docs other than help.sap.
    will be awaiting for ur replies....
    i will Reward points for this.
    Thanks in advance!!!
    Urs,
    Raki.
    my mailid is:[email protected]

    Hi Raki,
    Char Var are used to create pop-up for selection of char values for restrct/filter query content: for example you can create a variable on Cost Center to select one or some of these when executing a query.
    Text Var are used to substitute the header column text with the value of the variable selected for the query: for example you can create a text variable on CALMONTH and insert it in Column, so when you execute the query on a particular month the corresponding column will have in header the month you selected in a dynamic way.
    Hier Var are used to select a particular Hier for the selected Char. You can also create Node Hier Var to select single nodes of the single hier.
    Formula Var are used in particular to obtain values from attributes of a Master Data Char and also to determine Formula on these values: example with Data in Master Data, you can extract this date and make differences with another date stored in cube.
    Look in www.service.sap.com/bi and search for variables, you will find a lot of documents.
    Ciao.
    Riccardo.

  • Using the env variable of unix in a procedure call

    hi,
    how can i use the environment varible of unix in a oracle procedure call ?
    I am working woth shell scripts and it hold some value into a variable and that varible value I want to pass into a oracle procedure.
    i'm sending the sample code and please let me know the solution for this as early as possible.
    actual_file_name=`head -1 temp | tail -1`
    $ORA_BIN_HOME/sqlplus $USER $PASSWD@$TNS
    exec procedure($actual_file_name);
    if i write like above it is not supporting and I tried in so many ways. but no use.
    pls help me.
    suresh.K

    See one possible solution using SQL*Plus command line:
    Re: accessing unix environment variable in oracle procedures

  • Calling Oracle function and Procedure using OCCI with in C++ code

    Could any body send me the sample code to create and execute Oracle function and Procedure using OCCI concept in C++?.
    Edited by: 788634 on Aug 16, 2010 4:09 AM

    Hi Vishnu,
    Yes, sure, you can create a PL/SQL procedure, function, package, package body, etc. from within an OCCI application. I would say that, generally, this is not the sort of activity a typical client application would perform unless there is some initialization/installation processes that need to happen. In any case, here is a simple demo showing how to create a stand alone procedure (in a real application I would use a package and body) that returns a ref cursor. The ref cursor is just a simple select of two columns in the hr.countries sample table. Of course, there is no error handling, object orientation, etc. in this demo - I wanted to keep the code as short and as simple as possible to illustrate the concept.
    Regards,
    Mark
    #include <occi.h>
    #include <iostream>
    using namespace std;
    using namespace oracle::occi;
    int main(void)
      // occi variables
      Environment *env;
      Connection  *con;
      Statement   *stmt;
      ResultSet   *rs;
      // database connection information
      string user = "hr";
      string passwd = "hr";
      string db = "orademo";
      // sql to create the procedure which returns a ref cursor as out parameter
      // should be run as hr sample user or in a schema that has select privilege
      // on the hr.countries table and a synonym (countries) that points to the
      // hr.countries table
      string sqlCreate =
        "create or replace procedure get_countries(p_rc out sys_refcursor) as "
        "begin"
        " open p_rc for"
        " select country_id, country_name from countries order by country_name; "
        "end;";
      // pl/sql anonymous block to call the procedure
      string sqlCall = "begin get_countries(:1); end;";
      // create a default environment for this demo
      env = Environment::createEnvironment(Environment::DEFAULT);
      cout << endl;
      // open the connection to the database
      con = env->createConnection(user, passwd, db);
      // display database version
      cout << con->getServerVersion() << endl << endl;
      // create statement object for creating procedure
      stmt = con->createStatement(sqlCreate);
      // create the procedure
      stmt->executeUpdate();
      // terminate the statement object
      con->terminateStatement(stmt);
      // now create new statement object to call procedure
      stmt = con->createStatement(sqlCall);
      // need to register the ref cursor output parameter
      stmt->registerOutParam(1, OCCICURSOR);
      // call the procedure through the anonymous block
      stmt->executeUpdate();
      // get the ref cursor as an occi resultset
      rs = stmt->getCursor(1);
      // loop through the result set
      // and write the values to the console
      while (rs->next())
        cout << rs->getString(1) << ": " << rs->getString(2) << endl;
      // close the result set after looping
      stmt->closeResultSet(rs);
      // terminate the statement object
      con->terminateStatement(stmt);
      // terminate the connection to the database
      env->terminateConnection(con);
      // terminate the environment
      Environment::terminateEnvironment(env);
      // use this as a prompt to keep the console window from
      // closing when run interactively from the IDE
      cout << endl << "ENTER to continue...";
      cin.get();
      return 0;
    }

  • What exactly is the diff between main window and variable window

    what exactly is the diff between main window and variable window in SAP script?

    hi,
    MAIN WINDOW :- In a main window you display text and data, which can cover several pages (flow text). As soon as a main window is completely filled with text and data, the system continues displaying the text in the main window of the next page. It automatically triggers the page break.
    You can define only have one window in a form as main window.
    The main window must have the same width on each page, but can differ in height.
    A page without main window must not call itself as next page, since this would trigger an endless loop. In such a case, the system automatically terminates after three pages.
    VARIABLE WINDOW :- The contents of variable windows is processed again for each page, on which the window appears. The system outputs only as much text as fits into the window. Text exceeding the window size is truncated; the system does not trigger a page break. Unlike constant windows, the page windows declared as variable windows may have different sizes on different form pages.
    As far as the processing of the window contents is concerned, the system currently treats constant and variable windows alike. The only difference is that constant windows have the same size throughout the form.
    hope this will be useful.
    If useful then reward points.
    with regards,
    Syed

  • Remote procedure call failed and did not execute response after changing contents

    Hey Hey!
    I have reviewed the other posts related to this issue but have not found a solution.
    I have done myself quite a mischief and hope someone here can help me out!
    I'm running an old ACER laptop with Windows 7. This PC belonged to an old colleague and therefore all of the folders and user names were still under his name, so I decided to try to change them all to my name. The main issue was the USER folder which had
    the locked symbol next to it but it wasn't locked at all. I googled how to delete this folder and one bright spark suggested I create a new folder with my name, copy all of the folders from the other 'locked' user's folder into my folder, and then delete the
    old user's folder. 
    That was fine. All seemed well. When I tried to delete the old folder the computer sat around thinking saying it was 'moving' but not doing anything. So, I cancelled the operation in the Task Manager. When I attempted to open any folder from the start menu
    or desktop or task bar I was presented with a bunch of numbers and letters and the message "REMOTE PROCEDURE CALL FAILED AND DID NOT EXECUTE."
    I quickly googled the message realising I'd made a major error and the first response was to type in services.msc or something to that effect, so I typed that into the Start Menu search bar and hit enter and nothing came up. So, I tried again, but now I
    couldn't type anything into the search bar, I could not even select any programs from the Start Menu. 
    So, I can't access the Start Menu, search bar, or any of the folders unless I open uTorrent, select open containing folder, and from there I can access what I need.
    I'm too afraid to reboot the PC. I can't locate my copy of Windows 7 anywhere. I'm freaking out!!
    Before I pour my lowly student wage into getting a professional to fix it, could someone please offer some suggestions??
    Greatly appreciated in advance. 
    Paris, Texas. 

    Hi,
    Based on your description, for this question is more related to NetQueryDisplayInformation() API, in order to get better help, we may ask for suggestions in the following MSDN forum.
    MSDN Forum
    https://social.msdn.microsoft.com/Forums/en-US/home
    Besides, we can try to use a script to get all domain users. Regarding this point, the following script can be referred to as reference.
    How to list all active directory users in a particular domain using PowerShell
    https://gallery.technet.microsoft.com/office/How-to-list-all-active-0d9be7ce
    In addition, for scripts, we can also ask for help in the following forum.
    The Official Scripting Guys Forum
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    Best regards
    Frank Shen 

  • How many ways to read and write a local variable in a called VI?

    Ciao!
    I'm producing my first TestStand sequence. It is called "FirstAttempt" and it is made by a single step which calls a VI. One of the first dilemmas i encountered realizing this sequence is how to read and write a local variable (created going in Variables -> Locals ('FirstAttempt') -> <right click to insert local>) in the called VI.
    The first way (the only one i tried) is to create a control and an indicator on the VI front panel, connect them to their respective terminals in the connector pane and then specify (going in Step Settings -> Module) that these connectors (shown in the Parameter Name column) are linked to the local variable (selected in the Value column).
    The second way (not tried) consists in using TestStand API: create a Sequence Context reference on the VI front panel, link it to a property node in the block diagram, select the property "Locals" and extract from this the local variable name and value which, i think, can be readable and writable.
    So...
    Are the shown ways correct?
    Are there other ways?
    Knowing that a "local" variable can be considered "global" within the whole sequence, is there the possibility to simply create a reference to the local variable and use the reference in the called VI block diagram in order to save space in the connector pane (if using method 1) or in the block diagram (if using method 2)?
    Thanks!
    Message Edited by aRCo on 09-17-2009 05:09 AM

    Hi,
    Before TestStand 3 you would use the second way you quoted as its the only way.
    But now you would use the first way you quoted. You may still what to pass the SequenceContext if you were going to use the TestStand API. For TestStand 3.x and above you would use this way as the first chose. (Personnelly, I would not pass the SequenceContext into a VI if I know it was never going to be used in that VI.)
    Not sure I understand your final comment, maybe you are liking it to passing the reference of a control to a subVI so that the control can be updated from within the subVI.
    If this is the case and you had a situation where you had a step that was running in parallel with the rest of the steps in the sequence either as a separate thread or execution and were dependent on the contents of the  local variable changing from that parallel running step, then you would have to use the API SetVal method to change the local.
    Hope this is clear.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • DBAdapter procedure call issue (dev and test env have seperate schema)

    Hi All
    We are facing an issue with DBAdapter (even after commenting the schema name from JCA file). The procedure is using SQL objects and collections. The DBAdapter is trying to find these objects in the old schema (the one used in dev) but they are compiled on a diff schema in INT and hence it is throwing an exception.
    How can i get this to work. Please help.
    CREATE OR REPLACE
    TYPE QUERY_INVENTORY AS OBJECT (
    requestingstoreid VARCHAR2 (20),
    simuserid VARCHAR2 (60),
    storeidlist vfuk_store_id_list,
    itemidlist vfuk_item_id_list,
    flexfield1 VARCHAR2 (200),
    flexfield2 VARCHAR2 (200),
    flexfield3 VARCHAR2 (200)
    CREATE OR REPLACE
    TYPE QUERY_INVENTORY_LIST AS TABLE OF QUERY_INVENTORY;
    CREATE OR REPLACE PACKAGE abcd
    AS
    PROCEDURE def (
    i_queryrequest IN QUERY_INVENTORY_LIST,
    o_errormsg OUT VARCHAR2,
    o_errorcode OUT VARCHAR2
    END abcd;
    /

    Hi Arik
    Thanks for the reply. A DB procedure with normal arguments (VARCHAR, DATE etc) is working fine after commenting the schema name in JCA file (It is taking the schema name from data source).
    But if you use SQL objects and SQL collections as IN\OUT parameters, it generates the XSD with complex types that have the schema prefix attached to them. So, even after commenting in JCA it is still looking for those SQL objects in the OLD schema.
    Do i need to change the prefixes in the XSD as well? This would not be a feasible option as i would have to do it for all the environments.
    Somebody pls help....

  • Procedure call and shell script

    When i try to pass a shell variable to a procedure call in a shell script it does not work. But a SQL command ( insert ) has no problem taking the shell variable. Has this something to do with context switch. How to get around this prbokem.
    `sqlplus <username/password> -silent << EOF
    set serveroutput on size 1000000
    exec procA; -- works
    exec procB($shell_variable); -- does not work
    insert into table1 values ($shell_variable); -- works
    EOF`
    Thanks!

    It works to me :
    TEST@db102 SQL> create or replace procedure isnumeric (num in varchar2)
      2  is
      3          a       number;
      4  begin
      5          a := to_number(num);
      6          dbms_output.put_line (num||' is a number');
      7  exception
      8          when others then
      9                  dbms_output.put_line (num||' is NOT a number');
    10* end;
    11  /
    Procedure created.
    TEST@db102 SQL> exec isnumeric(123);
    123 is a number
    PL/SQL procedure successfully completed.
    TEST@db102 SQL> exec isnumeric('abc');
    abc is NOT a number
    PL/SQL procedure successfully completed.
    TEST@db102 SQL>
    [ora102 work db102]$ cat callvar.sh
    export VAR=$1
    sqlplus -s test/test << EOF
    set serveroutput on size 1000000
    exec isnumeric('$VAR');
    EOF
    [ora102 work db102]$ ./callvar.sh 123
    123 is a number
    PL/SQL procedure successfully completed.
    [ora102 work db102]$ ./callvar.sh abc
    abc is NOT a number
    PL/SQL procedure successfully completed.
    [ora102 work db102]$                       

  • How can I create a function using TestStand variables and call it from a step's Pre-Expression?

    In one sequence I have dozens of Pre-Expressions which are almost the same thing, like this...
    Locals.tagID = (Parameters.singlePhaseEnabled ? "L" : "D") & Str(Locals.phase) & "006"
    ...and the only thing different is that three digit string at the end ("006" will vary). How can I write a function that I can call from a step's Pre-Expression so it would look something like this? ...
    Locals.tagID = MyNewFunction("006")

    You cannot write custom commands for expressions.
    That being said, there are a couple of options:
    Create a subsequence with a single step. Use a parameter of the sequence as "function parameter".
    Create a custom step type including a substep module which implements the function. Add an edit substep to enable the user of the steptype to gracefully change the parameter.
    Store the variable parameter in a local/file global variable and modify the value in each step. This will, at least, keep the "function" the same for every step.
    Norbert

Maybe you are looking for

  • Problem in  BOM or component allocation for the Non- codified Item in a PO.

    Hi All, Please advise how to explode a BOM or Assign component in a Purchase order with Item category (L) for a Operation oriented material for which no material code is created from a production order . Actually in my scenario, no raw material compo

  • File has to pass through FTPS connection.. Connection parameters?

    Hi, I want to transfer the file through FTPS connection. Partner side provided the following details as connection parameters. - IP : 129.32.169.140  - POrt: 990 User name Password PASV mode SSL Direct, OpenSSL,SSL Listing, SSL Transfers. Kindly let

  • Bridge Fails to Load Thumbnails

    Bridge can not load a folder with 200 images in CR2 and jpg format. Getting answers from Adobe is worse than trying to penetrate the NSA. Anyone out there have any suggestions. I've purged cache, set the to the middle of the slider, clicked compact c

  • Hyperlinks in excel don't allow user to save file in adobe reader

    I created a fillable form for users who have adobe reader. Form works. Users can fill the form in and save it (with same name). When users try to access this same form thru a hyperlink in excel, they are not allowed to save the filled in form using t

  • "Page" and "Rect" props of the Field prop in Javascript API

    Page property of the Field property in Javascript Acrobat API returns an array of pages that this field exists in. On the other hand, "rect" property returns just one set of coordinates of the field on a page. My questions are: 1. Suppose field's "pa