国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

CSV to array

Jun 07, 2016 pm 02:54 PM
array csv sql string Truncate array

將CSV的字符串 截斷成相應的 字符串值數(shù)組 PL/SQL jQuery CSV function csv_to_array (p_csv_line in varchar2, p_separator in varchar2 := g_default_separator) return t_str_arrayas type t_str_array as table of varchar2(4000); l_returnvalue t_str_a

將CSV的字符串
截斷成相應的 字符串值數(shù)組 PL/SQL jQuery CSV
function csv_to_array (p_csv_line in varchar2,
                       p_separator in varchar2 := g_default_separator) return t_str_array
as
  type t_str_array as table of varchar2(4000);
  l_returnvalue      t_str_array     := t_str_array();--返回的字符串數(shù)組類型
  l_start_separator  pls_integer     := 0 ;
  l_stop_separator   pls_integer     := 0 ;
  l_length           pls_integer     := 0 ;--長度
  l_idx              binary_integer  := 0 ;
  l_quote_enclosed   boolean         := false ;
  l_offset           pls_integer     := 1 ;
begin

  /*

  Purpose:      convert CSV line to array of values

  Remarks:      based on code from http://www.experts-exchange.com/Database/Oracle/PL_SQL/Q_23106446.html

  Who     Date        Description
  ------  ----------  --------------------------------
  MBR     31.03.2010  Created
  fartpig 07.03.2011  noted

  */
  /*
  相應的CSV中的注意 就是關于 "" 中包含分隔符 ,的情況,需要通過標記 是否有雙引號的 變量來進行掃描查找 
  同時保存三個掃描量:掃描開始位置(掃描頭),掃描結束位置(掃描尾),掃描偏移量(用來標記掃描的偏移)
  */
  --獲得長度
  l_length := length(p_csv_line) ;

  if l_length > 0 then
    loop
      --遞增 標記的數(shù)據(jù)下標
      l_idx := l_idx + 1;

      l_quote_enclosed := false;
      --判斷開始分割的 下一個字符是否是 "
      if substr(p_csv_line, l_start_separator + 1, 1) = '"' then
        --如果是 標記其 有雙引號
        l_quote_enclosed := true;
        --設定 掃描偏移單位為 2
        l_offset := 2;
        --查找 下一個雙引號的位置
        l_stop_separator := instr(p_csv_line, '"', l_start_separator + l_offset, 1);
      else
        --如果沒有 雙引號 
        --設定 掃描偏移單位為 1
        l_offset := 1;
        --查找 下一個 分割符 的位置
        l_stop_separator := instr(p_csv_line, p_separator, l_start_separator + l_offset, 1);
      end if;
      --如果 沒有找到 掃描的下一個 位置
      if l_stop_separator = 0 then
        --設定 掃描的下一個位置為  總長度+1 從而推出循環(huán)
        l_stop_separator := l_length + 1;
      end if;
      --將 掃描得到的 值 保存到數(shù)組中
      l_returnvalue.extend;      
      l_returnvalue(l_idx) := substr(p_csv_line, l_start_separator + l_offset, (l_stop_separator - l_start_separator - l_offset));
      --如果掃描到頭 就推出循環(huán)
      exit when l_stop_separator >= l_length;
      --如果有 雙引號
      if l_quote_enclosed then
        --將掃描位置 +1 從而過濾掉"
        l_stop_separator := l_stop_separator + 1;
      end if ;
      --標記 掃描的開始位置 為 掃描到的位置
      l_start_separator := l_stop_separator;
    end loop;

  end if;
  -- 返回結果
  return l_returnvalue;

end csv_to_array;
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
PHP get the first N characters of a string PHP get the first N characters of a string Jul 11, 2025 am 03:17 AM

You can use substr() or mb_substr() to get the first N characters in PHP. The specific steps are as follows: 1. Use substr($string,0,N) to intercept the first N characters, which is suitable for ASCII characters and is simple and efficient; 2. When processing multi-byte characters (such as Chinese), mb_substr($string,0,N,'UTF-8'), and ensure that mbstring extension is enabled; 3. If the string contains HTML or whitespace characters, you should first use strip_tags() to remove the tags and trim() to clean the spaces, and then intercept them to ensure the results are clean.

