小编Jim*_*mmy的帖子

SQL,删除行尾的逗号外观

我的数据如下

MyText
-------
some text, some more text, even more text,,
some text,,,,
some text, some text,,,
some text, some more text, even more, yet more, and again
Run Code Online (Sandbox Code Playgroud)

我想实现:

MyText
-------
some text, some more text, even more text
some text
some text, some text
some text, some more text, even more, yet more, and again
Run Code Online (Sandbox Code Playgroud)

如何删除行尾的逗号?我必须保留项目之间的逗号,但我需要删除任何项目

我需要在select语句中执行此操作,并且我无法在不编写函数的情况下找到应用RegEx的解决方案(我希望避免使用)

我有一个解决方案,但它特别脏,我想改进它.我正在使用一组嵌套的REPLACE替换4个逗号,3个用3个替换,2个用一个替换,然后删除一个

有任何想法吗?

编辑:数据来自外部系统,所以我无法控制,否则我会在第一个实例中正确连接逗号.我正在使用的这个语句将在SQL Server 2005上运行

sql sql-server replace

3
推荐指数
1
解决办法
1万
查看次数

修改按钮时onResume中的NullPointerException,为什么?

我从一些用户那里得到了一个N​​ullPointerException,我无法发现问题所在,它被抛到了这一行:

((Button)findViewById(R.id.speakEnglishButton)).setText("");

我无法看到有什么问题,该按钮存在该Id,它编译得很好,在我的模拟器和2个设备上正常工作,但是我在我的开发者控制台中为这个用户发布了大约100个左右的错误版.

仔细观察onResume:

@Override
protected void onResume()
{
    super.onResume();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isButtonLabelsEnabled = sp.getBoolean("isButtonLabelsEnabled", false);
    if (!isButtonLabelsEnabled)
    {
        ((Button)findViewById(R.id.speakEnglishButton)).setText("");
        ((Button)findViewById(R.id.speakFrenchButton)).setText("");
        ((Button)findViewById(R.id.speakSpanishButton)).setText("");
        ((Button)findViewById(R.id.speakGermanButton)).setText("");
        ((Button)findViewById(R.id.speakItalianButton)).setText("");
    }
    else
    {
        ((Button)findViewById(R.id.speakEnglishButton)).setText(getString(R.string.btnLblEnglish));
        ((Button)findViewById(R.id.speakFrenchButton)).setText(getString(R.string.btnLblFrench));
        ((Button)findViewById(R.id.speakSpanishButton)).setText(getString(R.string.btnLblSpanish));
        ((Button)findViewById(R.id.speakGermanButton)).setText(getString(R.string.btnLblGerman));
        ((Button)findViewById(R.id.speakItalianButton)).setText(getString(R.string.btnLblItalian));
    }
}
Run Code Online (Sandbox Code Playgroud)

基本上,我正在做的是检查保存的首选项布尔值,并根据其值,我要么在按钮上设置标签,要么将它们设置为空白.

任何人都可以建议吗?

谢谢

android android-ui android-2.1-eclair android-activity

3
推荐指数
1
解决办法
4295
查看次数

Python,如何在与文本消息相同的行上打印当前日期时间?

这里有Python的初步经验,我希望能够打印出一些当前时间/日期作为第一项的文本.

到目前为止,这是我能够做到的,但看起来我在语法上是不正确的,有人可以帮我纠正吗?

import socket
import sys
import time
import datetime

remote_host = "127.0.0.1"

now = datetime.datetime.now()

for remote_port in [9002,8080]:
        now_text = now.strftime("%Y-%m-%d %H:%M")
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(60)
        try:
                sock.connect((remote_host, remote_port))
        except Exception,e:
                print "%d %d closed " % now_text remote_port
        else:
                print  "%d %d open" % now_text remote_port
        sock.close()
Run Code Online (Sandbox Code Playgroud)

亲切的问候

python python-2.4

2
推荐指数
1
解决办法
4017
查看次数

可以使用GROUP BY或HAVING改进这个简单的选择吗?

我有以下参考数据.

STORE_CODE      SUPPLIER_CODE
------          ------
ASDA            A3
ASDA            A2
TESCO           A2
TESCO           A4
ASDA            A4
ASDA            A4
ASDA            A4
ASDA            A4
WAITROSE        A3
ASDA            A4
WAITROSE        A3
ASDA            A3
ASDA            A3
ASDA            A4
SAINSBURY       A2
SAINSBURY       A2
SAINSBURY       A6
TESCO           A6
ASDA            A3
TESCO           A3
TESCO           A3
SAINSBURY       A3
WAITROSE        A5
WAITROSE        A5
WAITROSE        A5
WAITROSE        A4
ALDI            A1
ALDI            A1
ALDI            A1
ALDI            A1
ALDI            A1
ALDI            A1
ALDI            A1
ALDI            A1
Run Code Online (Sandbox Code Playgroud)

我想要做的是显示一个供应商列表,这些供应商至少有4个与之关联的独特商店.

到目前为止,这是我所结合的:

SELECT 
    distinct stoc.supplier_code as SUPPLIER_CODE …
Run Code Online (Sandbox Code Playgroud)

sql oracle select oracle10g

