Results 1 to 3 of 3

Thread: Cross Apply

  1. #1
    Join Date
    Apr 2013
    Posts
    8

    Question Unanswered: Cross Apply

    Hi,

    I am rewriting some SQL Server SPs into PostgreSQL functions one of them uses a CROSS APPLY in a SP similar to this:

    SELECT
    t.col1,
    t.col2,
    ca.col1,
    ca.col2
    FROM
    tableTest t
    CROSS APPLY fn_whatever(t.col3, t.col4) AS ca

    I have wrote and tested the function fn_whatever which works ok but I cannot work out how to use.

    I tried:

    SELECT
    t.col1,
    t.col2,
    ca.col1,
    ca.col2
    FROM
    tableTest t
    fn_whatever(t.col3, t.col4) AS ca

    But the last line gives a syntax error

    Please help if you can

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    This is currently not possible.

    Postgres 9.3 will be able to use LATERAL for this (which is the ANSI standard compliant implementation of SQL Server's cross apply).
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Apr 2013
    Posts
    8
    Thanks for the information shammat I will wait in anticipation for the 9.3 release

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •