string SQL subset

Hello

I was wondering if there was a sql expression, probably a form of rational expression that could determine whether a string is one subset of another.

Sounded simple, but I had trouble finding a predefined regular expression. Sounds like a problem deeper than expected.

Here is the set of basic data, the word "CHEERS", I would like to know if there is a string of characters within that Word. I could do the word Scrabble, I?

Following a simple test with results expected that I hope it exposes my needs with a solution that our regexp resident guru got close to, but not quite.

with data as (
select 'ers' sub, 'y' exp from dual union all
select 'cee', 'y' from dual union all
select 'crr', 'n' from dual union all
select 'x', 'n' from dual union all
select 'cr' ,'y' from dual
)
select 'cheers', sub, exp
  ,regexp_replace(sub, '([:cheers:]{'||length(sub)||'})', '|') test_subset
from data;

He gets the x, but not the RRC.

I am after a sql equivalent to the following, since the age of a string in a table nested for this test requires a few hoops, and it would be nice to have a test in native SQL.

DECLARE
  TYPE list IS TABLE OF varchar2(1);
  a LIST := list('c','h','e','e','r','s');
  b LIST := list('c','e','r');
BEGIN
IF b SUBMULTISET a THEN
    dbms_output.put_line('Subset.');
ELSE
    dbms_output.put_line('not');
END IF;
END;
/

Scott

You cannot perform this operation with simple approaches to replacement.

This is because you should always do the right number of replacements.

Your approach to the nested table in my opinion is close to the optimum, at least one view of readability.

Something to play with

with the data as)

void Select 'ers', 'y' union exp double all the

Select 'cee', 'y' from dual union all

Select "RRC", "n" of all the double union

Select "x", "n" of all the double union

Select 'cr', 'y' of the double

)

, r (sub, s, n, exp) as)

Select sub, regexp_replace ('cheers', substr (sub, 1, 1), null, 1, 1), 2, exp of data

Union of all the

Select sub, regexp_replace (s, substr (sub, n-1), null, 1, 1), n + 1, r exp

where instr (s, substr (sub: n - 1)) > 0

)

Select

Sub, exp

r

where length ('cheers') - length = length (sub)

SUB EXP
CR There
ERS There
Eco There

Just do a negative sign for invalid data

Select

Sub, exp

from the data

less

Select

Sub, exp

r

where length ('cheers') - length = length (sub)

SUB EXP
CRR n
x n

Tags: Database