PHP get the last N characters of a string PHP get the last N characters of a string Jul 11, 2025 am 03:17 AM

There are two main ways to get the last N characters of a string in PHP: 1. Use the substr() function to intercept through the negative starting position, which is suitable for single-byte characters; 2. Use the mb_substr() function to support multilingual and UTF-8 encoding to avoid truncating non-English characters; 3. Optionally determine whether the string length is sufficient to handle boundary situations; 4. It is not recommended to use strrev() substr() combination method because it is not safe and inefficient for multi-byte characters.

How to create empty tables with the same structure as another table? How to create empty tables with the same structure as another table? Jul 11, 2025 am 01:51 AM

You can use SQL's CREATETABLE statement and SELECT clause to create a table with the same structure as another table. The specific steps are as follows: 1. Create an empty table using CREATETABLEnew_tableASSELECT*FROMexisting_tableWHERE1=0;. 2. Manually add indexes, foreign keys, triggers, etc. when necessary to ensure that the new table is intact and consistent with the original table structure.

How to Check if an Array Includes a Value in JavaScript How to Check if an Array Includes a Value in JavaScript Jul 13, 2025 am 02:16 AM

In JavaScript, check whether an array contains a certain value. The most common method is include(), which returns a boolean value and the syntax is array.includes(valueToFind), for example fruits.includes('banana') returns true; if it needs to be compatible with the old environment, use indexOf(), such as numbers.indexOf(20)!==-1 returns true; for objects or complex data, some() method should be used for in-depth comparison, such as users.some(user=>user.id===1) returns true.

How to convert a string to uppercase or lowercase in C  ? How to convert a string to uppercase or lowercase in C ? Jul 19, 2025 am 01:34 AM

InC ,stringscanbeconvertedtouppercaseorlowercasebyprocessingeachcharacterusingstd::toupperorstd::tolowerfrom1.Casteachcharactertounsignedcharbeforeapplyingthefunctiontoavoidundefinedbehavior.2.Modifycharactersinplaceorcopythestringifpreservingtheori

How to find the Nth highest value in a SQL column? (e.g., second highest salary) How to find the Nth highest value in a SQL column? (e.g., second highest salary) Jul 12, 2025 am 01:58 AM

There are three common methods to find the Nth highest value of a column in SQL. 1. Use subquery and LIMIT/OFFSET: First sort the target column in descending order, skip the first N-1 record and then take one. It is suitable for simple scenarios but may affect performance; 2. Exclude maximum values ??layer by layer through nested subqueries: the logic is clear but the structure is complex when the hierarchy increases; 3. Use DENSE_RANK or ROW_NUMBER window function (recommended): Flexible processing of duplicate values, supports precise ranking, suitable for database environments that support window functions. Which method to choose depends on the specific database type, data volume and structural requirements.

How to iterate over a string in Python How to iterate over a string in Python Jul 14, 2025 am 02:04 AM

There are many ways to traverse strings in Python, depending on the requirements. First, using a for loop, you can directly access characters one by one: s="hello", forcharins:print(char), and each character will be output in turn. Secondly, if you need index information, you can combine the enumerate() function: s="hello", forindex,charinenumerate(s):print(f"Position{index}:{char}"), so as to obtain the characters and their positions at the same time. In addition, list comprehension is suitable for batch processing of characters

Relational Database Design Principles for SQL Developers Relational Database Design Principles for SQL Developers Jul 21, 2025 am 01:56 AM

When designing a relational database, four key principles should be followed. First, correctly use primary and foreign key constraints to ensure data integrity and association accuracy; second, perform standardized design reasonably, usually reaching the third normal form (3NF), eliminating redundancy and ensuring data consistency; third, establishing appropriate indexes for common queries to improve query performance but avoid over-index; finally, using consistent naming specifications and structural styles to enhance readability and maintainability. Mastering these principles can help build a clear, efficient and robust database structure.

See all articles