How to create a postgres function that returns a value

I am trying to move some of my web app logic into postgres functions. But I am hitting some errors while creating a very basic insert function.

This is the function that I am trying to create;

CREATE OR REPLACE FUNCTION create_user(IN email EMAIL, password TEXT, thumb TEXT) RETURNS text AS  $  BODY$   BEGIN    insert into users (unqid, thumb, email, password)     values (gen_random_uuid(), thumb, email, password)    returning unqid ; END; $  BODY$     LANGUAGE plpgsql   VOLATILE 

I am trying to get the function to return the uuid of the item if the insert is successful. And I am calling it like this;

select * from create_user('', 'passpopcorn', 'thumbelinaurl'); 

Getting this error;

SQL Error [42601]: ERROR: query has no destination for result data   Where: PL/pgSQL function create_user(email,text,text) line 3 at SQL statement 

From my googling it sounds like this error comes up when you don’t have a return statement in the query. But in my Insert query, I do have a returning statement.

Extra question; for simple insert statements (like this one here, or one with a couple of select followed by an insert), would functions be a better bet or procedures?

FunctionCompile returns Part::partd: Part specification 151345[[1]] is longer than depth of object

Today, I install mathematica 12.3 on my computer(windows), then I run the FunctionCompile code

cf = FunctionCompile[Function[Typed[arg, "MachineInteger"], arg + 1]] 

but it goes wrong, and return the information

Part::partd: Part specification 151345[[1]] is longer than depth of object 

I test on my another computer, FunctionCompile works well, so what’s happening here?

Running select filename from dbo.sysfiles returns short foldernames with tilde

I am running the following statement in SQL Server 2014(in Windows 2012R2):

select filename from dbo.sysfiles where fileid = 1 

However it returns:


I wish for the full path without the tilde.

(e.g C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\DATA\master.mdf)

I tried upgrading the SQL Server 2014 Express to 2016 Express but it made no difference.

Any ideas? Thanks. Dave

Query returns different result in postgresql

I am working on one project in which I am using postgresql.

I have following values

A     B -------------- 18815   0 29187   0 29494   0 28995   0 0       0 25762   3517 29291   0 29612   0 29331   0 30004   0 

Following query I am using to get my result.

select to_char(interval '1 second'*(A+B),'HH24:MI') as resulthours  For Example - select to_char(interval '1 second'*(18815+0),'HH24:MI') as resulthours (it gives result = 05:13) 

same way I got following result for all the values from both columns A and B

Result  05:13 08:06 08:11 08:03 08:07 08:08 08:13 08:08 08:20 

total – 70:29

now the issue is, expected result should be 70.55 , but I am getting gives 70:29

AJAX form post returns 0

I am working on a simple plugin that shows an HTML form where the user can input a keyword which is used to query an external API. I currently have the form and the related jQuery set up, but when passed to the plugin’s PHP file, I get a response of simply 0. At this point I’m only just trying to get any response but 0 (see the echo "Whyyyy" part). I’ve been scouring the internet and feel like I have tried everything that’s been suggested, leading me to think I’m making a mistake somewhere.

Any help would be greatly appreciated. 🙏

This is the plugin’s PHP:

defined('ABSPATH') or die('Ah ah ah. You didn\'t say the magic word.');  class News_search {      // Load scripts upon class initiation     public function __construct() {         add_action('wp_enqueue_scripts', array($  this, 'enqueue_scripts'));         add_action('wp_ajax_get_news_callback', 'get_news_callback');         add_action('wp_ajax_nopriv_get_news_callback', 'get_news_callback');         add_shortcode('wp_news_search', array($  this, 'wp_news_search_form'));     }      function enqueue_scripts() {         // Enqueue CSS         wp_enqueue_style('wp-news-search', plugins_url('/css/wp-news-search.css', __FILE__));         // Enqueue and localize JS         wp_enqueue_script('ajax-script', plugins_url('/js/wp-news-search_query.js', __FILE__), array('jquery'), null, true);         wp_localize_script('ajax-script', 'ajax_object',             array('ajax_url' => admin_url('admin-ajax.php'),                 'security' => wp_create_nonce('my-string-shh'),             ));     }      // Handle AJAX request     function get_news_callback() {         check_ajax_referer('my-special-string', 'security');         $  keyword = isset($  _POST['news-keyword']) ? $  _POST['news-keyword'] : null;         echo "Whyyyy";         die();      }      public function wp_news_search_form() {         $  content .= '<form id="wp-news-search__form">                         <label>                             <input type="text" name="news-keyword" placeholder="' . __('Enter keywords') . '" id="news-keyword" required>                         </label>                         <button id="wp-news-search__submit">' .                          __('Search for news', 'wp-news-search') .                        '</button>                     </form>';         return $  content;     }  }  new News_search(); 

And this is the JS file:

(function ($  ) {      $  (document).ready(function () {         $  ('#wp-news-search__form').submit(function (event) {             event.preventDefault();              // const keyword = $  ('#query-input').val();             const values = $  (this).serialize();               if (values) {                 // send stuff to php                 console.log(values);                 const data = {                     action: 'get_news_callback',                     status: 'enabled',                     security:,                     form_data: values                 }                  $  .post(ajax_object.ajax_url, data, function(response) {                     if (response) {                         console.log(`Response is: $  {response}`);                     }                 })                     .fail(() => { console.error('error'); })                     .always(() => { console.log('form submitted') });             }          });       });  })(jQuery); 

What would happen if a wizard calls a familiar in the Ethereal Plane and then returns to the Material Plane?

What would happen if a wizard summons a familiar (using find familiar) in the Border Ethereal, and then the wizard returns to the Material Plane (interrupting or ending the magical effects of etherealness)?

Would the familiar disappear due to the distance from the caster, since they are now on different planes?
Does the Ethereal Plane overlap with the Material Plane (Border Ethereal) such that distances are preserved and the familiar remains in the Border Ethereal while the caster is in the Material Plane?

The Ethereal Plane
Its shores, called the Border Ethereal, overlap the Material Plane and the Inner Planes, so that every location on those planes has a corresponding location on the Ethereal Plane. (PHB, p. 301)

Does this make possible the ability of having one’s familiar become an ethereal traveler?

WordPress primitive query returns = array

i am trying to primitive query form this wp_query:

$  query_v = array(     'post_type' => array('pro'),     'posts_per_page'    => -1,     'orderby' => $  count_visit,     'order' => 'ASC',     'tax_query' => array(         array(             'taxonomy' => 'servizi_pro',             'field' => 'slug',             'terms' => $  art_p,             'parent' => 0         )     ) ); 

the problem with this wp_query is that it does not sort me by the number of post views counter that I downloaded as an additional plugin, and I am trying to implement in a primita wordpress query, the wp_query with the addition of the instructions to display the type of custom posts based on the number of views:

<?php global $  wpdb; $  cpt = "pro";  $  q = $  wpdb->get_results(     $  wpdb->prepare(" SELECT * FROM {$  wpdb->prefix}term_relationships  LEFT JOIN {$  wpdb->prefix}terms ON {$  wpdb->prefix}term_relationships.term_taxonomy_id = {$  wpdb->prefix}terms.term_id  LEFT JOIN term_taxonomy ON {$  wpdb->prefix}term_relationships.term_taxonomy_id = {$  wpdb->prefix}term_taxonomy.term_id  LEFT JOIN {$  wpdb->prefix}posts  ON {$  wpdb->prefix}term_relationships.object_id = {$  wpdb->prefix}posts.ID  LEFT JOIN post_views ON {$  wpdb->prefix}term_relationships.object_id = {$  wpdb->prefix}  WHERE  {$  wpdb->prefix}post_views.type = '4'    AND {$  wpdb->prefix}posts.post_type = '$  cpt'  AND  {$  wpdb->prefix} = '$  art_p'         ") ); ?>  <?php print_r($  q);?> <?php foreach ($  q as $  r){ ?>     <?php echo "{$  r->post_title}"; ?> <?php } ?> 

but it always returns to me array (), where am I wrong?