Similar Questions

  • 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

  • Date format string SQL Conveting XML

    Hi all
    I have a question where a date that comes as input to a string format must be inserted into a database is Timestamp. Can someone help me on this...

    the date format which I recive is '2008-08-01' where "yyyy-MM-DD" I have to convert it in the format "YYYY-MM-ddTHH" Help with this convert Timestamp would be a great help.

    Hi Sissi,
    Please use the format-dateTime function in xslt and to generate the time portion of the date, use the '00' instead of hh, mm, and ss. This function automatically converts an XML datetime SQL string.

    The function will look like this - dateTime(YYYY-MM-DDT00:00:00) format.

    Concerning
    AYUSH

  • Concatenation of strings - SQL Query (pl - sql function returning SQL query body

    Hi all

    I have just problem with the string concatenation. I would like to come back to something like "Lname, FNAMe" but below returns it Lnamefname

    v_sql: = ' SELECT concat(LNAME,FNAME) as an ENTREPRENEUR, '
    ' |' s.TEAM as TEAM, "he said.
    |' s.CONTRACT_NO as CONTRACT_NO'
    ||' S '

    I also tried below who gave the results as fname (seprate column as an entrepreneur) and lname received separately as lname... I wish I had it

    example of result should be something like: = Weigner, Lucy

    v_sql: = 'SELECT LNAME "| ', ' ||' FNAME ENTREPRENEUR,'
    ||' S.TEAM as TEAM "
    ||' S.CONTRACT_NO as CONTRACT_NO,'


    Thank you

    Lucy,

    Try

    v_sql := ' SELECT LNAME|| '',''|| FNAME CONTRACTOR,'
          || ' S.TEAM as TEAM,'
          || ' S.CONTRACT_NO as CONTRACT_NO,';
    

    See you soon,.
    Hari

  • build the sql string

    I build my sql in java string and then pass it to Hibernate query

    I add several conditions based on user research

    This is a simple condition 'and' I create and add
              if(StringUtils.isNotBlank(stgAuditGeneral.getAuditeename())){
                   filter=" and lower(AUDITEE_NAME) like '%?%' ";
                   sqlqQuery=sqlqQuery+StringUtils.replace(filter, param, StringUtils.lowerCase(stgAuditGeneral.getAuditeename()));
              }
    Assume that the user has entered
     lourt's 
    generated SQL will be
    and lower(AUDITEE_NAME) like '%lourt's%'  and   ......
    If the user enters the quotes for stgAuditGeneral.getAuditeename () my String sql will be curreprted and I get sql exception

    Please suggest me how to avoid this problem

    user11138293 wrote:
    I'm using hibernate,
    I pass the query parameter is the request that I create, please tell me in this case can I use preparedstatement way settings?

    Hibernate provides similar functionality. Review the class SQLQuery (createSQLQuery returns). It has methods like setString(), setInteger() that allow you to replace the two positional parameters (as? 1? 2) or of named parameters (as: param1,: param2) in the query.
    There is absolutely no reason why this day and age everyone should be concatenating queries SQL and parameters set as strings.

  • How to run a SQL string to a procedure of forms?

    Hello

    first the background. I have a Varchar2 column in a Table with a SQL string.
    Now I want to read this chain in forms and run the SQL statement - but I don't know how.

    This is the SQL string:
    Select the country from p_1 from countries where country_nr = p_2

    P_1 and p_2 are Variables in the procedure of forms.

    Most people forget that groups Records are excellent tools for dynamic queries like this. Search for Populate_group_with_query.

    Only you need to change your sql, it is not in the sentence, like this:

    Select the country as P_1
    country
    where country_nr = p_2
    and p_3 = p_3
    and p_4 = p_4

    Select name as P_1
    of the customer
    where customer_nr = p_2
    and country_nr = p_3
    and p_4 = p_4

    Your rec group would have a single column, P_1, where the data would be accessible after the query. Get_group_char_cell allows you to retrieve the value of P_1.  I don't know, but you should not "AS P_1" expression in the select, as long as you have created the record group initially with a specific column name.

    The only thing that is not clear, however, is your use of variables in the where clause. You can either hardcode the literal values in the SQL string, like this:

    'where country_nr = ''123'' and...'

    Note as you build your text string SQL, you use two apostrophes instead of one, given that pl/sql uses the apostrophe of beginning and end of the string.

    Or alternatively, you can use bind variables for your where the variables paragraph as follows:

    where customer_nr = :Parameter.var_2
    and country_nr = :Parameter.var_3

    Then, you can move a value in the: parameter values before completing the Group rec. You can use elements in a block of control rather than the settings, too.

    Here is an example of using dynamic query in a record group: Re: dynamic query

  • DatabaseMetaData and ResultSetMetaData return different codes of Type SQL for number

    Hello

    I was testing the code of a colleague who used ResultSetMetaData who was retrieved with Statement.getMetaData () of a select statement. ResultSetMetaData.getColumnType (I) returned 2 (digital) for the SQL type number. My DatabaseMetaData used test code comes from Connection.getMetaData (). DatabaseMetaData.getColumns returned 3 (decimal) for the SQL number type.

    Here is a snippet of code to illustrate the issue:

    The database must contain table MY_TABLE with a column of type "digital."

    String username = "user";

    String password = "password";

    String host = "host".

    Port of String = "port";

    String sid = 'sid ';


    DriverManager.registerDriver (new oracle.jdbc.OracleDriver ());

    Connection connection =

    DriverManager.getConnection ("JDBC: thin: @" + host + ': ' + port + ': ' + sid, user, password);

    Get the SQL with DatabaseMetaData type

    Metadata DatabaseMetaData = connection. getMetaData();

    ResultSet tables is metadata.getTables ( user, null,null, new String [] { "TABLE" });.

    My_table should be the first table

    if (tables. next()) {

    String tableName = table.getString (3);

    log.info (tableName);

    ResultSet columns is metadata.getColumns ( user, tableName,null, null);.

    while (columns. next()) {

    String columnName = columns.getString (4);

    String columnType = columns.getString (5);

    System.out.println (columnName + "' + columnType" ");

    Column type 3

    }

    columns. close();

    }

    tables. close();

    Get the SQL with ResultSetMetaData type

    Statement statement = connection. createStatement();

    String SQL = ' SELECT * FROM my_table ';

    . Perform statement(sql);

    ResultSet resultSet = statement. getResultSet();

    ResultSetMetaData metaData2 = resultSet. getMetaData();

    for (int i = 1; I < = metaData2. getColumnCount(); i++) {

    System.out.println (metaData2.getColumnName (I) + "' .getColumnType metaData2(i) +" ");

    Column type is 2

    }

    Is there a reason for the discrepancy?

    Kind regards

    Johannes

    A bug has been filed for this. You must get your license in any case. ojdbc14 is the obsolete way.

  • java.sql.SQLSyntaxErrorException: ORA-00904: invalid identifier

    Hi all

    IM using JDeveloper 11.1.1.6.0.

    Here, I said method in the main class, which returns an object of type of connection reference.

    When I run the app I type 'ksh' in the fields and click on submit.

    It shows the following error, java.sql.SQLException: ORA-00904: "KSH": invalid identifier

    {code}

    public static list < privileges > getUserPrivileges (DBTransaction dbt, object userId)

    {

    String sql = "SELECT m.menu_code" +.

    "OF sec_menus m p sec_menu_privileges JOIN +.

    "WE (m.menu_code = p.menu_code '+)"

    "(ET m.app_id = p.app_id)" + "

    "JOIN sec_user_app_groups g +.

    "WE (g.GROUP_ID = p.GROUP_ID '+)"

    "AND p.app_id = g.app_id" +.

    "AND user_id =" + userId + "."

    "             )";

    PreparedStatement stat = null;

    ResultSet rs = null;

    List of privileges <>privilegesList = new ArrayList < privileges > ();

    MenuCode string = "";

    Try

    {

    = stat dbt.createPreparedStatement (sql, 1);

    RS = stat.executeQuery ();

    While (RS. Next())

    {

    menuCode = rs.getString (1);

    }

    }

    catch (System.Exception e)

    {

    e.printStackTrace ();

    }

    Finally

    {

    closeStatement (stat);

    closeResultSet (SR);

    }

    Return privilegesList;

    }

    Public Shared Sub closeStatement (stat of statement)

    {

    Try

    {

    STAT. Close();

    }

    catch (SQLException e)

    {

    }

    }

    public static void closeResultSet (ResultSet rs)

    {

    Try

    {

    RS. Close();

    }

    catch (SQLException e)

    {

    }

    }

    ------------

    CREATE TABLE SEC_USERS

    (

    USER_ID VARCHAR2 (10),

    USER_NAME VARCHAR2 (50).

    PASSWORD VARCHAR2 (300)

    )

    Insert into SEC_USERS

    (USER_ID, USER_NAME, USER_FIRST_NAME, USER_LAST_NAME, PASSWORD)

    Values

    ('ksh', 'ksh', 'test');

    COMMIT;

    -----------------------

    Error:

    java.sql.SQLSyntaxErrorException: ORA-00904: "KSH": invalid identifier

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)

    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)

    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)

    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)

    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)

    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)

    at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:947)

    at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1283)

    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1441)

    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)

    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3823)

    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1671)

    dry. ControllerUtil.getUserPrivileges (ControllerUtil.java:90)

    dry. ControllerUtil.login (ControllerUtil.java:59)

    at sec.model.AppModuleImpl.login(AppModuleImpl.java:77)

    at sec.control.bean.LoginPage.loginAction(LoginPage.java:92)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.el.parser.AstValue.invoke (unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke (unknown Source)

    at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)

    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)

    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:889)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:379)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

    to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:446)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:446)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:119)

    at java.security.AccessController.doPrivileged (Native Method)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.wrapRun (WebAppServletContext.java:3715)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    < ActionListenerImpl > < processAction > java.lang.NullPointerException

    javax.faces.el.EvaluationException: java.lang.NullPointerException

    at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:92)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)

    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)

    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:889)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:379)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

    to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:446)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:446)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:119)

    at java.security.AccessController.doPrivileged (Native Method)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.wrapRun (WebAppServletContext.java:3715)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Caused by: java.lang.NullPointerException

    dry. ControllerUtil.closeResultSet (ControllerUtil.java:136)

    dry. ControllerUtil.getUserPrivileges (ControllerUtil.java:118)

    dry. ControllerUtil.login (ControllerUtil.java:59)

    at sec.model.AppModuleImpl.login(AppModuleImpl.java:77)

    at sec.control.bean.LoginPage.loginAction(LoginPage.java:92)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.el.parser.AstValue.invoke (unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke (unknown Source)

    at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)

    ... more than 54

    {\code}

    Thanks in advance

    The particular error that causes the ORA-00904 exception, it's that you concatenate a string literal in the SQL statement without enclosing the literal with quotes. Replace the line

    "AND user_id =" + userId + "."

    with

    "AND user_id = '" + Userid + "'" +.

    Although it will work in this way, the concatenation of literal values variable to a SQL statement is a very wrong approach. The right approach is to use a placeholder variable (for example?) in the SQL statement and to link it with the necessary value after analysis of the declaration and before running. In this way, you will be able to analyze the statement once and execute it several times with different values without new analysis view the statement. Also, the SQL engine will be able to use its SQL cache if you try to analyze the statement even once again, which will significantly improve performance. However, if you concatenate variable literal value to education, engine SQL won't recognize the statement as one already analyzed, it will not use its cache and it will analyze the statement again from scratch. From a point of view shortly, the best approach is as follows:

    "" AND user_id =? ".

    and then

    = stat dbt.createPreparedStatement (sql, 1);

    stat.setString (1, userId); Don't forget to change the username to a string type in the method declaration

    RS = stat.executeQuery ();

    There are other problems in your code. First of all, the invocation closeResultSet (rs) after closeStatement (stat) is erroneous and obsolete, because when you close a SQLStatement instance it automatically closes all its result sets. Secondly, in the finally block you call closeStatement (stat), but there is no guarantee that stat variable is not null. For example, the variable stat can be null if the SQLStatement instance has not been established successfully in the try section above.

    Dimitar

  • Berkeley DB 6 with API SQL and CLOB, BLOB column type.

    Hi, we use Oracle Database Server Mobile 11.3.0.3 with BerkeleyDb as our customer database.  We use the SQL API with language .NET and JAVA.  In the Oracle database synchronize us with Berkeley DB, we have those 2 Datatype: BLOB or CLOB.  I couldn't find examples with the SQL API for Berkeley DB and these two types of data.   Could someone gave me some examples to access these two data type .net and JAVA in a BerkeleyDB database?

    Thank you!

    Hello

    Here is an example of the use of BLOB with BDB SQL JDBC data type. It also works with the CLOB data type.

    import java.io.ByteArrayInputStream;

    import java.sql. *;

    public class SQLBlobExample {}

    private String url = "jdbc:sqlite: / path_of_dbfile";

    private conn Connection = null;

    Public Shared Sub main (String [] args) {}

    Example SQLBlobExample = new SQLBlobExample();

    int ret;

    String RS;

    try {}

    If ((ret = example.openConnection ())! = 0)

    System.Exit (1);

    If ((ret = example.createTable ())! = 0)

    System.Exit (1);

    If ((ret = example.addRowByByteArray ("moka", "c'est la description de moka"))! = 0)

    System.Exit (1);

    If ((ret = example.addRowByBinaryStream ("Latte", "c'est la description de latte"))! = 0)

    System.Exit (1);

    If ((rs = example.retrieveRowByBinaryStream ("Mocha"))! = null)

    System.out.println ("retrieve Mocha:" + r);

    on the other

    System.Exit (1);

    If ((rs = example.retrieveRowByByteArray ("Latte"))! = null)

    System.out.println ("Latte recover:" + r);

    on the other

    System.Exit (1);

    example.closeConnection ();

    } catch (SQLException e) {}

    System.Err.println ("hand: SQLException:" + e.getMessage ());

    }

    }

    public int openConnection() {}

    int ret = - 1;

    If (this.conn == null) {}

    try {}

    Class.forName ("SQLite.JDBCDriver");

    This.Conn = DriverManager.getConnection (url,

    "myLogin", "password");

    RET = 0;

    } catch (java.lang.ClassNotFoundException e) {}

    System.Err.Print ("openConnection :");

    System.Err.Print ("ClassNotFoundException :");

    System.Err.println (e.getMessage ());

    } catch (SQLException ex) {}

    System.Err.Print ("openConnection :");

    System.Err.Print ("SQLException :");

    System.Err.println (ex.getMessage ());

    }

    }

    return (ret);

    }

    public int closeConnection() throws SQLException {}

    int ret = - 1;

    try {}

    If (this.conn! = null) {}

    This.Conn.Close ();

    This.Conn = null;

    }

    RET = 0;

    } catch (SQLException e) {}

    System.Err.Print ("closeConnection :");

    System.Err.Print ("SQLException :");

    System.Err.println (e.getMessage ());

    }

    return (ret);

    }

    public int createTable()}

    Statement stmt;

    String createString = "create table COFFEE_DESCRIPTIONS +.

    "(COF_NAME VARCHAR (40) NOT NULL,"+).

    "COF_DESC CLOB, +.

    "key (COF_NAME)) primary."

    int ret = - 1;

    try {}

    stmt = this.conn.createStatement ();

    stmt. Execute ("PRAGMA large_record_opt = 10 ;");

    stmt.executeUpdate ("drop table if exists COFFEE_DESCRIPTIONS");

    stmt.executeUpdate (createString);

    RET = 0;

    } catch (SQLException e) {}

    System.Err.println ("Create table: SQLException:" + e.getMessage ());

    }

    return (ret);

    }

    public int addRowByByteArray (String coffeeName, String value)

    throws SQLException {}

    PreparedStatement pstmt = null;

    int ret = - 1;

    try {}

    ("System.out.println (" write the following: ("+ coffeeName +",) "+ value +" ")");

    String sql = "INSERT INTO COFFEE_DESCRIPTIONS VALUES(?,?)";

    pstmt = this.conn.prepareStatement (sql);

    pstmt.setString (1, coffeeName);

    pstmt.setBytes (2, value.getBytes ());

    pstmt.executeUpdate ();

    RET = 0;

    } catch (SQLException e) {}

    System.Err.println ("addRowByByteArray: SQLException:" + e.getMessage ());

    } catch (Exception ex) {}

    System.out.println ("addRowByByteArray: unexpected exception:" + ex.getMessage ());

    } {Finally

    If (pstmt! = null)

    pstmt. Close();

    }

    return (ret);

    }

    public int addRowByBinaryStream (String coffeeName, String value)

    throws SQLException {}

    PreparedStatement pstmt = null;

    int ret = - 1;

    try {}

    Byte [] buf = value.getBytes ();

    ("System.out.println (" write the following: ("+ coffeeName +",) "+ value +" ")");

    String sql = "INSERT INTO COFFEE_DESCRIPTIONS VALUES(?,?)";

    pstmt = this.conn.prepareStatement (sql);

    pstmt.setString (1, coffeeName);

    pstmt.setBinaryStream (2, ByteArrayInputStream (buf) new, buf.length);

    pstmt.executeUpdate ();

    RET = 0;

    } catch (SQLException e) {}

    System.Err.println ("addRowByBinaryStream: SQLException:" + e.getMessage ());

    } catch (Exception ex) {}

    System.out.println ("addRowByBinaryStream: unexpected exception:" + ex.getMessage ());

    } {Finally

    If (pstmt! = null)

    pstmt. Close();

    }

    return (ret);

    }

    public String retrieveRowByByteArray (String coffeeName)

    throws SQLException {}

    Dim description As String = null;

    Byte [] buf;

    PreparedStatement pstmt = null;

    try {}

    String sql =

    'select COF_DESC +.

    "of COFFEE_DESCRIPTIONS +.

    "where COF_NAME =?";

    pstmt = this.conn.prepareStatement (sql);

    pstmt.setString (1, coffeeName);

    ResultSet rs = pstmt.executeQuery ();

    If (RS. Next {}

    buf = rs.getBytes (1);

    Description = new String (buf);

    }

    } catch (SQLException ex) {}

    System.Err.println ("retrieveRowByByteArray: SQLException:" + ex.getMessage ());

    } catch (Exception e) {}

    System.out.println ("retrieveRowByByteArray: unexpected exception:" + try ());

    } {Finally

    If (pstmt! = null)

    pstmt. Close();

    }

    return description;

    }

    public String retrieveRowByBinaryStream (String coffeeName)

    throws SQLException {}

    Dim description As String = null;

    int len = 0;

    Byte [] buf = new byte [1024];

    PreparedStatement pstmt = null;

    try {}

    String sql =

    'select COF_DESC +.

    "of COFFEE_DESCRIPTIONS +.

    "where COF_NAME =?";

    pstmt = this.conn.prepareStatement (sql);

    pstmt.setString (1, coffeeName);

    ResultSet rs = pstmt.executeQuery ();

    If (RS. Next {}

    Len = rs.getBinaryStream (1) .read (buf);

    Description = new String (buf);

    }

    } catch (SQLException e) {}

    System.Err.println ("retrieveRowByBinaryStream: SQLException:" + e.getMessage ());

    } catch (Exception ex) {}

    System.out.println ("retrieveRowByBinaryStream: unexpected exception:" + ex.toString ());

    } {Finally

    If (pstmt! = null)

    pstmt. Close();

    }

    return description;

    }

    }

    If there is any question, please do not hesitate to let me know.

    Kind regards

    Cindy

  • How to call the pl/sql function of the ofa

    Dear friends,

    I am trying to call a function of OPS page .but iam getting error as

    java.sql.SQLException: ORA-01861: literal does not match the format string

    ORA-06512: at line 1

    It is my function, callable statement

    FUNCTION CAR_LOAN_VALIDATION (P_PERSON_ID IN NUMBER

    P_DEDUCTION_START_DATE AS

    P_DEDUCTION_END_DATE AS

    P_LOAN_VALUE NUMBER

    )

    RETURN VARCHAR2

    IS

    l_message VARCHAR2 (100);

    l_contract_type VARCHAR2 (50);

    l_loan_eligible_date DATE;

    l_grade VARCHAR2 (15);

    l_old_loan_end_date DATE;

    l_max_loan_end_date DATE;

    l_remaining_amount NUMBER;

    l_eligible_amt NUMBER;

    BEGIN

    BEGIN

    SELECT - papf.person_id,.

    (SELECT the sense

    OF hr_lookups

    WHERE lookup_type = 'ADTC_CONTRACT_TYPE. '

    AND lookup_code = attribut3) contract_type;

    ADD_MONTHS (papf.original_date_of_hire, 11) loan_eligible_date,.

    DECODE (paaf.ass_attribute2,

    'President', '' President. ''

    SUBSTR (ass_attribute2, INSTR (ass_attribute2, '.', 1, 1) + 1,)

    3)

    ) grade.

    (SELECT nvl (MAX (deduction_end_date), null)

    OF xxadtc_car_loan_request

    WHERE person_id = p_person_id) old_loan_end_date;

    TO_DATE (ADD_MONTHS (p_deduction_start_date, 47)) max_loan_end_date

    -to_date (ADD_MONTHS (sysdate, 47)) max_loan_end_date

    IN l_contract_type

    l_loan_eligible_date

    l_grade

    l_old_loan_end_date

    l_max_loan_end_date

    OF per_all_people_f women's wear, per_all_assignments_f ADP

    WHERE SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date

    AND papf.business_group_id = 81

    AND papf.person_id = paaf.person_id

    AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date

    AND papf.person_id = P_PERSON_ID;

    EXCEPTION

    WHILE others THEN

    DBMS_OUTPUT. Put_line ('error');

    END;

    -to obtain the amount of the previous car loan-

    BEGIN

    SELECT to_number (prrv.result_value)

    IN l_remaining_amount

    OF per_all_people_f women's wear.

    per_all_assignments_f ADP,

    pay_assignment_actions CIP,

    pay_run_results prr,

    prrv pay_run_result_values,

    petf pay_element_types_f,

    pay_input_values_f pivf,

    pay_element_classifications pec,

    pay_payroll_actions App,

    TPP per_time_periods

    WHERE SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date

    AND papf.person_id = paaf.person_id

    AND papf.business_group_id = 81

    AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date

    AND paaf.assignment_id = pac.assignment_id

    AND pac.assignment_action_id = prr.assignment_action_id

    AND prr.run_result_id = prrv.run_result_id

    AND prr.element_type_id = petf.element_type_id

    AND SYSDATE BETWEEN petf.effective_start_date AND petf.effective_end_date

    AND prrv.input_value_id = pivf.input_value_id

    AND SYSDATE BETWEEN pivf.effective_start_date AND pivf.effective_end_date

    AND pivf.NAME = 'balance '.

    AND petf.classification_id = pec.classification_id

    AND pac.payroll_action_id = ppa.payroll_action_id

    AND ppa.time_period_id = ptp.time_period_id

    AND TO_CHAR (ptp.pay_advice_date, 'Mon-YYYY') =

    To_char (SYSDATE, "Mon-YYYY")

    AND petf.element_name = "Fashions ready Ahlami"

    - and employee_number = '10185'

    AND papf.person_id = p_person_id;

    EXCEPTION

    WHEN no_data_found THEN

    -DBMS_OUTPUT. Put_line (' ERROR: no data!');

    l_remaining_amount: = 0;

    WHILE others THEN

    DBMS_OUTPUT. Put_line ('error');

    END;

    Select GET_CAR_LOAN_ELIGI_AMT (P_PERSON_ID)

    in l_eligible_amt

    Double;

    IF L_contract_type NOT IN ("Permanent") THEN

    l_message: = 'contract Type is invalid. "

    END IF;

    IF l_loan_eligible_date < SYSDATE THEN

    l_message: = 'Date to join is less then a year. "

    END IF;

    IF l_grade IN ('US', '00', 'AUS', ') THEN

    "l_message: = ' your are not eligible Grade."

    END IF;

    IF l_old_loan_end_date < SYSDATE THEN

    l_message: = 'previous loan period is not completed. "

    END IF;

    IF l_max_loan_end_date > P_DEDUCTION_END_DATE THEN

    l_message: = 'Maxinum number of monthly payment for 48 months;

    END IF;

    IF l_remaining_amount > 0 THEN

    l_message: = "amount of the previous car loan is waiting until";

    END IF;

    IF l_eligible_amt < p_loan_value THEN

    l_message: = 'Please check eligible amount ";

    END IF;

    RETURN nvl(l_message,'S');

    EXCEPTION

    WHEN NO_DATA_FOUND

    THEN

    RETURN "error";

    END CAR_LOAN_VALIDATION;

    END XX_CAR_LOAN_REQUEST_PKG;

    CODE THAT CAN BE CALLED BY CODE - CO STATEMENT

    {if (PageContext.GetParameter ("Submit")! = null)}

    OAViewObject vo2 = (OAViewObject) am.findViewObject ("XxadtcCarLoanRequestEOVO1");

    {if(VO1!=null)}

    VO1. GetCurrentRow () .setAttribute ("LoanStatus", "pending approval");

    int xxpersonId = pageContext.getEmployeeId ();

    String xxDeductionStartDate = vo2.getCurrentRow ().getAttribute("DeductionStartDate").toString ();//pageContext.getParameter("DeductionStartDate").toString();

    SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy/mm/dd");

    ConvertedDate1 date = dateFormat1.parse ("xxDeductionStartDate");

    String xxDeductionEndDate = vo2.getCurrentRow ().getAttribute("DeductionEndDate").toString ();//pageContext.getParameter("DeductionEndDate").toString();

    SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy/mm/dd");

    ConvertedDate2 date = dateFormat2.parse ("xxDeductionEndDate");

    String xxLoanValue = vo2.getCurrentRow ().getAttribute("LoanValue").toString ();//pageContext.getParameter("LoanValue").toString();

    int iLoanValue = Integer.parseInt (xxLoanValue);

    System.out.println ("loop submit input");

    System.out.println ("xxpersonId id is:" + xxpersonId);

    System.out.println ("xxDeductionStartDate id is:" + xxDeductionStartDate);

    System.out.println ("xxDeductionEndDate id is:" + xxDeductionEndDate);

    System.out.println ("xxLoanValue id is:" + xxLoanValue);

    TXN OADBTransaction = am.getOADBTransaction ();

    String sql = "START: 1: = XXADTC_CAR_LOAN_REQUEST_PKG." CAR_LOAN_VALIDATION(:2,:3,:4,:5); END; « ;

    CallableStatement cs = txn.createCallableStatement(sql,1);

    String outputval = null; / / int outputval = 0;

    try {}

    System.out.println ("entry into loop try funtion callable validation");

    cs.setInt(2,xxpersonId);

    System.out.println ("cs setInt (2, xxpersonId);") is executed");

    cs.setString(3,xxDeductionStartDate);

    System.out.println ("cs.setString (3, xxDeductionStartDate is executed);'");

    cs.setString(4,xxDeductionEndDate);

    System.out.println ("cs.setString (4, xxDeductionEndDate is executed);'");

    cs.setDate(3,xxDeductionStartDate);

    cs.setDate(4,xxDeductionEndDate);

    cs.setInt(5,iLoanValue);

    cs.registerOutParameter(1,Types.VARCHAR); / / cs.registerOutParameter(1,Types.NUMERIC);

    DSI Execute();

    outputval = cs.getString (1); / / txn.commit ();

    System.out.println (outputval);

    TXN.Commit ();

    If (outputval. Equals ("S"))

    {

    am.invokeMethod ("apply");

    }

    on the other

    {

    throw new OAException ("is:" + outputval, OAException.INFORMATION name of the Organization);

    }

    TXN.Commit ();

    }

    {} catch (Exception sqle)

    try {}

    DSI Close();

    }

    catch (System.Exception e)

    {

    throw OAException.wrapperException (e);

    }

    throw OAException.wrapperException (sqle);

    }

    }

    Please help where is the error.

    Help, please

    Let me know for any clarification.

    Thank you

    Aravinda.

    Ford Hi,

    See below the code.

    In the controller

    java.sql.Date DeductionSDate; declare the variable

    In LICS

    String xxDeductionStartDate = vo2.getCurrentRow () .getAttribute ("DeductionStartDate");

    TXN OADBTransaction = am.getOADBTransaction ();

    if(xxDeductionStartDate!=null)

    {

    java.sql.Date startDate = txn.getOANLSServices () .stringToDate (xxDeductionStartDate);

    DeductionSDate = startDate;

    }

    Assign to this cs.setDate(3,DeductionSDate);


    Thank you

    Dilip

  • Java Invokeing inside pl/sql

    Dear Experts,

    I wrote the following java program

    import java.sql. *;
    import java. IO;
    Oracle.jdbc import. *;

    public class oracle_java_sync
    {
    Public Shared Sub insertion_via_java (whole deptno,
    Dnom chain,
    String pass)
    throws SQLException
    {
    String sql = "INSERT INTO DEPT VALUES (?,?,?)"; "
    Try
    {
    Connection Conn is DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "Tiger");.
    conn.setAutoCommit (false);
    PreparedStatement myStatement = conn.prepareStatement (sql);
    myStatement.setInt (1, deptno);
    myStatement.setString (2, dname);
    myStatement.setString (3, loc);
    myStatement.executeUpdate ();
    myStatement.close ();
    }
    catch (SQLException e)
    {
    System.Err.println (e.getMessage ());
    }
    }
    }

    After that, I did the following steps
    step 1 > Compilation
    D:\STUDY\play_with_java > javac oracle_java_sync.java

    step 2 > loading
    D:\STUDY\play_with_java > loadjava u scott/talkative tiger@ORCL-oracle_java_sync.java
    arguments: '-u' 'scott/***@ORCL' '-verbose' "oracle_java_sync.java".
    creation: source oracle_java_sync
    loading: source oracle_java_sync
    Loaded classes: 0
    Resources: 0
    Load of sources: 1
    Published Interfaces: 0
    The generated classes: 0
    Classes ignored: 0
    The synonyms created: 0
    Errors: 0

    step 3 > call and appeal
    D:\STUDY\play_with_java > sqlplus

    SQL * more: Production release 11.2.0.1.0 on Sun Oct 14 13:01:30 2012

    Copyright (c) 1982, 2010, Oracle. All rights reserved.

    Enter the user name: scott
    Enter the password:

    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > create or replace
    procedure insertdeptnoviajava (deptno number 2,
    3 dname VARCHAR2,
    loc 4 VARCHAR2
    5)
    6 AS
    JAVA 7 language
    8 name "oracle_java_sync.insertion_via_java (java.lang.String, java.lang.Integer, java.lang.String)";
    9.

    Created procedure.

    SQL > CALL insertdeptnoviajava (25, 'Manufacturing', 'Kolkata');

    Calls made.

    SQL > START
    2 insertdeptnoviajava(25,'Manufacturing','Kolkata');
    3 VALIDATION;
    4 END;
    5.

    After this stage the system is unresponsive.
    The cursor blinks but nothing happens.

    Could you please suggest where something went wrong.

    Concerning
    Mehdi Bhattacharya

    Hi René,.

    I think that this forum should be better for this kind of issues: Java in the Oracle database.

    Coming to your problem, there are several errors.
    Why not try to create the java class in Eclipse or Netbeans? Usually this may help you.

    I have your java class, this line:

     public static void insertion_via_java(Integer deptno,
    

    should be replaced by

     public static void insertion_via_java(int deptno,
    

    Also, you should validate your transaction somewhere:

    myStatement.executeUpdate();
    myStatement.close();
    conn.commit();
    

    Then change your Java stored procedure to reflect the proper types by calling the method (int, java.lang.Integer not):

    CREATE OR REPLACE PROCEDURE insertdeptnoviajava (
       deptno          NUMBER
     , dname           VARCHAR2
     , loc             VARCHAR2)
    AS
       LANGUAGE JAVA
       NAME 'oracle_java_sync.insertion_via_java(int,java.lang.String,java.lang.String)';
    /
    

    Kind regards.
    Al

  • Strange thing in the SQL and PL/SQL

    Hi all

    I meet a very strange thing of the length of the string in SQL and PL/SQL.
    I ran the length of the string SQL and PL/SQL. The output values do not match.
    Can you please help me on how this happens?

    SQL
    select LENGTH ( '!w0n5hn:  0.1 qlpgz-P0h1txtn-tk68-..1tk81-!A_kh0nlw_P0hphn0ln kh0nlw P0hphn0ln
    zyntwm qlpgz – P0h1txtn 0n1 B00n1n – T00xk-..2 pwqt50wmwntn zt0ttn Pwn15nl pwlw0nw
    tk pwfw0wnxw1 Extwnn5hn hf: T00xk ..1 qlpgz-P0h1txtn-tk77-!A_P0hphn0ln_B0hwnw0
    Annhx50tw1 tkpn 
    P05m00y Axth0n 
    zwxhn100y Axth0n 
    gwnx05pt5hn  zx0wwn 1
     
     
     
     
    
    zx0wwn 2
     
     
     
     
     
     
     
     
    
    zx0wwn .
     
     
     
     
     
     
     
     
    
    zx0wwn !
     
     
     
     
     
     
     
     
    
    zx0wwn 5
     
    
    P0w-khn15t5hnn ed Thw tnw0 m0y l0tnxh thw kh0nlw P0hphn0l f0x5l5t5wn hy nwlwxt5nl thw kh0nlw !0ltw ftnxt5hn hn thw p0hphn0ln h0hwnw0
    Phnt khn15t5hnn ed Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 15xt5hn00y xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    eded Thw xh0nlw1 !0ltw 5n nh lhnlw0 0!05l0hlw fh0 nwlwxt5hn 1t05nl 5twm m05ntwn0nxw; thw nyntwm thw0why p0w!wntn thw !0ltw hw5nl 0nn5lnw1 th 0115t5hn0l 5twmn
    edmq Thw xh0nlw1 !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh 5t 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln 
    ed.. Thw xh0nlw1 !0ltw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw xh0nlw x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw xh0nlw !0ltw 150lhl
    ed!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm 0ll 5twmn, 0ll tn0lwn hf thw xh0nlw1 !0ltw 00w, hf xht0nw, 0wmh!wed  Th5n 5nw!5t0hly 0wntltn 5n thw 0wmh!0l hf 0ll p0hphn0ln 5n!hl!5nl thw xh0nlw1 !0ltw 5n 0ll hthw0 xh0nnwln.  Thw 0115t5hn hf 0 nww !0ltw th thwnw 5twmn m0y, hf xht0nw, x0w0tw 0 nww p0hphn0l.  Thwnw p0hphn0ln 00w nht 0tthm0t5x0lly 0tthh05nw1 0n 0 0wntlt hf thw xh0nlw !0ltw 0xt5hn; thwy mtnt hw 01m5n5ntw0w1 hy thw 0pp0hp050tw 0tthh05nw0 5n 0 nwp000tw 0xt5hn
    ed5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    mq Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 mh1tlw, lhx0l Pk h0 !0ltw-p050 xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    mqed Thw xh0nlw1 !0ltw 5tnwlf 5n 0wt05nw1 5n thw 15xt5hn00y
    mqmq Thw !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh thw p0hphn0l (NB. thw p0hphn0l, nht thw !0ltw) 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln.  In thw x0nw hf !0ltw-p050 p0hphn0ln, hnly thw p0hphn0l !0ltw th0t w0n nwlwxtw1 5n thw p0hphn0ln h0hwnw0 m0y hw xh0nlw1 (5f thw tnw0 w5nhwn th xh0nlw thw hthw0 !0ltw 5n thw p050, thwy mtnt 0xxwnn thw n0mw p050 p0hphn0l !50 th0t !0ltw 5n thw p0hphn0ln h0hwnw0)
    mq.. Thw tn0lw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw 0wjwxt5hn x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw 0wjwxt5hn 150lhl.  Thw 0wpl0xwmwnt !0ltw th0t w0n 0ppl5w1 5n thw xh0nlw 5n 0lnh 0wxh01w1 pw0m0nwntly, nh th0t th5n x0n hw 15npl0yw1 th tnw0n whw0w 0pp0hp050tw 1t05nl 5twm xh15nl 0xt5!5ty
    mq!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm nhmw 5twmn, hthw0 tn0lwn hf thw !0ltw m0y 0lnh hw 0wmh!wed  If th5n 5n thw x0nw, 0n1 5f thwnw tn0lwn 00w 0lnh p0hphn0ln, th5n 0lnh 0wntltn 5n thw 0wmh!0l hf p0hphn0ln 5n!hl!5nl thw !0ltw 5n hthw0 tn0lw xh0nnwln (5t 5n w!wn 0 0wmhtw phnn5h5l5ty th0t xh0nl5nl 0 lhx0l Pk p0hphn0l m0y 0wmh!w 0 tn0lw 0n1 p0hphn0l fh0 thw n0mw !0ltw 5n 0nhthw0 lhx0l Pk; n5m5l00ly xh0nl5nl 0 !0ltw p050 m0y 0wmh!w hthw0 !0ltw-p050 tn0lwn/p0hphn0ln).  z5m5l00ly, thw 0115t5hn hf 0 nww !0ltw th 5twmn 0n 0 0wntlt hf thw xh0nlw 0xt5hn, m0y lwnw00tw nww p0hphn0ln 5n 0ny tn0lw xh0nnwl
    mq5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    .. zww 5mplwmwnt0t5hn nhtwn hwlhw, tn1w0 “pwl0tw1 Infh0m0t5hn” 
    B0n5x Flhw 
     fl1l1fl1fl;lj0n1khfh0njkfhzgJKkf xhy0w0ttj 0nwhtj5y0w0hlwfklj0w0lklt5h5hn1fhlj1fhljn1fhlj1fhljwj50w0ytlt5w0j0w5t5
    ztfl!n1fllw0t!qww0wh00wwjh0f0n1jfhn1jkkwjhqw5t! tjt5w0yttwn1fln1ln1fn1') from dual;
    Here, I got an error like
    ORA-01704: string literal too long
    01704. 00000 -  "string literal too long"
    *Cause:    The string literal is longer than 4000 characters.
    *Action:   Use a string literal of at most 4000 characters.
               Longer values may only be entered using bind variables.
    Error at Line: 1 Column: 16
    But in PL/SQL,.
    BEGIN
         dbms_output.put_line(LENGTH ( '!w0n5hn:  0.1 qlpgz-P0h1txtn-tk68-..1tk81-!A_kh0nlw_P0hphn0ln kh0nlw P0hphn0ln
    zyntwm qlpgz – P0h1txtn 0n1 B00n1n – T00xk-..2 pwqt50wmwntn zt0ttn Pwn15nl pwlw0nw
    tk pwfw0wnxw1 Extwnn5hn hf: T00xk ..1 qlpgz-P0h1txtn-tk77-!A_P0hphn0ln_B0hwnw0
    Annhx50tw1 tkpn 
    P05m00y Axth0n 
    zwxhn100y Axth0n 
    gwnx05pt5hn  zx0wwn 1
     
     
     
     
    
    zx0wwn 2
     
     
     
     
     
     
     
     
    
    zx0wwn .
     
     
     
     
     
     
     
     
    
    zx0wwn !
     
     
     
     
     
     
     
     
    
    zx0wwn 5
     
    
    P0w-khn15t5hnn ed Thw tnw0 m0y l0tnxh thw kh0nlw P0hphn0l f0x5l5t5wn hy nwlwxt5nl thw kh0nlw !0ltw ftnxt5hn hn thw p0hphn0ln h0hwnw0
    Phnt khn15t5hnn ed Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 15xt5hn00y xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    eded Thw xh0nlw1 !0ltw 5n nh lhnlw0 0!05l0hlw fh0 nwlwxt5hn 1t05nl 5twm m05ntwn0nxw; thw nyntwm thw0why p0w!wntn thw !0ltw hw5nl 0nn5lnw1 th 0115t5hn0l 5twmn
    edmq Thw xh0nlw1 !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh 5t 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln 
    ed.. Thw xh0nlw1 !0ltw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw xh0nlw x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw xh0nlw !0ltw 150lhl
    ed!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm 0ll 5twmn, 0ll tn0lwn hf thw xh0nlw1 !0ltw 00w, hf xht0nw, 0wmh!wed  Th5n 5nw!5t0hly 0wntltn 5n thw 0wmh!0l hf 0ll p0hphn0ln 5n!hl!5nl thw xh0nlw1 !0ltw 5n 0ll hthw0 xh0nnwln.  Thw 0115t5hn hf 0 nww !0ltw th thwnw 5twmn m0y, hf xht0nw, x0w0tw 0 nww p0hphn0l.  Thwnw p0hphn0ln 00w nht 0tthm0t5x0lly 0tthh05nw1 0n 0 0wntlt hf thw xh0nlw !0ltw 0xt5hn; thwy mtnt hw 01m5n5ntw0w1 hy thw 0pp0hp050tw 0tthh05nw0 5n 0 nwp000tw 0xt5hn
    ed5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    mq Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 mh1tlw, lhx0l Pk h0 !0ltw-p050 xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    mqed Thw xh0nlw1 !0ltw 5tnwlf 5n 0wt05nw1 5n thw 15xt5hn00y
    mqmq Thw !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh thw p0hphn0l (NB. thw p0hphn0l, nht thw !0ltw) 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln.  In thw x0nw hf !0ltw-p050 p0hphn0ln, hnly thw p0hphn0l !0ltw th0t w0n nwlwxtw1 5n thw p0hphn0ln h0hwnw0 m0y hw xh0nlw1 (5f thw tnw0 w5nhwn th xh0nlw thw hthw0 !0ltw 5n thw p050, thwy mtnt 0xxwnn thw n0mw p050 p0hphn0l !50 th0t !0ltw 5n thw p0hphn0ln h0hwnw0)
    mq.. Thw tn0lw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw 0wjwxt5hn x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw 0wjwxt5hn 150lhl.  Thw 0wpl0xwmwnt !0ltw th0t w0n 0ppl5w1 5n thw xh0nlw 5n 0lnh 0wxh01w1 pw0m0nwntly, nh th0t th5n x0n hw 15npl0yw1 th tnw0n whw0w 0pp0hp050tw 1t05nl 5twm xh15nl 0xt5!5ty
    mq!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm nhmw 5twmn, hthw0 tn0lwn hf thw !0ltw m0y 0lnh hw 0wmh!wed  If th5n 5n thw x0nw, 0n1 5f thwnw tn0lwn 00w 0lnh p0hphn0ln, th5n 0lnh 0wntltn 5n thw 0wmh!0l hf p0hphn0ln 5n!hl!5nl thw !0ltw 5n hthw0 tn0lw xh0nnwln (5t 5n w!wn 0 0wmhtw phnn5h5l5ty th0t xh0nl5nl 0 lhx0l Pk p0hphn0l m0y 0wmh!w 0 tn0lw 0n1 p0hphn0l fh0 thw n0mw !0ltw 5n 0nhthw0 lhx0l Pk; n5m5l00ly xh0nl5nl 0 !0ltw p050 m0y 0wmh!w hthw0 !0ltw-p050 tn0lwn/p0hphn0ln).  z5m5l00ly, thw 0115t5hn hf 0 nww !0ltw th 5twmn 0n 0 0wntlt hf thw xh0nlw 0xt5hn, m0y lwnw00tw nww p0hphn0ln 5n 0ny tn0lw xh0nnwl
    mq5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    .. zww 5mplwmwnt0t5hn nhtwn hwlhw, tn1w0 “pwl0tw1 Infh0m0t5hn” 
    B0n5x Flhw 
     fl1l1fl1fl;lj0n1khfh0njkfhzgJKkf xhy0w0ttj 0nwhtj5y0w0hlwfklj0w0lklt5h5hn1fhlj1fhljn1fhlj1fhljwj50w0ytlt5w0j0w5t5
    ztfl!n1fllw0t!qww0wh00wwjh0f0n1jfhn1jkkwjhqw5t! tjt5w0yttwn1fln1ln1fn1') );
    END;
    I got the value as 3969.

    I tried with the same string. I know that the maximum length of the SQL string is 4000 and PL/SQL is 32767. but the thing is when am a length of the string in PL/SQL as less than 4000, then iwhy must not be run alongside SQL?

    Can you help me out on this issue?

    DB: Oracle 11g Release 2

    Thank you and best regards,
    Suresh.

    Suresh Mohan says:

    Outside chr (256), are there other characters of white space available?

    White space characters are listed on http://en.wikipedia.org/wiki/Whitespace_character.

    From the point of view of the old MS-MS-BACK/ASCII characters, a white space character was #256 as the chariot of normal space was #32. He was also a space compared to a difficult space.

    You need to look at the character set you use - ASCII is a set of characters in a single byte, and not the same thing.

    You can use the SQL DUMP() function to watch the characters in a string. For example

    select dump( my_string_column ) from my_table where ...
    
  • SQL in the command with the parameter

    Hello

    When I tried to run this query, it returns the empty data set.did I missed something or is - it is not allowed to use?

    SQL:

    String sql ="select * from customer where customerId in (?) » ;
    objConnection = super.getConnection ();

    = objConnection.prepareStatement (sql) stmt1;
    stmt1. SetString (1, id); Here id format will be ('100', '102'...)

    resultSet = stmt1.executeQuery ();

    Thanks in advance.

    You mean something like...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select *
      2  from emp
      3  where ename in (
      4    with t as (select '&input_string' as txt from dual)
      5    select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
      6    from t
      7    connect by level <= length(regexp_replace(txt,'[^,]*'))+1
      8*   )
    SQL> /
    Enter value for input_string: SCOTT,JAMES
    old   4:   with t as (select '&input_string' as txt from dual)
    new   4:   with t as (select 'SCOTT,JAMES' as txt from dual)
    
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
          7788 SCOTT      ANALYST         7566 19-04-1987 00:00:00       3000                    20
          7900 JAMES      CLERK           7698 03-12-1981 00:00:00        950                    30
    
    SQL>
    
  • ORA-01830Date end of photo format before converting all of the input string

    Hi guys,.

    We have two env db a dev and AQ. Both the envs are running on the same version of database and in both the setting nls_date_format envs are the same and they are 'DD-MON-YY' format only. But when I execute the same statement immediately following my dev env is fetching data appropriate without any problem but my env qa is any mistake on the mentioned error.

    I enclose the suite that I use

    SELECT TPTRJO1. JOURNAL_ENTRY_ID
    OF TRANSACTION_JOURNAL TPTRJO1,.
    JOURNAL_CASH_DRAWER TPJCD1
    WHERE (TPJCD1. CASH_DRAWER_ID = 5010639.0)
    AND (TPJCD1. DRAWER_SEQ = 5.0)
    AND (TPJCD1. CASH_DRAWER_DATE = TO_DATE ('2011-09-13 00:00:00 ', 'yyyy-MM-dd'))

    AND (TPTRJO1. JOURNAL_ENTRY_ID = TPJCD1. JOURNAL_ENTRY_ID)
    AND (TPTRJO1. TRANSACTION_ID = 595,0)

    However, according to the logic, it should error in both the envs due date format and the actual data used in the entry.

    What would be the possible difference between the envs db towing?

    Please, share your ideas.
    Any suggestions are appreciated.

    Thank you and waiting for an early response

    I assume that you have given in your dev environment.
    If there is a record with TPJCD1. CASH_DRAWER_ID = 5010639.0,
    the expression ' TO_DATE ('2011-09-13 00:00:00 ', 'yyyy-MM-dd').
    will never be evaluated.

    Here is my test scenario where '1 = 0' prevents the date under evaluation:

    SQL>SELECT *
      2    FROM all_objects
      3   WHERE created > TO_DATE('2011-09-13 00:00:00', 'yyyy-MM-dd');
     WHERE created > TO_DATE('2011-09-13 00:00:00', 'yyyy-MM-dd')
                             *
    ERROR at line 3:
    ORA-01830: date format picture ends before converting entire input string
    
    SQL>
    SQL>SELECT *
      2    FROM all_objects
      3   WHERE 1 = 0 AND created > TO_DATE('2011-09-13 00:00:00', 'yyyy-MM-dd');
    
    no rows selected
    

    URS

  • Through a set of query results, replacing one string by another.

    I want to write a function that replaces the occurrence of a string with another string different.  I need to be a CF fuction which can be called from another function CF.  I want to 'hand' this function (a string) SQL statement like this: (Please note, don't bother commenting "there are ways of writing this SQL try..., I made this simple example to get to the point where I need help.)  I have to use a 'sub_optimal' SQL syntax just to demonstrate the situation)

    Here's the string I want to pass to the function:

    SELECT

    [VERYLONGTABLENAME]. FIRST NAME,

    [VERYLONGTABLENAME]. LAST_NAME,

    [VERYLONGTABLENAME]. ADDRESS

    Of

    LONGTABLENAME [VERYLONGTABLENAME]

    Here are the contents of the ABRV table:

    TBL_NM, ABRV <! - header line - >

    VERYLONGTABLENAME, VLTN

    SOMEWHATLONGTALBENAME, SLTN

    MYTABLENAME, MTN

    ATABLENAME, ATN

    The function returns the string origin, but with the abbreviations in place names of the long table, example:

    SELECT

    VLTN. FIRST NAME,

    VLTN. LAST_NAME,

    VLTN. ADDRESS

    Of

    LONGTABLENAME VLTN

    Notice that only the table brackets and names that match a value in the table ABRV were replaced.  The LONGTABLENAME immediately following the FROM is left as is.

    Now, here's my attempt at amateur said written dum function: Please look at the comment lines for where I need help.

    < name cffunction output = "AbrvTblNms" = "false" access = "remote" returntype = "string" >
    < name cfargument = "txt" type = "string" required = "true" / >

    < cfset var qAbrvs = "" > <! - variable to hold the results of the query - >

    < cfset var output_str = "#txt #" > <!-I create a local variable so I can manipulate the data returned by the parameter TXT.  Is it necessary or can I use the parameter txt? ->


    < cfquery name = "qAbrvs" datasource = result "cfBAA_odbc" = "rsltAbrvs" >
    SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
    < / cfquery >

    <!-I'm assuming that at this point, the query is executed and records in the result-> set

    < cfloop index = list "idx_str" = "#qAbrvs #" > <! - is - right?  I do not. ->
    < cfset output_str = Replace (output_str, "#idx_str #",) <! - is - right?  I do not. ->

    < / cfloop > <!-who am I loop on?  What is the index? How to do the replacement of the chain? ->

    <!-the chunck, below is a partial of my Object Pascal from Delphi function that does the same thing

    I need to know how to write this part in CF9
    So what not of folklore
    Start
    s: = StringReplace (s, ' [' + FieldByName('TBL_NM').]) [AsString + ']', FieldByName ('ABRV'). AsString, [rfReplaceAll]);
    Following;
    end;
    ->

    < cfreturn output_txt >

    < / cffunction >

    I am mostly struggling with the syntax here.  I know what I want to do, I know how to get there in a different programming language, just not CF9.  Thanks for any help you can provide.

    RedOctober57 wrote:

    ...
    Thanks for any help you can provide.

    One:

     

    No you need not create a local variable that is a copy of the variable arguments that the scope of the arguments is already local to the function, but you are not referencing correctly the scope of the arguments, then you may be using a variable 'txt' in another scope.  So best practice would be to refer to "arguments.txt" where you must.

    Two:

    I know what I want to do, I know how to get there in a different programming language, just not CF9.

    Then a best start would be to descirbe what you want to happen and give a simple example in the other programming language.  Most of us is muti-lingual and can analyze code in any clear and clean syntax.

    Three:

         

    I think you want to be a loop on your recordset returned by the previous query, perhaps 'qAbrvs '.

    
    

    Four:

    Continuing on this assumption I suppose you want to replace each instance of the long chain with the short form string that record together.

    
    

    Five:

                  

    If this is true, then you loop through the set of records from tablenames and abbreviations that you want to replace the chain.

Maybe you are looking for

  • How to install a window URL

    I disabled addons, is returned to the default value of Firefox and looked at some of the other solutions that relate to the windows of the URL. Nothing seems to work. I get search windows that take me to the wrong places but no window simple URL that

  • Satellite P100 - 429 LAN wireless has stopped working

    I had a satellite P100-429 during about three weeks, the wireless card was working fine until yesterday. Today I turned on the laptop, but I can't connect to my access point. In fact the laptop can now find any wireless network at all. Can anyone hel

  • 17-f151nm Pavilion: Pavilion 17-f151nm hardware upgrade

    Hello, I have a Pavilion 17-f151fm, K6Z65EA #BED product number if that's any help. I'm looking to upgrade of hardware a bit but I find different information about the hardware so I'm in doubt a little bit what to do. This laptop has two slots of RAM

  • Upgrade from previous version of XP Win7

    I am trying to upgrade one of my PC to Win7 but I get an error code indicating that it is impossible to move from the current operating system. Any ideas?

  • missing disk-need food support

    Original title: recovery disk I need to reformat my computer (windows xp).  I do not have the computer recovery disc but I from my laptop.  Can I use these discs, or should they be on the computer, I'm trying? Woody