如何从varchar形式的数字中删除前导零.我尝试过以下方法:
选项1:
insert into example_table (columnName)
(SELECT
SUBSTR(columnName2, InStr('%[^0 ]%', columnName2 + ' '), 10)
from columnName2);
Run Code Online (Sandbox Code Playgroud)
有了这个,我得到的错误是
SQL Error: ORA-01722: invalid number
ORA-02063: preceding line from xxxx
01722. 00000 - "invalid number"
Run Code Online (Sandbox Code Playgroud)
选项2:
insert into example_table (columnName)
(SELECT
SUBSTR(columnName2, InStr('%[^0 ]%', columnName2 + ' '),
LEN(columnName2))
from columnName2);
Run Code Online (Sandbox Code Playgroud)
这次我得到了
Error at Command Line:23 Column:87
Error report:
SQL Error: ORA-00904: "LEN": invalid identifier
Run Code Online (Sandbox Code Playgroud)
选项3:
SUBSTRING
(columnName2, PATINDEX('%[^0 ]%', columnName2 + ' '), 10));
Run Code Online (Sandbox Code Playgroud)
与上面类似,我得到了
Error at Command Line:23 Column:41
Error …Run Code Online (Sandbox Code Playgroud) 我目前正在上课学习elisp,所以我没有这种语言的经验.我试图交互式地读入两个输入(矩形的宽度和长度),然后使用它们来调用函数来计算矩形的面积.我的代码如下:
(defun rectangle_Area(w l)
"Compute the area of a rectangle, given its width and length interactively."
(interactive "nWidth: ")
(interactive "nLength: ")
(setq area (rectangleArea w l))
(message "The rectangle's area is %f." area))
Run Code Online (Sandbox Code Playgroud)
目前我得到错误的参数数量错误.就像我说的,我以前没有经验......我真正需要知道的是如何使用交互式存储/读取两个单独的值.
感谢您的任何帮助
我有一个关于AWK命令的快速问题.我需要打印命令直到同一行的行结束,但是当它到达下一行时,我需要它在另一行上打印.以下示例将提供更好的清晰度.
说我有一个文件:
0 1 2 3 This is line one
0 1 2 3 This is line two
0 1 2 3 This is line three
0 1 2 3 This is line four
Run Code Online (Sandbox Code Playgroud)
我尝试了以下内容并获得了以下结果
awk '{for(i=5;i<=NF;i++) print $i}' fileName >> resultsExample1
Run Code Online (Sandbox Code Playgroud)
我在resultsExample1中得到以下内容
This
is
line
one
This
is
line
two
And so on....
Run Code Online (Sandbox Code Playgroud)
例2:
awk 'BEGIN {" "} {for(i=5;i<=NF;i++) printf $1}' fileName >> resultsExample2
Run Code Online (Sandbox Code Playgroud)
for resultsExample2我得到:
This is line one This is line two this is line three This …Run Code Online (Sandbox Code Playgroud) 我是Ada的新手,目前正在尝试编写一个涉及if-else if语句的简单程序.代码如下:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Year_Codes is
Year : String(1..9) := " ";
CharsRead : Natural;
function YearCode(Name : in String) return Integer is
begin
if(Name = "freshman")then
return 1;
elsif(Name = "sophomore")then
return 2;
elsif(Name = "junior")then
return 3;
elsif(Name = "senior")then
return 4;
else
return 0;
end if;
end YearCode;
begin
Put("Enter your academic year: "); -- Prompt for input
Get_Line(Year, CharsRead); -- Input
Put( YearCode(Year) ); -- Convert and output
New_Line; …Run Code Online (Sandbox Code Playgroud) 我试图将字符串"5/23/14 02:23:24"从Eclipse中的String转换为要插入到SQL语句中的Date.我的代码如下:
String dateAndTime = "5/23/14 02:23:24";
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
Date date = sdf.parse(dateAndTime);
long dateLong = date.getTime();
insertStatement.setDate(1, new java.sql.Date(dateLong));
Run Code Online (Sandbox Code Playgroud)
我希望看到
23-MAY-2014 2.23.24.000000000 PM
Run Code Online (Sandbox Code Playgroud)
在我的桌子上,但我看到了
23-MAY-2014 12.00.00.000000000 AM
Run Code Online (Sandbox Code Playgroud)
谁能说清楚我做错了什么?
谢谢!