2
推荐指数
1
解决办法
105
查看次数

你能在SELECT语句中使用ascii代码吗?特别是SOH角色

我有以下简单的select语句:

select 'hello' || '|' || 'world' as MYVALUE from dual;

这给了我2个单词,由管道分隔.

我想换掉管道分隔器以换取其他东西,例如Ascii SOH字符.

如何在select语句中使用ascii代码,例如\u01

oracle select ascii oracle11g

2
推荐指数
1
解决办法
1971
查看次数

如何在iOS上的块中显示UIAlertView?

从块中显示UIAlertView的最佳方法是什么?

我的代码中有以下操作:

- (IBAction)connectWithTwitterClicked:(id)sender {
    ACAccountStore * account = [[ACAccountStore alloc]init];
    ACAccountType * accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
        if (granted == YES){
            NSLog(@"Twitter account has been granted");
            NSArray * arrayOfAccounts = [account accountsWithAccountType:accountType];
            if([arrayOfAccounts count] > 0){
                ACAccount * twitterAccount = [arrayOfAccounts lastObject];
                NSLog(@"Found twitter Id of [%@]", twitterAccount.username);
                // continue on to use the twitter Id
            } else {
                // no twitter accounts found, display alert to notify user
            }
        } else{ …
Run Code Online (Sandbox Code Playgroud)

twitter objective-c ios objective-c-blocks ios6

2
推荐指数
2
解决办法
3848
查看次数

您可以将Android应用程序部署到Google App Engine吗?

是否可以将Android应用程序部署到谷歌应用程序引擎环境?即将它部署到appspot?

如果没有,是否有任何类型的"容器"可以让人这样做?

我想创建一个可以部署在android和基于Web的环境中的应用程序

google-app-engine android

1
推荐指数
1
解决办法
565
查看次数

AndroidManifest.xml中; 无法包含外部库

我正在关注Android网站上的MapView教程

[2010-08-22 11:12:24 - com.android.ide.eclipse.adt.internal.project.AndroidManifestParser] Parser exception for /MeCercana/AndroidManifest.xml: Open quote is expected for attribute "android:name" associated with an  element type  "uses-library".
[2010-08-22 11:12:24 - MeCercana] Error in an XML file: aborting build.
Run Code Online (Sandbox Code Playgroud)

我按照说明复制了外部Maps API,我的XML文件如下所示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.jameselsey"
      android:versionCode="1"
      android:versionName="1.0">
  <uses-permission android:name="android.permission.INTERNET" /> 
    <application android:icon="@drawable/icon" android:label="@string/app_name">   
       <uses-library android:name=”com.google.android.maps” />          
        <activity android:name=".Mecercana"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest> 
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试编译并运行时,我得到以下错误

我无法看到我的XML出了什么问题?

android android-manifest

1
推荐指数
1
解决办法
7167
查看次数

如何从Oracles JSON CLOB类型的JSON数组中选择特定元素

我有一个CLOB列,其中包含以下数据(为了解决此问题而简化)

{
    "notUsed": [],
    "stock": [
        {
            "name": "eggs",
            "value": "in stock"
        },
        {
            "name": "milk",
            "value": "out of stock"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我想避免必须选择整个对象并以编程方式解析以获取我想要的数据.理想情况下,我想利用Oracle JSON路径功能来实现这一目标.

我想得到"value",在哪里"name" = "eggs"

我试过以下,但得到了一个[99999][40442] ORA-40442: JSON path expression syntax error.我已通过评估程序运行上面的示例JSON和JSON路径,并返回所需的结果,这让我觉得Oracle拥有自己的JSONPath解释

SELECT
  json_query(
                 '{"notUsed":[],"stock":[{"name":"eggs","value":"in stock"}, {"name":"milk","value":"out of stock"}]}',
                 '$.stock[?(@.name=="eggs")]' )
FROM dual;
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用Dot Notation,但是还没有找到一个例子,它涵盖了将where子句添加到数组的属性中.

select
  myTable.id,
  myTable.JSON_COLUMN.stock    -- how to get array element here?
from MY_TABLE myTable
where j.id = 46
Run Code Online (Sandbox Code Playgroud)

版:

SELECT * FROM …
Run Code Online (Sandbox Code Playgroud)

oracle json jsonpath oracle12c

1
推荐指数
1
解决办法
1497
查看次数

how to point AWS Route53 subdomain to AWS Lightsail instance?

I have setup a Wordpress on Lightsail, and have created a static IP which I can access WP ok.

I have migrated my .co.uk domain across to Route53 from another provider and am trying to point blog.example.co.uk to my Lightsail instance.

In Lightsail I have setup a DNS record like this:

A   example.co.uk           12.34.56.78
A   blog.example.co.uk      12.34.56.78
Run Code Online (Sandbox Code Playgroud)

It then lists these DNS servers in Lightsail:

ns-849.awsdns-42.net
ns-1643.awsdns-13.co.uk
ns-341.awsdns-42.com
ns-1516.awsdns-61.org
Run Code Online (Sandbox Code Playgroud)

I've taken those DNS servers and set on the root of …

dns amazon-web-services amazon-route53 amazon-lightsail

1
推荐指数
1
解决办法
2319
查看次数