New answers tagged dynamic-sql
Here is the answer to the above post. sqlshipped :=' and a.ORDS_COMPLETED_DATE between TO_DATE(' ||'''' ||shippedfrom ||'''' ||',''DD-MM-YY''' || ')and TRUNC(TO_DATE(' ||'''' ||shippedto ||'''' ||',''DD-MM-YY''' ||') + 1) ';
you should remove redundant parentheses surrounding BETWEEN clause. After all I think the best solution would be: sqlshipped := ' select * from TEST_TABLE a where a.ORDS_COMPLETED_DATE between :1 and trunc(:2 + 1) '; execute immediate sqlshipped using shippedfrom, shippedto; This is most efficient, because when using binding query need not to be ...
Try the following code: CREATE TABLE #Names ( [Type] VARCHAR(50), ColNum SMALLINT, ColName VARCHAR(50), ColDataType VARCHAR(20) ) INSERT INTO #Names VALUES ('Customer', 1, 'CustomerID', 'INT'), ('Customer', 2, 'CustomerName', 'VARCHAR(50)'), ('Customer', 3, 'CustomerJoinDate', 'DATE'), ('Customer', 4, 'CustomerBirthDate', 'DATE'), ...
This sounds prime for a front end display solution. Query 1 would pull back your data, Query 2 would pull back the column names and in code when you build what ever structure you use to display you set the headers from the second query. While a Pure SQL Method may be possible it will be dynamic SQL and code maintnence would be a nightmare. Also your ...
Top 50 recent answers are included