小编pri*_*nce的帖子

PostgreSQL - 在存储过程中编写动态sql,返回结果集

如何编写包含动态生成的SQL语句的存储过程,该语句返回结果集?这是我的示例代码:

CREATE OR REPLACE FUNCTION reporting.report_get_countries_new (
  starts_with varchar,
  ends_with varchar
)
RETURNS TABLE (
  country_id integer,
  country_name varchar
) AS
$body$
DECLARE
  starts_with ALIAS FOR $1;
  ends_with ALIAS FOR $2;
  sql VARCHAR;
BEGIN

    sql = 'SELECT * FROM lookups.countries WHERE lookups.countries.country_name >= ' || starts_with ;

    IF ends_with IS NOT NULL THEN
        sql = sql || ' AND lookups.countries.country_name <= ' || ends_with ;
    END IF;

    RETURN QUERY EXECUTE sql;

END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT …
Run Code Online (Sandbox Code Playgroud)

postgresql resultset execute dynamic-sql plpgsql

9
推荐指数
2
解决办法
4万
查看次数

根据我点击javascript/JQuery的位置更改HTML

在html页面中,您可能会有一些代码包含两个段落,如下所示:

<hr />
<p>The first paragraph</p>
<p>The second paragraph</p>
<hr />
Run Code Online (Sandbox Code Playgroud)

而且非常简单,这两个标签将呈现如下:


第一段

第二段


我感兴趣的是允许用户单击渲染的html代码中的某个位置,以便使用JQuery插入新元素.例如,如果我在第一段中找到的单词f*ir*st中单击字母i和字母r(只是单击,没有高亮/选择),我就可以插入自定义跨度元素或任何我就像在HTML代码中的那个位置那样导致这样的事情:

<hr />
<p>The fi<span id="myCustomSpan"></span>rst paragraph</p>
<p>The second paragraph</p>
<hr />
Run Code Online (Sandbox Code Playgroud)

有什么想法可以帮助我吗?我的要求不包括绝对定位.这不会解决我的问题.

javascript jquery css-position click dom-manipulation

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

SQL:field = other_field即使它们相同也返回false(NULL值)

我有一个困难,因为在比较子查询中的两个字段时,尽管字段相同,即它们都具有NULL值,但比较返回FALSE结果

Therfore NULL = NULL返回FALSE

现在我知道NULL应该与IS运算符进行比较,但是当我比较两个字段时,我应该知道它们是否包含空值?如果值为NULL,我需要比较两个相同数据的字段.

考虑这个SQL:

SELECT 
*
FROM
fts.fts_customers_data_50360001
WHERE 
    fts.fts_customers_data_50360001.record_type = 15
    AND
    fts.fts_customers_data_50360001.mid = 103650360001
    AND NOT EXISTS
    (
        SELECT 
            fts.temp_fees_50360001.record_type
        FROM 
            fts.temp_fees_50360001
        WHERE 
            fts.temp_fees_50360001.record_type      = fts.fts_customers_data_50360001.record_type    
            AND 
            fts.temp_fees_50360001.merch_id         = fts.fts_customers_data_50360001.mid
            AND 
            fts.temp_fees_50360001.fee_curr         = fts.fts_customers_data_50360001.currency
            AND 
            fts.temp_fees_50360001.card_scheme      = fts.fts_customers_data_50360001.card_scheme
            AND 
            fts.temp_fees_50360001.tran_type        = fts.fts_customers_data_50360001.fee_type
            AND 
            fts.temp_fees_50360001.area             = fts.fts_customers_data_50360001.region
            AND 
            fts.temp_fees_50360001.srvc_type        = fts.fts_customers_data_50360001.card_type
    );
Run Code Online (Sandbox Code Playgroud)

在上面的查询中,

fts.temp_fees_50360001.card_scheme = fts.fts_customers_data_50360001.card_scheme

两者都有NULL值但比较返回false ..太糟糕了

任何想法都会得到很多赞赏

sql postgresql comparison null

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

PHP - 使用无cURL的http Web请求向网关发布XML数据

我试图找到一种无需cURL的方法,通过http web请求将数据发送到第三方支付网关.我开发了以下代码,实际上它与接收页面成功通信,但显然POST数据没有被发送.

<?php
function makeWebRequest()
{
    //URL where to send the data via POST
    $url = 'http://localhost/connect_to_gateway/receive.php';

    //the actual data
    $xml = '<?xml version="1.0" encoding="UTF-8"?>' .
            '<test>' .
                'Hi there!' .
            '</test>';
    $data = array('xml' => $xml);

    //prepare the HTTP Headers
    $content_type = 'text/xml';
    $data = http_build_query($data);
    // use key 'http' even if you send the request to https://...
    $options = array(
        'http' => array(
            'method'  => 'POST',
            'header'  => 'Content-type: ' . addslashes($content_type) .'\r\n'
                            . 'Content-Length: ' . strlen($data) …
Run Code Online (Sandbox Code Playgroud)

xml postdata httpwebrequest file-get-contents http-headers

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